LTC1298 A/D converter: shiftin 12 bits or 13 bits ?
pamajema
Posts: 5
Hello
Please why do we not shifin 12 bits like this in this example ?
We should shiftin 13 bits because the first bit after the clock is a null bit ?
Like using the A/D ADC0831 in fact ? I also check the Datasheet and even
when DO and DI are tied together with a resistor to·the I/O PIN, there is a nul bit first ???
And can someone explain why we read from 0 to 4095 while using 12 bits
and why we read from 0 to 8190 while using 13 bits ???
I took this example from there: http://www.parallaxinc.com/dl/docs/prod/appkit/ltc1298.pdf
(And in the .BS1 program,the FOR NEXT is from 1 to 13 ?)
Thanks a lot for your help
sincerely
jessica
Please why do we not shifin 12 bits like this in this example ?
We should shiftin 13 bits because the first bit after the clock is a null bit ?
Like using the A/D ADC0831 in fact ? I also check the Datasheet and even
when DO and DI are tied together with a resistor to·the I/O PIN, there is a nul bit first ???
And can someone explain why we read from 0 to 4095 while using 12 bits
and why we read from 0 to 8190 while using 13 bits ???
I took this example from there: http://www.parallaxinc.com/dl/docs/prod/appkit/ltc1298.pdf
(And in the .BS1 program,the FOR NEXT is from 1 to 13 ?)
Thanks a lot for your help
sincerely
jessica
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. [b]shiftin DIO_n,CLK,msbpost,[noparse][[/noparse]AD\12][/b] ' Get data bits. high CS ' Deactivate the ADC. return ' Return to program.
Comments
Mostly it relates to how the chip is built internally. The msbfirst, msbpost etc tells whether shifts occur on a rising or falling edge of the clock. This can make it necessary to send one extra clock pulse.
The most important thing is to do what the manufacturer says!
There are several very knowledgeable folks on the Forum who can probably add more chip-level details for you.
0 - 4095 or 0- 8190 is just basic binary counting, every additional binary digit effectively gives double the resolution. Just play with the Windows calculator to flip back and forth from a few binary numbers and decimal to see what I mean.
Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
thanks for your answer.
But when I check the datasheet of the LTC1298 A/D, it says that wether or not DIN is tied to DOUT the first bit is a null one
after the falling of the clock...
may be i am making a mistake reading this ?
I'm quite mistaken because I found the same routine in a french book all about basic stamp and it says
to shiftin 13 bits in the same configuration...
again thanks a lot
I use the ltc1298 in all my projects requiring a/d and find it works well, although I must admit I never stopped to worry about the 12-bit vs 13 bit issue.
The code I use is from the Parallax application note; here is the actual subroutine that does the work. You can see the only reference is to 4-bits of configuration and 12 bits of data.
Din and Dout are loosely tied together because they are never used together and it saves a stamp pin.
I guess I'm at a bit of a loss as to what the issue is. Sorry.
' ==========================================================
' ADC Subroutine
' ==========================================================
' Here's where the conversion occurs. The Stamp first sends the config
' bits to the 1298, then clocks in the conversion data. Note the use of
' the new BS2 instructions Shiftout and Shiftin. Their use is pretty
' straightforward here: Shiftout sends data bits to pin DIO and clock
' the CLK pin. Sending the least-significant bit first, it shifts out
' the four bits of the variable config. Then Shiftin changes DIO to
' input and clocks in the data bits--most-significant bit first, post
' clock (valid after clock pulse). It shifts in 12 bits to the
' variable AD.
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.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
Thanks for your answer !
I use the same routine and it works well too !
So I will stop too to worry about the 13bits vs 12bits issue [noparse]:)[/noparse]
After reading the datasheet 3 or 4 times (too many times I think [noparse];)[/noparse] ),
I think it's related to the fact that DIO and DIN are tied together...
Nevermind, it works well and that's the main point !
jessica
That's great. Wanting to know the background information is always a good thing even if you don't always get the specific answers you need.
Feel free to PM if you have other a/d questions.
Cheers,
Tom
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·