Shop OBEX P1 Docs P2 Docs Learn Events
using 2 ADC0831 w/same clk and cs — Parallax Forums

using 2 ADC0831 w/same clk and cs

faridfarid Posts: 1
edited 2004-11-03 06:17 in Learn with BlocklyProp
advice please

i am trying to display two separate voltage on·two lines of LCD and i'm using two adc0831. i connected·both cs to same pin and also both clk's to same pin too. i get reading from one ADC but not the other. the o/p are connected to two pins.

what am i doing wrong??

Comments

  • edited 2004-11-03 06:17
    /CS·stands for active-low "chip-select".· This is the pin that you should drive low to select one ADC0831 at a time.· Each /CS pin should be connected to it's own BASIC Stamp I/O pin.· Your program can then set the /CS pin low for the ADC you want to have report its voltage measurement.· The DO (data output) lines for both ADCs can be tied together and monitored by a single I/O pin.· The CLK pins can also be tied together and controlled by a single I/O pin.· This makes a total of four I/O pins, two for separate /CS pins, one for your DO bus, and one for the CLK bus.·

    At this point, I would first wire up one and test at a time and make sure that each works individually before attempting to operate them in concert again.

    Let's say that /CS for your first ADC0831 is connected to P4, /CS for your second ADC0831 is connected to P5, both CLK lines are bussed to P6, and both DO lines are bussed to P7.· Something like this (not tested) should work for reading the both ADCs:

    ' TestTwoAdcs.bs2
     
    '{$STAMP BS2}
    '{$PBASIC 2.5}
     
    ' ADC A /CS line connected to P4
    ' ADC B /CS line connected to P5
    ' CLK lines bussed to P6
    ' DO lines bussed to P7
     
    voltsA         VAR     Byte           ' ADC A measurement
    voltsB         VAR     Byte           ' ADC B measurement
     
    HIGH 4                                ' Tri-state ADC A
    HIGH 5                                ' Tri-state ADC B
     
    DO
     
      LOW 4                               ' Activate ADC A
      SHIFTIN 7, 6, MSBPOST, [noparse][[/noparse]voltsA\9]   ' Get 8-bit voltage
      HIGH 4                              ' Tri-state ADC A
     
      LOW 5                               ' Repeat for ADC B
    
      SHIFTIN 7, 6, MSBPOST, [noparse][[/noparse]voltsB\9]
      HIGH 5
     
      DEBUG HOME, CLREOL, ? voltsA,       ' Display values
                  CLREOL, ? voltsB
     
      PAUSE 250                           ' 1/4 s delay
     
    LOOP
    
    




    Post Edited (Andy Lindsay) : 11/3/2004 6:20:44 AM GMT
Sign In or Register to comment.