View Full Version : Discussion PIC output
S. Hackwelder
Jul 09, 2006, 10:42 PM
Hey!
Just lurking about and had a question. How would you have a microcontroller output a voltage that corresponds to a measured value? Say your measure 20 (units) with your PIC, I want 20 millivolts or milliamps to output to a multimeter.I would like a range of zero to about 200.
Thanks
Spockie-Tech
Jul 10, 2006, 12:28 AM
Use a Pulse Width Modulation output powered by a interrupt-driven timer (or inbuilt PWM if the micro has it), then a low-pass filter (a resistor and a capacitor) to convert the variable width pulse into a variable DC voltage.
Sounds complicated, but its 2 components and some code. :)
If you need to drive any sort of load with the voltage, you will need an op-amp/buffer to prevent ripple
Exact values of the R/C circuit will depend on your PWM frequency.
For more details, google for "pwm to voltage filter". heres one example page
http://www.ontrak.net/pwm.htm
xorcise
Jul 10, 2006, 01:15 PM
You can use an 8-pin 12-bit DAC like the MCP4921. It has a very simple SPI interface and works a charm. Set it up with a 2.5V reference and you can get voltage divisions at 610uV (0.61 mV) each. I'm using the MCP4922 12-bit Dual-DAC in an application and have code written to drive it here (it has buffers and more built-in features):
MCP4922 12-BIT DUAL DAC DRIVER & TEST DEMO (http://www.circuit-ed.com/forums/viewforum.php?f=8)
S. Hackwelder
Jul 12, 2006, 10:56 PM
Hey;
Thanks for the suggestions guys. I am working on the pwm code now. I hope I can get that to work.
Thanks
Comatose
Jul 12, 2006, 11:35 PM
PWM works okay, but some sort of serial interface is really the best way to go for moving data out of a PIC. Its very easy to get a PIC talking to hyperterminal.
Spockie-Tech
Jul 13, 2006, 02:02 AM
Assuming the goal is just to get the informaiton on a display and dont mind running a program to do so, then serial output is a good option.
If however, the application is a portable display (like a Multimeter) or some other tiny 7-seg display (there are lots of units that require a 20-200mv input), the PWM->voltage output is the go
S. Hackwelder
Jul 13, 2006, 07:35 AM
Ya,I intend for the multimeter to display the results of my measurement. I am building as device that will mount to my plane measure max. speed reached, and after I land I want to display the results. Ya, serial output would be good, but it is more overhead than I am willing to have(computer,rs232 chip,etc).
Thanks!
P.S. Yes , 200 is wishful thinking!
vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.