ADC using counters
Litefire
Posts: 108
Hey, i'm trying to perform ADC on the propeller using sigma-delta conversion via the counter modules.·
I know how to set up the circuit, but what would i need to do to program in this funciton?· and would this require a separate cog to run properly?
I assume that it is possible to use this with 5V+ devices?· any modifications that i would need to do to use this?
finally, what changes to the code do i need to perform to be able to use different pins in the program?
Thanks so much!
~~Brian
Post Edited (Litefire) : 4/13/2007 1:26:19 PM GMT
I know how to set up the circuit, but what would i need to do to program in this funciton?· and would this require a separate cog to run properly?
I assume that it is possible to use this with 5V+ devices?· any modifications that i would need to do to use this?
finally, what changes to the code do i need to perform to be able to use different pins in the program?
Thanks so much!
~~Brian
Post Edited (Litefire) : 4/13/2007 1:26:19 PM GMT
Comments
What do you mean by "use this with 5V+ devices"? The output is an analog signal from roughly zero to +3V. You can buffer this with an op-amp and, if the op-amp runs off some other power supply (+5V or +5V/-5V or +15V/-15V), you can amplify this to anything you want.
Normally, you use a cog for each analog to digital channel. The ADC object takes care of launching this. The I/O pins used are set by a pair of named constants in the ADC object which just continually converts the analog input to a digital value in a location that the caller provides. Have a look at any of the examples mentioned.
Post Edited (Mike Green) : 4/13/2007 2:53:01 PM GMT
This subject has come up many times here in the forum. Start at the good threads index sticky, and also search on ADC or analog. Here is one: http://forums.parallax.com/showthread.php?p=619937
For best results the ADC requires its own cog, which could monitor two ADCs based on its two counters. The two pins used are chosen when specifying the count mode register. The count mode register specifies one pin to use for input and the other for output. The assembly language supervisor simply starts the counter going and reads it after a fixed time interval. The analog to digital result is a fraction, the number of counts accumulated by the counter module, divided by the total number of clock cycles in the sampling interval. You could do that in SPIN also without dedicating an assembly COG to it, but the result could not be quite as accurate.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
my one question would be how to ask the ADC cog to scan two specified input pins. such that i could say:
result := adc.scan(1, 5)
where pin 1 is the fbpin and pin 5 is the adcpin from the example code in AN001.
i need to be able to scan 4 of these (i have the pins and required components set up, i just need to be able to control them)...
and mike, when i said if it was kosher with +5V devices i was trying to ask if it could translate a voltage that was at or greater than 5v.
~~Brian
Suppose the resistor from Apin to Bpin is 100 kohms as shown in AN001. AN001 suggests using a 150kohm resistor for the input, for a full scale range to cover from 0 to 3.3 volts and a little beyond. If you have a higher input voltage, or a +/- larger range in fact, you will use a higher resistance at the input. For example, if the maximum input is 10 volts, choose the minimum resistor value from,
You would actually choose a slightly higher resistor so that the ADC does not go too near saturation.
I posted a circuit analysis (which should not be taken as authoritative!) in this thread:
http://forums.parallax.com/showthread.php?p=633577
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
any hints on what to do to let me use one ADC object for multiple possible pairs of pins? essentially, i want the desired pins to be specified at call-time, so the assembler code should be updated to allow variables instead of the constants that are currently used as pin declarations. since i have zero assembler knowledge, anyone mind helping me out with that?
thanks so much!
~~Brian
could this be due to timing errors? the loop is constantly running, with the spin running the data output... perhaps the data is being outputted during a scan and is reading weird values. here's a sample of the data i got at 3.3v (Vdd).
171
170
171
168
170
169
170
168
163
148
170
170
153
150
168
169
170
138
169
so it is usually around 170 at Vdd, but it has some weird fluctuations... can anyone explain this?
~~Brian
Here's a modified version of ADC.spin. I haven't tested it yet, but give it a try.
Mike
Well, i've got MAJOR spread on my values... even when being held on ground it's got a spread of +/- 15 from around 120.
This seems to be happening on all of my adcs (i've got four of them on the one DIP chip). I've checked all of the connections, and they're all solid, and leads are really short... how accurate can i expect this to be?
~~Brian
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
sadly, my robot did not qualify for the competition tomorrow... so i'm taking a little break from it... but i think i'm going to try to improve it to have a jump start on next year.
this would be a huge help.
~~Brian