BS2<->AD7142 via SPI, 3.3V device issue
Piper984
Posts: 74
Hello Stampers,
I would like to intergrate an Analog Devices AD7142 into a BS2 circuit via SPI.· So far, no joy.· Could someone look over the following snip and let me know if it looks ok?
All I get back into iResult is 65535, so something isn't plusing correctly.· I also tried MSBPRE for the ShiftIn but again no luck.
The white paper for the AD7142 can be found·@ http://www.analog.com/AD7142
I'd like to verify that my code is·correct or not·before I contact AD.· My expereince with SPI is pretty much limited to 5V 12bit A/D ICs.· The AD7142 is a 3.3V IC. Does this matter ??
Regards!
I would like to intergrate an Analog Devices AD7142 into a BS2 circuit via SPI.· So far, no joy.· Could someone look over the following snip and let me know if it looks ok?
' {$STAMP BS2} ' {$PBASIC 2.5} sclk CON 0 sdo CON 1 sdi CON 2 cs CON 3 HIGH CS ' init chip PAUSE 500 iResult VAR Word iMessage VAR Word iMessage = %1110010000001000 DO GOSUB ADread DEBUG DEC iResult,CR PAUSE 500 LOOP ADread: LOW cs ' select chip SHIFTOUT sdo,sclk,MSBFIRST,[noparse][[/noparse]iMessage\16] ' SHIFTIN sdi,sclk,MSBPOST,[noparse][[/noparse]iResult\16] ' HIGH cs ' deselect chip RETURN
All I get back into iResult is 65535, so something isn't plusing correctly.· I also tried MSBPRE for the ShiftIn but again no luck.
The white paper for the AD7142 can be found·@ http://www.analog.com/AD7142
I'd like to verify that my code is·correct or not·before I contact AD.· My expereince with SPI is pretty much limited to 5V 12bit A/D ICs.· The AD7142 is a 3.3V IC. Does this matter ??
Regards!
Comments
I don't see anything wrong with your ADread routine. I'd go for the MSBPRE in the SHIFTIN, because it says the MSB becomes available immediately after the command word. But you tried that and it didn't help. I wonder why you chose the command word, iMessage = %1110010000001000? According to the description, that is the "CDC Low Limit Status Register Map", in which individual bits flag whether or not the low limit for each capacitance channel has been exceeded. The actual data registers are in bank 3, and those are only functional after the configuration registers in bank 2 have been set up. The thing is hideously complicated! My guess is that it needs to be set up more carefully first, and then you can read some usefull data.
Also check the usual, that the sense of sdo and sdi are not mixed up. Also, I see that Analog Devices has or plans a version of this chip with an I2C interface. Maybe they sent you one of those?
For the interface to 3.3 volts, be sure and put a 10kohm resistor in series between the pins on each chip. That should allow enough protection.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Thanks for the reply. I have 8 samples, and 2 development boards for this IC (one board for the SPI version, the other for the I2C version). I received mine from the first batch released.
These rascals are very complex, but they are exactly what I need for a particular project, and so I am very eager to get the SPI working. I have not tried the I2C yet.
Lucky for me, the eval boards come with some very nice configuration/diagnostics software that interfaces via the eval boards USB port, so I can 'see' the data I am wanting to collect. The eval board has a setting that allows the onboard controller to be disabled and so then the AD7142 can be interfaced with an external controller. This is the stage I'm at now.
I'll post back any learning I get from AD for future Stampers.
Regards!
Chris
Did you look at products from www.qprox.com for your application?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Regarding QProx: Yup, my first two prototypes used devices from Qprox, but most of their products are for simply sensing touch/no touch. With AD7142 ICs, you have access to ALOT more data, and for what I'm doing, the AD7142 seems to be a perfect fit. Now if I can only get SPI to work! I left the I2C eval board @ my office over the weekend, or I would have tried it already. Also, the cost of the AD7142 is much less than the QT113s I was using.
Will post when BS2<->AD4172 is successful.
Regards,
Chris
Not sure if this is something I need to look at or not: But the whitepaper for the AD7142 says the min 'fSCLK' is 10kHz and the max is 10mHz.·Is this a problem for my 20mHz BS2?· I sent a message to AD but haven't heard back yet.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I used simple voltage divider circuits on the CS, CLK, and SDI pins (VIN*(R2/(R1+R2))) to drop from 5.0 to 3.3, and then direct connection from the SDO line of the AD7142 to the BS2. The 2.3V is seen as high by BS2.
Yeah!!
Not having perused the data sheet, just a quick scan, I'm still wondering how much configuration you have to do to make a standalone Stamp program, where the Stamp does the configurating. Please do post your progress on this.
For anyone interested, here is a short tutorial on capacitance sensing using sigma delta technique...
www.elecdesign.com/Articles/Index.cfm?ArticleID=10185&pg=1. It is possible to make very effective capacitance sensors using sigma delta with an SX chip (or Propeller would be very good for this too), That requires external analog switches for each channel.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Yes, it seems to only have been a voltage issue.· One additional learning I've had is to place a 4k7 resistor on the AD7142's SDO pin.· I was getting some weird error in the LSB side of the 16bit words coming back, and this cleaned it up.· Again, thresholding issue.
Now, as for initializing this IC: My current approach is to store 424 bytes of data (212 16bit words that =·106 16bit registers and·106 16bit values) in DATA statements and then loop through them:
Where iMessage is the Resister and iCode is the value to write.· The +57344 is·just the command·bits·and write bit in the 10-16 position of the word.
So far, it's working great... Although I do have a weird BOE·issue.. I am·streaming data out of·a BOE's RS232 port·via the debug command, and then I wrote a little data acquision application in VB so I can graph/record data coming off the BS2·for testing.··Weirdly, when·my VB app connects to COM1, the BS2 resets.· Which·in my case is a pain·in the ars·since·the initialization process·is lengthy and has it's own serial stream·syntax.· Is that·normal??·I should probably post a new thread·about that.
Anyway, I plan on having a PCB·made·w/·an AD7142·and 40 pin socket for BS2P40 for next phase of my testing.· I'll post any learnings to this thread.
Regards!!