Shop OBEX P1 Docs P2 Docs Learn Events
TLC1543 ADC not getting data — Parallax Forums

TLC1543 ADC not getting data

dev/nulldev/null Posts: 381
edited 2009-07-18 19:09 in BASIC Stamp
Hi

I am trying to get an ADC to work (TLC1543). The signal is coming from a small preamplifier with a microphone on it. The problem is that I get only zero bits out. It's 10-bit so should be able to pick up the slightest of voltages.

Datasheet attached. I wired it like this:
preampadc.jpg

I am trying to use "mode 1" from the datasheet. Here is the code:
Init:
  addr = %0000 ' Select input A0

ReadADC:
  HIGH cs ' Start measure
  PAUSE 2
  LOW cs ' Activate TLC1543
  PAUSE 1
  SHIFTOUT dat, clk, MSBFIRST, [noparse][[/noparse]add] ' Send address
  SHIFTIN dat, clk, MSBPRE, [noparse][[/noparse]bits\10]
  DEBUG BIN10 bits,CR
  PAUSE 1000
  GOTO ReadADC





Thanks for any help.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't worry. Be happy

Comments

  • phil kennyphil kenny Posts: 233
    edited 2009-07-18 14:17
    Have you tried adding a short PAUSE between the SHIFTOUT and
    SHIFTIN commands?

    The ADC needs 21 usec to complete the conversion.

    phil
  • dev/nulldev/null Posts: 381
    edited 2009-07-18 19:09
    The ADC will send the result of the previous conversion while you it is converting the next one, so you don't have to do that.
    I found some code that worked for a 12-bit ADC, and it works for this one! The following code works for the 1543 (it's a miracle!):
    ADch VAR Nib ' selects AD external channel 0-10
    result VAR Word ' result, 12 bit A/D conversion
    
    demo: ' to show off the subroutine below.
    'DIRS=$FFFF ' makes all Stamp pins outputs to start
    'OUTS=$1000 ' makes all pins except ADC chip select low to start
    LOW ADcs
    DO
      GOSUB ADwake ' makes a dummy conversion to initialize converter
      FOR ADch =0 TO 10 ' specify one of 11 input channels
        GOSUB ADread ' get millivolt data from that channel
        result = 14464 ** result + result ' convert count to millivolts.
        DEBUG DEC ADch,": ",DEC result,REP 32\5,CR ' display, use extra spaces to clear garbage
      NEXT
      GOSUB ADsleep
      'NAP 1
      DEBUG HOME ' repeat the demo
    LOOP
    
    ADread: ' entry point to give result as count from 0 to 4095
     LOW ADcs ' select chip
     SHIFTOUT sdo,sclk,MSBFIRST,[noparse][[/noparse]ADch<<8\12] ' mode, left justify ADch
     SHIFTIN sdi,sclk,MSBPRE,[noparse][[/noparse]result\12] ' get result, 12 bits
     HIGH ADcs ' deselect chip
    RETURN
    
    ADsleep: ' entry point to put TLC2543 to sleep
     LOW ADcs ' select chip
     SHIFTOUT sdo,sclk,MSBFIRST,[noparse][[/noparse]$e\4] ' command=$e
     HIGH ADcs ' deselect chip
     LOW sdi ' keep this pin from floating in sleep
    RETURN
    
    ADwake:
     ADch=$b
     GOTO ADread
    
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
Sign In or Register to comment.