Shop OBEX P1 Docs P2 Docs Learn Events
Using the adc8038 — Parallax Forums

Using the adc8038

mosquito56mosquito56 Posts: 387
edited 2009-04-18 22:26 in Propeller 1
·I ordered about 20 adc8038's and finally got one working today. I first used the 8031, then the 8034 and now the 8038.

· When I first started reading the adc chip operation, I read that the author had problems getting the chip to read 256. Then I remembered the 8031 could read 256 so I checked his code.

Basically 2 options

Method 1:

··datar:=2
· repeat i from 0 to 7········· ' read 8 bits············ 'Example 3
··· if ina[noparse][[/noparse]dataoutFromADC] == 1········
······· datar:=datar*2

other method:

datar:=0
· repeat i from 0 to 7········· ' read 8 bits············ 'Example 3
··· if ina[noparse][[/noparse]dataoutFromADC] == 1
····· datar |= |< i············ ' set bit i HIGH
··· else
···· ·datar &= !|< i


I can get a reading of 256 when connected to vref from the first code but not the second.

Am I just cheating? Grounding the input gives a value of 2. This makes me think that I am just doubling the values.

Has anyone figured this problem out? Which method is more accurate?

P.S. Can someone translate this into english?· datar &= !|< i

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·······

······· "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet


Post Edited (mosquito56) : 4/17/2009 10:52:36 AM GMT

