Closed digitaldanny closed 3 years ago
NE555 Variable Frequency Square Wave Generator - YouTube
This video is a good reference for building the first stage of this circuit.
Square wave to triangle wave circuit - YouTube
This video explains how to use RC networks to produce triangle or sine waves from an incoming square wave.
I could use a voltage ladder at the input of the 555 to select various frequencies. One of these could be enabled at a time using GPIO or a decoder IC so that the MCU doesn't need to use as many GPIO.
I do need to be careful that the resistance range keeps R2 >= 100*R1 so that the duty cycle stays at 50%. The formula below. If R2 is large enough, R1 can be ignored and makes the duty cycle ~50%.
DC = (R1 + R2) / (R1 + 2*R2)
DC(R1=0) = R2 / 2*R2 = 50%
Adding some links below related to the class AB amplifiers for the final stage of this circuit.
Introduction to Class A, Class B, and Class AB Amplifiers - YouTube
Realized today that the MCU will not be able to play the tune after being unplugging from the speaker circuit. I'd like to keep this feature in, so the circuit will need to select between frequencies on its own.
Did some testing on the breadboard for the class AB amplifier today. Will do some more testing tomorrow to see if I actually need an op amp for voltage control or if I can control amplification with a 3rd transistor instead.
First I build a class B amplifier and saw crossover distortion as expected (pictured below). Although, based on the voltage divider formula for my biasing resistors 3.3V * 1360 / (10k + 1360) = 0.21V, I expected to see only around 0.1V (0.21/2) of the positive and negative voltages missing. In the picture below, I see closer to 0.5V missing on both sides.
I replaced the biasing resistors with 2 diodes and saw a huge reduction in distortion; however, there is definitely still some distortion. Will need to play around with the circuit tomorrow. This might just be a mismatch in the voltage drop across the diodes vs the Vbe of the transistors.
Describe the solution you'd like
Frequency should be controllable with MCU.Describe alternatives you've considered Using a DAC/LM386 would be the easy solution to create a output signal to the speaker. But since I'd like to use this circuit to meet an analog complexity requirement for this project, I will be building a variable frequency waveform generator
that can somehow be controlled with the MCU.