Looking for example code with the MCP3208 analog to digital converter
turbosupra
Posts: 1,088
I saw these
http://obex.parallax.com/objects/481/
http://obex.parallax.com/objects/488/
But they are a little complicated for a beginner such as myself and I was looking for a simplistic starter so that I could experiment with my ADC and led/testboard where I could change a few values and see what it does.
My ultimate goal is to output a specific voltage value to my multimeter, and be able to manipulate that in the code.
Thanks for reading.
http://obex.parallax.com/objects/481/
http://obex.parallax.com/objects/488/
But they are a little complicated for a beginner such as myself and I was looking for a simplistic starter so that I could experiment with my ADC and led/testboard where I could change a few values and see what it does.
My ultimate goal is to output a specific voltage value to my multimeter, and be able to manipulate that in the code.
Thanks for reading.
Comments
to OUTPUT a voltage you don't need a analog digital converter you need the oposite
a digital to analog converter
There are two basic principles to do that
first: PWM (pulse-width-modulation (needs one IO-PIN and some additional hardware R-C eventual OP-Amp as a voltagefollower)
second: R-2R-resistor ladder needs one IO-Pin per bit resolution
If you don't need high speed on changing the voltage
the easiest way for PWM would be a loop
with two adjustable waittimes for IO-Pin high and io-pin low
and a resistor and condensator connected to the outputpin to convert the PWM DC alternating between 0V and 3.3V to a (more or less) flat DC-voltage
post which direction you would like to go or what more questions you have about coding this
best regards
Stefan
Thanks for the reply!
I thought about using a resistor ladder, and some spin code to tell it what to do, with multiple input pins, and 1 output pin.
I don't think I need high speed on changing, maybe .1 seconds? I would like to do the adjustment through software/pwm (as I think that would give me the most flexibility)
The resistor/condensator sounds like the best solution for me. I need to vary from as low as 1.4vdc to as high as 2.1vdc . Thanks for the help!
0.00 V means always off
1.65 V means 50% of the time on 50% of the time off
3.30V means 100% of the time on
1.40V means 1.4/3.3=42.4% time on 57.6% time off
2.10V means 2.1/3.3=63.4% time on 36.6% time off
depending on the values of R and C the adjusting time to a new voltage changes
and the current you can deliver to a load changes
digital multimeters (DMM) have 1MOhm-input resistance minimun. This means as long as you just
connect the voltage to a DMM you can use values from 1kOhm to 100 kOhm and condensators
from 0.1 µF to 100µF
For speed perfomance and lowest rest"ripples" you have to do more (OP-Amp as a voltagefollower with
"flatening capacitors on input and output of the OP-AMP
best regards
Stefan
So if I set up my crystal and time settings, I can tell spin to have the voltage on for 42.4% and then flatten it with the resistor/capacitor?
Can you tell me what happens if I used 1k and .01uF vs if I used 100k and 100uF? How would the two extremes affect my output? As I'm connecting them to an automobile ecu once I get it working.
https://www.parallax.com/Portals/0/Downloads/appnt/prop/AN001-PropellerCountersv1.1.zip
I will read up on this!
I'm actually working on a similar project. I would highly recommend going through all of the PE Labs. All of this would make much more sense after finishing them.
Are you talking about this line in the code?
ctraval long %00111 << 26 + 0 'NCO/PWM APIN=0 {BPIN=1} <-not used
Which labs are you talking about, the ones in the book that come with the chip/kit? Or the data sheet? http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/PropellerDatasheet-v1.2.pdf
They're very helpful
I'm trying to read the AN001 document and it really makes no sense to me at all, I am so lost and confused!