Comments

  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2009-04-17 11:45
    I can't comment much on the code posted or the adc8038 (I googled but didn't see a datasheet immediately, so I moved on). Do you have a link handy? What do you mean by "read that the author...", what is the document you are reading?

    The question regarding datar &= !|< i. Here is how I think it works....

    i is a value that is decoded into a long. If i is 1, the 1 bit is set, if i is 10, the 10 bit is set (counting from zero), if i is 31, the 31 (or most significant bit) is set. If the value is bigger than 31, then the remainder is the value that is set. In other words if i is 32, it is the same as 0, 33 is the same as 1, etc.

    The decoded value is then inversed. This will create a long with all 1s and one 0 in the i position. That long is then anded with the current value of datar.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
    www.tdswieter.com
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2009-04-17 14:17
    ADC08031/ADC08032/ADC08034/ADC08038
    8-Bit High-Speed Serial I/O A/D Converters with Multiplexer
    Options, Voltage Reference, and Track/Hold Function

    Data Sheet:

    www.national.com/ds/DC/ADC08031.pdf#page=1

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Aka: CosmicBob
  • mosquito56mosquito56 Posts: 387
    edited 2009-04-17 19:38
    · All programs are from the obex. The comment was in 8031 object.

    Judging by the response, not to many people are using this chip.

    Thanks for the explaination about ·datar &= !|< i. A little to advanced for me. This is MIT stuff and I'm just a community college type guy. ·Reminds me of the contests in school of people trying to write code in the smallest space possible.

    · Any discussion on the subject is welcome.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2009-04-18 00:28
    There are plenty of timing diagrams in the data sheet. Perhaps you could make a stab at writing a spin shifting routine to clock data in from the 8031. This might be a good exercise to learn deeper about SPIN and the 8031 and to double check the objects in the exchange.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
    www.tdswieter.com
  • mosquito56mosquito56 Posts: 387
    edited 2009-04-18 01:14
    Tim,

    ·I have been for about 2 months now. I used the 8031, 8034 and now 8038.



    Non of them will read 256. I was modifying one today and it seems to work. I tried to copy it into my prog and it doesn't work.

    · 7 bits is fine for my job. I understand the timing of the chips but why re-invent the wheel?

    Have a good one

    Don

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2009-04-18 01:42
    Don -

    I don't understand what you mean by reading 256. I think I might not be understanding the part fully since I only glanced at the data sheet. From what I see it is an 8-bit device when means that you should read values from 0 to 255. When you say 256 do you mean 8-bit?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
    www.tdswieter.com
  • mosquito56mosquito56 Posts: 387
    edited 2009-04-18 02:20
    ·Yes, I guess it should be 255. I was thinking 2 to the 8th bit:=256. If you count 0 as an entity in the mix, then 255 would be the max. Since it only reads 127 with vref, I would say something not quite right.

    Even with the one I have "working", it only reads 254.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • grindelgrindel Posts: 68
    edited 2009-04-18 02:29
    I got the ADC8031s in yesterday, I'm far from a competent coder, but I'll let you know if I can figure anything out. I'm constantly bothering the EEs at work, so if all else fails, they will probably be able to figure something out.
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2009-04-18 02:30
    If it reads 254, then it means you are able to read the buffer and it is possible a problem with the voltage coming in and vref. I don't have much experience with ADC to comment intelligently much further, but if you get 254 you are reading every bit in the register it sounds like.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
    www.tdswieter.com
  • grindelgrindel Posts: 68
    edited 2009-04-18 02:48
    so really, what we're talking about here is .02 Volts right? Could however you are hooking this up have that much difference in potential?

    Is it possible to manually operate the chip by having toggle switches for for CS and CLK and hooking up an LED to DO? For example: Switch on CS and toggle CLK on and off 16 times? <-ignore this, didn't print the AC section of the data sheet-'cause I'm not measuring AC (hehe)

    And just a general question, since I have hooked up and not yet applied power to my 8031, do I need to use current limiting resistors on anything but from the DO pin to my prop? I plan on using my +5V bus as Vref and Vcc and +3.3 V bus for Vin+. Vin- and GND hooked straight to ground.

    It should output somewhere around 10101001, right?

    Post Edited (grindel) : 4/18/2009 3:28:08 AM GMT
  • mosquito56mosquito56 Posts: 387
    edited 2009-04-18 03:08
    Grindel, I have never use any current limiting resistors on ANYTHING. I don't understand why everything works so well. I have spi? card from ucontroller, rctime, lm34, adc8038, t.v. card from ucontroller and 5 led's. I do use the resistors for the leds as they have a tendency to fry in about 5 secs when hooked up straight.

    I installed the 8038 backwards yesterday, pluged it in, saw my led dim and left it connected for· a couple minutes. I put my finger on the reg chips and literly? burned my fingers. Found the problem, flipped the chip and it worked.

    As to your question about voltages. I use 5v on all voltages so I don't know about values for 3.3v. If you use the 8031 object let me know if you get the 254 reading with vref applied.

    I am wondering since my program uses about 6 cogs if there might be a timing issue. When I run one cog, just program and tv it seems to work fine but when I copy the same code into my main program, I can only get the 127.
    · I played with the waitcnt in the loop, increase and decrease with no change. I don't know why this happens but until I get my temperature measuring device and hook it to some hot surfaces, 7 bits will do.


    Don

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • grindelgrindel Posts: 68
    edited 2009-04-18 03:23
    Thanks for the assurance. Unfortunately my prop is upstairs near the sleeping wife and baby, so I'm done for the night, but I'll let you know.

    The reason I think that 3.3 V will output 10101001 is that 3.3V/5V=.66 .66*256=169ish 169 to bin=10101001

    Looking at the data sheet again I think the CLK frequency has to be between 10 and 400 khz, my switch idea will not work unless you have REALLY fast fingers...heh.
  • grindelgrindel Posts: 68
    edited 2009-04-18 21:33
    I said 8031, but meant ADC0831...anyway, the 0831 can output 255 when Vin and Vref are hooked to the same source.

    when 3.3 was compared to 5 it output 170...which I guess might mean it always rounds up. I only have a $2 volt meter so I couldn't confirm that with any sort of confidence.
  • mosquito56mosquito56 Posts: 387
    edited 2009-04-18 22:26
    I tested the 0838 extensively this moring and determined that it only reads 7 bits.

    By using a thermocouple wire to imput thru an op amp, I can get the chip to count from 1 to 25 by ones.·I didn't go any further as it wasn't necessary. When the same pin is connected to 5v·it reads 127. I guess you can just connect to a pot that goes from 0 to 5 volts and do the same thing.

    ·· By changing the code I could get it to read both the msb and lsb. The chip actually outputs two sets of bits. Lsb and msb first. By waiting for sars to go high you get·msb first and by waiting for sars to go low you get lsb first. Both ways gave identical numbers.

    The code is available, but it runs on t.v. You can modify it to run an 0831 by elimiating the first loop which sets the chan number. Let me know if anyone wants· it.

    It reads the chip and fills a string with "10101010", prints the string and then converts the string to decimal.

    Output is



    Adc 1 is xx··········· 10101010101····· xx

    Adc 2 is xx··········· 10101010101····· xx,· etc.

    ··········his coding····my coding······· my coding

    ········· datar



    Have a good one

    Don.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
Sign In or Register to comment.