Shop OBEX P1 Docs P2 Docs Learn Events
LTC 1298 Giving Erratic Data-Please Help! — Parallax Forums

LTC 1298 Giving Erratic Data-Please Help!

MRM RCModelsMRM RCModels Posts: 5
edited 2007-10-10 02:50 in BASIC Stamp
I have a LTC 1298 hooked up per the instruction·with a BS2 homework board. I've also copied the code exactly from the data sheet. When I ran it a month ago everything was great, but now I'm getting erratic bit data (0-50 on channel·0 and 100-300 on channel 1). Would this amount of noise be normal? I thought it was the ADC so I changed it out with a new one. Still happends. Checked the code, still happens. If I hook up a sensor to it, I behaves like it's not even there. I've been trying to troubleshoot this for a week and I'm getting nowhere. Here's the code for reference.

' {$STAMP BS2}
' {$PBASIC 2.5}

CS CON 0 ' Chip select; 0 = active
CLK CON 1 ' Clock to ADC; out on rising, in on falling edge.
DIO_n CON 2 ' Data I/O pin _number_.

config VAR Nib ' Configuration bits for ADC.
AD VAR Word ' Variable to hold 12-bit AD result.
startB VAR config.BIT0 ' Start bit for comm with ADC.
sglDif VAR config.BIT2 ' Single-ended or differential mode.
oddSign VAR config.BIT2 ' Channel selection.
msbf VAR config.BIT3 ' Output 0s after data xfer complete.

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.
PAUSE 500 ' 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,MSBPOST,[noparse][[/noparse]AD\12] ' Get data bits.
HIGH CS ' Deactivate the ADC.
RETURN ' Return to program.
Sign In or Register to comment.