Help with ADC INPUT DRIVER object
I'm having trouble getting the object: http://obex.parallax.com/objects/488/ to work correctly. Here is the code I am currently trying:
adc channel 0= 737
adc channel 1= 1
adc channel 2= 738
adc channel 3= 0
adc channel 4= 739
adc channel 5= 0
adc channel 6= 0
adc channel 7= 2048
This is with ch0 pulled high, ch1 low, ch2 on a 10k pot and the rest of the pins are left unconnected. Changing the voltage on ch0 seems to also effect ch2 and ch4. I have tested everything with the object: http://obex.parallax.com/objects/180/ so i know all hardware is working well. If I switch the first two channels so that ch0 is gnd and ch1 vref I get:
adc channel 0= 0
adc channel 1= 3039
adc channel 2= 1
adc channel 3= 2048
adc channel 4= 0
adc channel 5= 2051
adc channel 6= 0
adc channel 7= 2048
Anybody have any idea what is going on here? Isn't 3039 out of range for a 12-bit adc? I would really like to use this object as I like the ability to store and reset min and man values for each channel.
Any help is appreciated!
-ADZ
OBJ adc : "ADC_INPUT_DRIVER" pst : "Parallax Serial Terminal" PUB Main pst.start(921_600) adc.start(MCP_DIO_PIN, MCP_DIO_PIN, MCP_CLK_PIN, MCP_CSL_PIN, 8, 8, 12, 1, true) repeat pst.Str(String(pst#cs, pst#NL, pst#HM, "adc channel 0= ")) pst.dec(adc.getval(0)) pst.Str(String(pst#NL, "adc channel 1= ")) pst.dec(adc.getval(1)) pst.Str(String(pst#NL, "adc channel 2= ")) pst.dec(adc.getval(2)) pst.Str(String(pst#NL, "adc channel 3= ")) pst.dec(adc.getval(3)) pst.Str(String(pst#NL, "adc channel 4= ")) pst.dec(adc.getval(4)) pst.Str(String(pst#NL, "adc channel 5= ")) pst.dec(adc.getval(5)) pst.Str(String(pst#NL, "adc channel 6= ")) pst.dec(adc.getval(6)) pst.Str(String(pst#NL, "adc channel 7= ")) pst.dec(adc.getval(7)) waitcnt(clkfreq/10 + cnt) '10Hz screen refreshThe output on the serial terminal looks like this:
adc channel 0= 737
adc channel 1= 1
adc channel 2= 738
adc channel 3= 0
adc channel 4= 739
adc channel 5= 0
adc channel 6= 0
adc channel 7= 2048
This is with ch0 pulled high, ch1 low, ch2 on a 10k pot and the rest of the pins are left unconnected. Changing the voltage on ch0 seems to also effect ch2 and ch4. I have tested everything with the object: http://obex.parallax.com/objects/180/ so i know all hardware is working well. If I switch the first two channels so that ch0 is gnd and ch1 vref I get:
adc channel 0= 0
adc channel 1= 3039
adc channel 2= 1
adc channel 3= 2048
adc channel 4= 0
adc channel 5= 2051
adc channel 6= 0
adc channel 7= 2048
Anybody have any idea what is going on here? Isn't 3039 out of range for a 12-bit adc? I would really like to use this object as I like the ability to store and reset min and man values for each channel.
Any help is appreciated!
-ADZ
Comments
Depending on your clock speed, and the ADC's operating voltage, FastMode will probably be running your ADC out of specification. FastMode should only be used on 12-bit ADCs when running under 40MHz (or 32MHz -- I forget). 10-bit ADCs work at much higher sample rates and can handle the faster reading better (but still FastMode should be used with caution at 80+MHz). So try turning off FastMode, or run the clock speed at a lower speed.
adc channel 0= 2046
adc channel 1= 4095
adc channel 2= 2046
adc channel 3= 0
adc channel 4= 2047
adc channel 5= 12
adc channel 6= 0
adc channel 7= 13
It also seems as though again ch0, ch2, and ch4 are some how interfering with each other as touching the resistor on p0 affects all three channels. Thanks again for helping me out with this!
-ADZ
FF
The other question is how are the inputs held high or low? With a resistor? Or shorted? Or and opamp? I doubt this is a problem as you are getting weird readings on many inputs.
Double check your wiring and make sure there is a decoupling capacitor on the power and reference pins. Are you running the ADC at 3.3V or 5V?
Edit: I'm running the ADC at 5v
FF
-ADZ
Very cool. I've always wanted to build a tesla coil and the new solid state ones look like a blast to play with!
You never mentioned if you had decoupling capacitors or not, this is very important for these ADCs (really for any IC). Also, the power supply is important, as the read speeds get faster, more spikes in the power draw are generated. Thus, if you are running the device off a limited power supply like a battery or USB (or the like) the increase in power draw or the noise on the power line could be causing an issue, capacitors, again, may fix this (but this time larger power rail filter capacitors). What is your power supply like and what kind of filtering/decoupling capacitors do you have?
They are a lot of fun to play with however you should see the pile of dead mosfets. Lol, Its silicon genocide! That's the reason I decided to get the prop involved, eventually I would like to use it to control phase lead/lag, switching dead time, over-current and over-voltage, audio/midi modulation and the list goes on. Hopefully the a/d will be able to display things like dc buss voltage, average current ( with use of a CT), and I'm sure I'll find a few other things to monitor.
I know when I wrote the driver I tested it at 80MHz with out FastMode and it worked, else I would have created a SlowMode, but again I might have been running above specifications and my IC just sucked it up. I just found my MCP3208, I couldn't find it yesterday, I'll do some testing today and see if I can duplicate something. I use many (hundreds) MCP3008s every day using this driver, but the 3008 has a higher sample rate and the project runs at 40MHz, so most of this stuff isn't comparable to your problem.
I'll let you know.