CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

changing output voltage

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








changing output voltage
PostPosted: Mon Mar 12, 2007 3:20 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Mar 12, 2007 3:33 pm     Reply with quote

See AN538 from Microchip: Using PWM to generate an Analog Output.
http://ww1.microchip.com/downloads/en/AppNotes/00538c.pdf
The schematic on page 2 shows an Opamp powered by +/- 10v.
I don't think you need that. I think a single-supply Opamp running
from +5v and Ground should work.

Another article:
http://www.tigoe.net/pcomp/analogout.shtml
Ttelmah
Guest







PostPosted: Mon Mar 12, 2007 3:35 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Mar 12, 2007 7:30 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Mar 12, 2007 9:56 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group