View previous topic :: View next topic |
Author |
Message |
Guest
|
changing output voltage |
Posted: Mon Mar 12, 2007 3:20 pm |
|
|
I'm working with the 16f877 and am looking for a quick way to set the output voltage level between 0 and 5 volts. Does anyone know how to do this or point me to some example code? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Ttelmah Guest
|
|
Posted: Mon Mar 12, 2007 3:35 pm |
|
|
Directly, you cannot do this. The PIC, only has _logic_ outputs. However you can get close, using one of the PWM pins, feeding into a simple resistor/capacitor integrator. Provided your load is quite a high impedance, and the resistor chosen is large, good results from perhaps 0.4 to 4.6v can be obtained.
Best Wishes |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Mon Mar 12, 2007 7:30 pm |
|
|
You can drive a digital potentiometer (connected between Gnd and +V) using a PIC.
In the potentiometer cursor tap you will get an analog output in the range of 0 to 5V,
if you an need an output with more current and lower impedance, it is a matter of
connecting a transistor or an unity gain op amp in voltage follower configuration.
Humberto |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Mon Mar 12, 2007 9:56 pm |
|
|
If you do use a Digipot read the spec sheet for the current limits on the taps. Microchip parts a 1mA max on the center tap. That's bitten me several times. Now I remember to use a buffer.
John |
|
|
|