Shop OBEX P1 Docs P2 Docs Learn Events
Trouble with ADC0831 — Parallax Forums

Trouble with ADC0831

Derek BrownDerek Brown Posts: 1
edited 2009-06-18 03:47 in BASIC Stamp
Hey,

I'm trying to use an ADC0831CCN with my BS2 and a TSL257T but I'm getting nothing but all 00000000 when I run my program. I've never worked with these before and I am using the example program from the A/D book. I'm pretty sure that wired everything up right but I just cannot get any kind of reading from it. I even tried setting upa test circuit with a 10k pot and still no dice. I replaced the chip since I bought two and still nothing. Any ideas on what I may be doing wrong?
confused.gif

Here is that program.

'
[noparse][[/noparse] Title ]
' Basic Analog and Digital - PL3_1R0.bs2
' Program Listing 3.1 Revision 0.
' {$STAMP BS2}
' {$PBASIC 2.5}

'
[noparse][[/noparse] Declarations ]
adcBits VAR Word
v VAR Byte
r VAR Byte
v2 VAR Byte
v3 VAR Byte

'
[noparse][[/noparse] Initialization ]
CS PIN 0
CLK PIN 1
DataOutput PIN 2

DEBUG CLS 'Start display.

'
[noparse][[/noparse] Main Routine ]
DO
GOSUB ADC_Data
GOSUB Calc_Volts
GOSUB Display
LOOP

'
[noparse][[/noparse] Subroutines ]
ADC_Data:
LOW CLK
LOW CS
PULSOUT CLK, 210
SHIFTIN DataOutput,CLK,MSBPOST,[noparse][[/noparse]adcBits]
HIGH CS
RETURN

Calc_Volts:
RETURN

Display:
DEBUG HOME
DEBUG "8-bit binary value: ", BIN8 adcBits
RETURN


NOTE: ADC pin arrangement

1) P0
2) input from pot/TSL
3) Vss
4) Vss
5) Vdd
6) P2
7) P1
8) Vdd


Thanks,

Derek

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-06-18 03:47
    Start by running the example code that reads the pin the ADC is attached to then take a wire with a 330 ohm resistor in series and touch it between the pin and ground, then the pin and 5v. You should get 0 and 1023. If not go back and check your connections, follow the drawings in the documentation.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
Sign In or Register to comment.