PDA

View Full Version : Analog Output from a PIC



robertmark68
- 1st August 2006, 19:00
Hello

I am brand squeaky new to the world of PIC's

I ask that you forgive my ignorance and bear with a stupid question or two.

First, a little background....

I recently purchased the X1 bundle and have been happily trying the neat little programs it comes with to get a feel for BASIC with PIC's.

Now for my question:

Is it possible for a PIC to output an analog voltage level on one of its pins?

I know that you can connect a I2C DAC to a PIC to do this BUT...I'm wondering if that would be redundant or not.

All I really need is for the PIC to output a voltage between 0-2.5V DC for a length of time I specify (multiple of half seconds).

This sounds fairly easy to me but I don't know if a PIC can do this or not.

Can someone point me in the right direction with a piece of code, or tell me I am insane and to get lost!

Hopefully not the latter!

Thanks so much in advance

Robert

mat janssen
- 1st August 2006, 19:11
You can use an output in the pwm mode and with a low pass fliter you will get a n analog value of this signal. You will get 256 steps of the analog value from 0 till 100% of the used supplyvoltage.

paul borgmeier
- 1st August 2006, 20:09
In addition to the PWM approach (which works great), PICs like the 16F628A have an on-board Voltage Reference Module (based on a 16- tap resistor ladder) where the output can be directed to RA2. This module provides limited D2A capabilities, but it might be useful for your application. See the data sheet for your PIC (section 11 for the 16F628A) and see if it might work for you.

Melanie
- 1st August 2006, 21:19
Actually the PICs Hardware PWM is 10-bit. The upper 8-bits you can control directly with the HPWM command, and the bottom couple of bits you can manipulate the appropriate Register (also within PICBasic - no Assembler needed)..

robertmark68
- 2nd August 2006, 18:06
I want to thanks the three of you who responded to my plaintive cry of woe....

After careful consideration and further purusal(sp?) of my PBP Manual.....

I happened upon the wonderful 'I2CWRITE' feature! This little gem coupled with an Analog Devices I2C 'digipot' will allow me to use the 2.5volt reference included in my Laser Diode driver to set the Laser Diode Current output to whatever my heart desires!

Were I to use the PWM method, I'd have to worry about the DC Supply (NiMH battery) changing over time as it surely would due the large amount of current I will be drawing to power my Laser Diode.

I will look into to the reference option though....that might be worthy of future consideration!

Thanks Again!
Robert