I would like to connect two LTC1298's to a STAMP 2
I need some help!
I would like to connect two LTC1298's to a STAMP 2.
How can I use the code below in such a way as to sequentially monitor two ADCs in order to watch four voltages??
****************************************************************************************
"LTC1298 & BS2
CS con 0
CLK con 1
DIO_n con 2
config var nib
AD var word
startB var config.bit0
sglDif var config.bit1
oddSign var config.bit2
msbf var config.bit3
high CS
high DIO_n
again:
for oddSign = 0 to 1
gosub convert
debug "channel ",DEC oddSign, ": ",DEC AD,cr
pause 500
next
goto again
'
convert:
config = config | %1011
low CS
shiftout DIO_n,CLK,lsbfirst,[noparse][[/noparse]config\4]
shiftin DIO_n,CLK,msbpost,[noparse][[/noparse]AD\12]
high CS
return
Post Edited By Moderator (Chris Savage (Parallax)) : 5/20/2007 5:15:17 PM GMT
I would like to connect two LTC1298's to a STAMP 2.
How can I use the code below in such a way as to sequentially monitor two ADCs in order to watch four voltages??
****************************************************************************************
"LTC1298 & BS2
CS con 0
CLK con 1
DIO_n con 2
config var nib
AD var word
startB var config.bit0
sglDif var config.bit1
oddSign var config.bit2
msbf var config.bit3
high CS
high DIO_n
again:
for oddSign = 0 to 1
gosub convert
debug "channel ",DEC oddSign, ": ",DEC AD,cr
pause 500
next
goto again
'
convert:
config = config | %1011
low CS
shiftout DIO_n,CLK,lsbfirst,[noparse][[/noparse]config\4]
shiftin DIO_n,CLK,msbpost,[noparse][[/noparse]AD\12]
high CS
return
Post Edited By Moderator (Chris Savage (Parallax)) : 5/20/2007 5:15:17 PM GMT

Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Ok, so then I would have to add three more lines to the BS2, for the extra LTC1298
Is the assumption below correct to add second CS2,CL2,DIO_n2 ?????
CS1 con 0
CL1 con 1
DIO_n1 con 2 '1st LTC 1298
CS2 con 3 '2nd LTC1298
CLK2 con 4
DIO_n2 con 5
Ok, so then do I have to duplicate a section of the code to read the additional LTC1298???
How is this best done?
CS1 con 0
CS2 con 1
CLK con 2
DIO con 3
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
' {$STAMP BS2} ' {$PBASIC 2.5} ' LTC1298 & BS2 cs0 CON 0 cs1 CON 1 '<-- two chip selects clk CON 2 dio CON 3 ad VAR Word cs VAR bit <-- cs is a variable config VAR Nib startB VAR config.Bit0 sglDif VAR config.Bit1 oddSign VAR config.Bit2 '<-- ad channel 0 or 1 msbf VAR config.Bit3 HIGH cs0 HIGH cs1 HIGH dio DO FOR cs=0 to 1 <-- outside selects which LTC1298 FOR oddSign = 0 TO 1 <-- inside selects channel GOSUB convert DEBUG "channel ",BIN1 cs, ".", BIN1 oddSign, ": ",DEC ad,cr PAUSE 500 NEXT NEXT LOOP ' convert: config = config | %1011 LOW cs SHIFTOUT dio, clk, LSBFIRST, [noparse][[/noparse]config\4] SHIFTIN dio, clk, MSBPOST, [noparse][[/noparse]AD\12] HIGH cs RETURN▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Thanks for the code on selecting two LTC1298's.
It appears to work, I was a bit consfused as to how the channels were displayed at first!
A few questions
in the original debug line:
debug "channel ", DEC, oddsign,":",DEC AD,cr
new debug line:
debug "channel ",BIN1 cs, ".", BIN1 oddsign, ": ",DEC ad,cr
Why are these two lines so different?
Help me understand why the difference.
I would like to add a conversion to millivolts such as :
AC Var word
AC = (AD*10)**14464+(AD*10) + 5/10
would I add this after the Gosub convert?
Would this work.
Thanks
Tom
There are now two variables, cs and oddsign, that need to be displayed to indicate the origin of the signal. Maybe you would rather display 0, 1, 2, 3 for the channel, instead of 0.0, 0.1, 1.0 and 1.1? Then you would use,
DEBUG "channel ",DEC1 cs<<1+oddsign, ": ",DEC ad,cr
That combines the two bits into one single channel number.
You could insert the conversion formula either as you say, right after the gosub convert, or put in inside the convert routine, just before the RETURN.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Thanks for all your help with the LTC1298 info and code
A great help in understanding how things work
tom