Shop OBEX P1 Docs P2 Docs Learn Events
AD 1298 converter incorrect debug values. — Parallax Forums

AD 1298 converter incorrect debug values.

autotechautotech Posts: 4
edited 2006-04-15 05:48 in BASIC Stamp
I·am currently using the basic stamp 2 home work board rev b. I have setup the 12 bit a/d converter LTC1298.I am running the demo program(appkit). I have seen at times the read out in Debug values are getting stuck with values greater than 4095.also at times when I turn the pot the value does not return to 0.note i am currently use a 10k pot and the 10uf tantalum cap. I have checked the voltage at the 1298 vcc to·ground = 4.99.. and ch1 = 4488 debug value ;should be 0 .voltage drop from vcc to ch1 is 4.99.help please.
note chan 2 does the same thing at times.
' {$STAMP BS2}
' {$PBASIC 2.5}
' ==========================================================
' ADC Interface Pins
' ==========================================================
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.

·' ==========================================================
' ADC Setup Bits
' ==========================================================

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 0s after data xfer complete.
' ==========================================================
' Demo Program
' ==========================================================
' This program demonstrates the LTC1298 by alternately sampling the two
' input channels and presenting the results on the PC screen using Debug.
HIGH CS ' Deactivate ADC to begin.
HIGH DIO_n ' Set data pin for first start bit.
again: ' Main loop.
DEBUG HOME
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.
' ==========================================================
' ADC Subroutine
' ==========================================================
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.

·

Comments

  • autotechautotech Posts: 4
    edited 2006-04-15 05:48
    Found the problem by adding a debug line showing 12 bit bin data.
    DEBUG CR,"12-bit binary value:· ", BIN12 AD,CR·
    problem fix changed debug line to dec4.
    DEBUG "channel ",DEC oddSign, ": ",DEC4 AD,CR ' Display data.

    has any one else had this problem.
Sign In or Register to comment.