Shop OBEX P1 Docs P2 Docs Learn Events
LTC 1298 ADC - outputs are unstable — Parallax Forums

LTC 1298 ADC - outputs are unstable

blippincottblippincott Posts: 4
edited 2007-11-15 15:51 in Robotics
I built a daughter board for a 1298 ADC, and all the hardware checks out. I have typed in the sample demo code for the chip, and it is interfaced to my BS2e on board my "FauxBoe". I can get steady readings with a voltage divider (10K pot) as long as I don't touch the pot. The Sharp sensors (GP2Y) I have on board are showing very jittery unstable outputs. Does anyone have a previous experience like this? Is there an improvement to the coding that can be made? Perhaps a different capacitor? My code does include an output to an LCD, i have tried it with debug only and it had no effect. Here is my code:

' ADC_Demo_FauxBoe.bse
' This program demonstrates the LTC1298 by alternately sampling the two
' input channels and presenting the results on the PC screen using Debug.
' {$STAMP BS2e}
' {$PBASIC 2.5}
' {$PORT COM1}

CS CON 10 'chip select; 0 = active, port 10
CLK CON 11 'clock to ADC; out on rising, in on falling edge, port 11
DIO_n CON 12 'data I/O pin number, port 12
config VAR Nib 'confifuration bits for ADC
AD VAR Word 'variable to hold AD result

startB VAR config.BIT0 'start bit for comm with ADC
sglDif VAR config.BIT1 'single-ended or differential mode
oddsign VAR config.BIT2 'channel selection
msbf VAR config.BIT3 'output 0's after data transfer complete
N9600 CON $4054 'baudemode 9600 bps inverted.
I CON 254 'instruction prefix value.
CLR CON 1 'LCD clear screen instruction.
L1_C2 CON 133
L2_C2 CON 197

SEROUT 8, N9600, [noparse][[/noparse]I, CLR] 'clear LCD screen
PAUSE 2000
SEROUT 8, N9600, [noparse][[/noparse]"Chan "] 'header print

HIGH CS ' Deactivate ADC to begin.
HIGH DIO_n ' Set data pin for first start bit.
again: ' Main loop.
FOR oddSign = 0 TO 1 ' Toggle between input channels.
GOSUB convert ' Get data from ADC.
DEBUG "channel ",DEC oddSign, ": ", DEC AD, CR ' Display data.
IF (oddsign = 0) THEN
SEROUT 8, N9600, [noparse][[/noparse]I, L1_C2, DEC oddsign, ": ", DEC AD] 'display data on LCD
ELSEIF (oddsign = 1) THEN
SEROUT 8, N9600, [noparse][[/noparse]I, L2_C2, DEC oddsign, ": ", DEC AD] 'display data on LCD
ENDIF
PAUSE 20 ' Wait a half second.
NEXT ' Change channels.
GOTO again ' Endless loop.

convert:
config = config | %1011 'set all bits except oddsign
LOW CS 'activate the ADC
SHIFTOUT DIO_n, CLK, LSBFIRST, [noparse][[/noparse]config\4] 'send config bits
SHIFTIN DIO_n, CLK, MSBFIRST, [noparse][[/noparse]AD\12] 'get data bits
HIGH CS 'deactivate the ADC
RETURN 'return to program

Thanks.
Brian

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I know just enough about electronics to be a
danger to myself and others."

Comments

  • FranklinFranklin Posts: 4,747
    edited 2007-11-15 05:26
    Take more than one reading and average them out, this will help but each reading will be different that is just the way digital readings are. What is the span of your readings anf could youy supply a wiring diagram?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • blippincottblippincott Posts: 4
    edited 2007-11-15 15:51
    Out of a 12-bit resolution, at 5VDC, the Sharp sensor covers a range of 196 to 3708, listing only about 3 different reading values in between the ones mentioned. The pot sits steadily at 2848 @ current setting. I considered adding an averaging subroutine to stabilize the usable reading. Not sure how to write it as yet, perhaps an array of 8 or 10 readings?
    The schematic is the same as the one on the first page of the LTC1298 manual I got online at Parallax.
    Brian

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I know just enough about electronics to be a
    danger to myself and others."
Sign In or Register to comment.