Interfacing SX with 12bit A/D LTC1298
Jim Fouch
Posts: 395
Being somewhat new to the SX and only having byte values·to work with, does someone have an example of interfacing to an LTC1298 A/D converter.
I don't really even need 12 bits of resolution. 8 would be ok.
I'm interfacing to a joystick w/ a 100K pot. I just need about 20 positions to control the speed of a stepper motor.
I've seen some examples of using a BS2. But that supports a WORD var. Not sure how I would work with the values when I'm limited to BYTE vars.
My guess would be something like whats shown in the SX/B help file.
· LOW CS
· SHIFTOUT Dio, Clk, LSBFIRST, config\4········ ' send config bits
· SHIFTIN· Dio, Clk, MSBPOST, resultHi\4······· ' get data (upper nibble)
· SHIFTIN· Dio, Clk, MSBPOST, resultLo\8······· ' get data (lower byte)
· HIGH CS
But how do I work with ResultHi & ResultLo and compair where a use may have the joystick. I need a center band that does nothing when not pusshed. Then as they move it right or left, I need about 10 bands to control speed.
I'm willing to throw the 4 least sig. bits away and live with the remaining 8.
I only ask this because I have an LTC1298 in hand and not much time to order a better fitting chip.
Thanks,
Jim Fouch
I don't really even need 12 bits of resolution. 8 would be ok.
I'm interfacing to a joystick w/ a 100K pot. I just need about 20 positions to control the speed of a stepper motor.
I've seen some examples of using a BS2. But that supports a WORD var. Not sure how I would work with the values when I'm limited to BYTE vars.
My guess would be something like whats shown in the SX/B help file.
· LOW CS
· SHIFTOUT Dio, Clk, LSBFIRST, config\4········ ' send config bits
· SHIFTIN· Dio, Clk, MSBPOST, resultHi\4······· ' get data (upper nibble)
· SHIFTIN· Dio, Clk, MSBPOST, resultLo\8······· ' get data (lower byte)
· HIGH CS
But how do I work with ResultHi & ResultLo and compair where a use may have the joystick. I need a center band that does nothing when not pusshed. Then as they move it right or left, I need about 10 bands to control speed.
I'm willing to throw the 4 least sig. bits away and live with the remaining 8.
I only ask this because I have an LTC1298 in hand and not much time to order a better fitting chip.
Thanks,
Jim Fouch
Comments
·LOW CS
· SHIFTOUT Dio, Clk, LSBFIRST, config\4········ ' send config bits
· SHIFTIN· Dio, Clk, MSBPOST, resultHi\8······· ' get data (upper nibble)
· SHIFTIN· Dio, Clk, MSBPOST, resultLo\4······· ' get data (lower byte)
· HIGH CS
And ignore resultLo?
This should basically turn my 12bit A/D into an 8-Bit one.
if you don't need 12 bit resolution, why do you consider using a separate ADC at all? The SX is fast enough to handle this conversion for you with just two external resistors and a capacitor plus the popular bitstream continouus calibration A/D converter Vitual Peripheral.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
There are 2 LTC varients requiring different code.· Can't help you with basic, took me long enough to get comfortable with assembly, and cannot bring myself to change now.· I have code for the single channel LTC in assembly.
Most ADC datasheets deny guarantees on the LSB.· So an extra bit can be handy, though in your case it does not seem to be needed.
The ADC 0831 is cheap and much easier to impliment.
Which ever way you go, buffer the signal with an op amp.· The data sheets I have read seem to all be a little shy on specific input impedences.· Your RC ADC could be suffering because of this.· The pot values you are using make an op amp advisable.
You can also use then op amp to modify the signal to something that easily translates into 8 bits.· ie, 0 to 2.55 volts range.· This in turn makes interperating the ADC's data a no brainer.
Hope this helps,· bongo
The bitstream method is not the same as RCTime. Bitstream gives more stable readings. Just make sure your voltage input impedance is not too high. I would try to keep it 5:1. That is, if you use 10K resistors for the bitstream cap, then use a 2K pot to provide the voltage. Or run the pot voltage through an op-amp to "stiffen" it.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
"One experiment is worth a thousand theories"
Post Edited (Bean (Hitt Consulting)) : 7/20/2005 1:44:53 PM GMT