I am thinking to use Arduino to generate square wave of various duty cycle and frequency. The square wave is going to be fed into a transistor amplifier.
What options do I have for programmatically controlling the output of a transistor?
-
\$\begingroup\$ you need to clarify the question. Are you talking about generating a DC voltage from the PWM? \$\endgroup\$Mark– Mark2010年11月12日 03:04:35 +00:00Commented Nov 12, 2010 at 3:04
2 Answers 2
The Arduino has an analogWrite(pin, level)
function that takes care of the details of the on-chip PWM hardware. Programmatically, you just give analogWrite
the pin number you're writing to, and a value 0 to 255 to control the duty cycle. If the hardware is such that the transistor saturates at one logic level from the PWM pin, and cuts off at the other, it should deliver proper PWM controlled power to your load. Be aware that the RMS value of PWM goes by the square of the duty cycle; 70% on, 30% off equates to half power.
If you use a low-pass filter (resistor to capacitor), you can filter the higher frequency PWM to be an average value of your PWM. So, if you are at 50% duty cycle and your voltage range is 0-5 V, you will get 2.5 V. This can be used to easily generate analog voltages.
The analog voltage can then be used to control the MOSFET.