Shop OBEX P1 Docs P2 Docs Learn Events
sample and hold ADC08832 — Parallax Forums

sample and hold ADC08832

ADPADP Posts: 15
edited 2004-12-03 22:34 in BASIC Stamp
Has anyone used one of these with bs2. I am trying to use the code for adc0831 with adc08832 but it isnt working. I dont know why this is a problem or what i should consider looking into. Could anyone help if possible.
thanks alot guys

Comments

  • dandreaedandreae Posts: 1,375
    edited 2004-11-21 05:16
    Hello,

    What type of input are you trying to read in?· Are you reading in a variable voltage?·· Have you tried using the ADC0831?· The reason·I ask is that I want to make sure that isn't a problem with the·circuit. ·Here are a couple of links·regarding·the data sheets for the two ADC chips:· http://www.national.com/JPN/ds/AD/ADC08832.pdf·

    http://64.233.161.104/search?q=cache:mxjuaNi9788J:laspace.lsu.edu/aces/Docs/Component%2520Docs/adc0831.pdf+adc0831&hl=en



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Tech Support
    dandreae@parallax.com
    www.parallax.com

    ·
  • ADPADP Posts: 15
    edited 2004-11-21 17:37
    Thanks for your response,
    Yes i am reading variable voltage in and i am just trying to to see if i can get a display on the debug window using the code for adc0831. Unfortunately nothing is being displayed but i am even wondering whether sample and hold option adc08832 has anything to do with this problem. I am using pretty much similar connections as for adc0831 to BS2 except for the fact that· i am just using 1 channel instead of the 2 that adc08832 offers.
    Attached is the code im using for adc0831 (i am using the same for adc08332 but doesnt work).

    Your help will be highly appreciated

    ADP
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-21 19:20
    The ADC0831 code will NOT work with the ADC0832.· If you read the docs (hint, hint), you'll find that the ADC0832 has additional addressing bits required in the stream.· I can't find an ADC0832 at my local electronics store, but I did write a program for someone else that they said works (attached).· Please have a look and refer the ADC0832 docs for specifics.

    Another thing to double-check is your connections -- even though they have the same package size, the ADC0831 and ADC0832 do NOT have the same pinout.·

    attachment.php?attachmentid=36603
    ' =========================================================================
    '
    '   File...... ADC0832.BS2
    '   Purpose...
    '   Author.... Jon Williams
    '   E-mail.... [url=mailto:jwilliams@parallax.com]jwilliams@parallax.com[/url]
    '   Started...
    '   Updated...
    '
    '   {$STAMP BS2}
    '   {$PBASIC 2.5}
    '
    ' =========================================================================
    
    ' -----[noparse][[/noparse] Program Description ]---------------------------------------------
    '
    ' Connect 1K resistor between Stamp Dio pin and ADC0832.6 (data out) to
    ' prevent a damage in the event of a data collision.
     
    
    ' -----[noparse][[/noparse] Revision History ]------------------------------------------------
     
    
    ' -----[noparse][[/noparse] I/O Definitions ]-------------------------------------------------
     
    CS              PIN     0                       ' ADC0832.1
    Dio             PIN     1                       ' ADC0832.5 / ADC0832.6
    Clk             PIN     2                       ' ADC0832.7
     
    
    ' -----[noparse][[/noparse] Constants ]-------------------------------------------------------
     
    
    ' -----[noparse][[/noparse] Variables ]-------------------------------------------------------
     
    chan            VAR     Nib                     ' channel number
    adc0            VAR     Byte                    ' channel 0 value
    adc1            VAR     Byte                    ' channel 1 value
     
    
    ' -----[noparse][[/noparse] EEPROM Data ]-----------------------------------------------------
     
    
    ' -----[noparse][[/noparse] Initialization ]--------------------------------------------------
     
    Reset:
     
    
    ' -----[noparse][[/noparse] Program Code ]----------------------------------------------------
     
    Main:
      DO
        GOSUB Read_0832
        DEBUG HOME,
              "Ch0: ", DEC3 adc0, CR,
              "Ch1: ", DEC3 adc1
        PAUSE 100
      LOOP
      END
     
    
    ' -----[noparse][[/noparse] Subroutines ]-----------------------------------------------------
     
    ' Reads ADC0832 inputs as single-ended
     
    Read_0832:
      LOW CS
      SHIFTOUT Dio, CLk, MSBFIRST, [noparse][[/noparse]%110\3]         ' select channel 0
      SHIFTIN Dio, Clk, MSBPOST, [noparse][[/noparse]adc0\9]
      HIGH CS
      LOW CS
      SHIFTOUT Dio, CLk, MSBFIRST, [noparse][[/noparse]%111\3]         ' select channel 1
      SHIFTIN Dio, Clk, MSBPOST, [noparse][[/noparse]adc1\9]
      HIGH CS
      RETURN
    

    Update 12/3: I bought a couple ADC08832s and found that the code above does indeed work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office


    Post Edited (Jon Williams) : 12/3/2004 9:00:14 PM GMT
    227 x 192 - 2K
  • ADPADP Posts: 15
    edited 2004-11-21 19:44
    Hello Jon,
    Thanks for your reply. Unfortunately I am using adc08832 (not adc0832). I think they work differently. The adc08832 is a sample/hold converter. I dont think that really comes into play with the code BUT it has a conversion time of 4us as opposed to adc0832 (the one you are referring to) which has 32us. I know you can help me here. Could the conversion time effect the code??? If , so , how?? and what necessary ammendments should my code focus on??
    Thanks Jon, i would really appreciate you help on this one, once again.
    ADP
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-21 21:48
    Hmmm... I've compared the docs for the ADC0832 and for the ADC08832 and the interface timing is the same. Since I don't have the part there is nothing for me to do except prod you to read the docs carefully and fix the code as you see fit. I don't see anything obvious at this point.

    I'm on vacation for the next week, so I'll simply bid you good luck and Happy Thanksgiving.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • ADPADP Posts: 15
    edited 2004-11-21 23:32
    Well thanks Jon, I really appreciate your support and hope I am able to get my project working so that you dont find your account clogged with messages by the time you get back.
    happy thanksgiving to you too
    ADP turn.gif
  • ADPADP Posts: 15
    edited 2004-12-02 23:55
    Hi Jon,
    I was wondering how I could be able to count time betweend peaks. Lets say i have a sine wave coming into adc0831 at a certain frequency. How would I go about getting the time between the peaks using BS2. I know the voltages will be rising and falling according to the sine waves amplitude.

    thanks
    ADP
  • steve_bsteve_b Posts: 1,563
    edited 2004-12-02 23:58
    Not sure if the stamp could do this....but you'd have to have a proper timing device and be able to read the ADC and the time at the same time (stamp can't do this -- only one thing at a time)....but if you could get things done close enough together, then that should do.

    Then just mark the time at the peak of each ADC read and then determine the time between each positive peak.·

    It's rough/crude....but it all depends what you need for accuracy.

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

    Steve
    http://members.rogers.com/steve.brady
    http://www.geocities.com/paulsopenstage

    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."

  • ADPADP Posts: 15
    edited 2004-12-03 16:15
    Thanks Steve,
    Do you think LabView could solve this problem? I can constantly send data from BS2 to LabView and i'm wondering whether basic stamp is responsible for doing the necessary peak calculation values or would LabView take·care of this.
    Thanks
    ADP
  • allanlane5allanlane5 Posts: 3,815
    edited 2004-12-03 19:04
    Umm, no you can't "Constantly" send data from BS2 to labview -- there must be gaps on the RS-232 line from the BS2 to the PC running Labview -- because the BS2 is a single-tasking module, and even for 'constant' data, you have to have a loop. While the BS2 is looping, it isn't sending data. While it's sending data, it isn't doing anything else.

    Having said that, you could read the AtoD converter with the BS2, then send a result to Labview, then read a new value, then send, etc. The reading loop would take 500 uSec, but sending a character at 9600 baud takes a mSec per character. Say 4 digits, its 4.5 mSec per sample, or a max sample frequency of 222 hz.

    If the Stamp takes care of peak-detection, then it can take a reading every 500 uSec. This is a max sample frequency of 2000 hz. -- using Nyquist limits that you must sample a frequency twice as fast as the signal changes, this is a frequency of 1000 Hz.

    What is the frequency you are trying to measure?
  • ADPADP Posts: 15
    edited 2004-12-03 22:34
    thanks for the response,
    well i want to be able to take heart signals that enter the adc (0831) and through them out to LabView and I just found out that labView cant just take these signals and do the necessary calculations to find the BPM of the heart. So I just want to try and send a sine wave into the BS2 and just be able to calculate the time between the peaks. I could use a function generator and change the frequency accordingly. But i just want to that can be done and how.
    I'd really appreciate your help,
    ADP
Sign In or Register to comment.