Shop OBEX P1 Docs P2 Docs Learn Events
BS2<->AD7142 via SPI, 3.3V device issue — Parallax Forums

BS2<->AD7142 via SPI, 3.3V device issue

Piper984Piper984 Posts: 74
edited 2006-06-16 01:57 in BASIC Stamp
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?

' {$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

  • Tracy AllenTracy Allen Posts: 6,658
    edited 2006-06-04 02:00
    Interesting chip. I've seen announcements in trade journals, but their web site still says "not yet released to manufacturing", so I guess you talked them out of a sample and are a beta tester!

    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
  • Piper984Piper984 Posts: 74
    edited 2006-06-04 12:18
    Hi Tracy,

    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
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2006-06-04 17:38
    Ahhh. The development board should make it easy (famous last words). Does the PC interface take care of the configuration, or, doe this chip store its configuration settings in eeprom? I'm just noting that you BS2 program does not do any configuration of the rascal. Please do post results.

    Did you look at products from www.qprox.com for your application?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Piper984Piper984 Posts: 74
    edited 2006-06-04 22:51
    From what I've seen so far, the PC software let you change settings, but they aren't stored on the chip on reset... So the MCU will need to send all of the configuration changes on startup.

    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
  • Piper984Piper984 Posts: 74
    edited 2006-06-05 20:52
    Hi Tracy, et all,

    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.

    ·
  • Piper984Piper984 Posts: 74
    edited 2006-06-07 19:27
    Ok, still working on the AD7142... I have narrowed it down, I think, to the fact that the Input High Voltage of the 3.3v device is like 2.3V, and I believe the BS2 requires +2.5V to trigger 1 on a pin. Is this correct?? Is there some type of digital buffer that I could use to cleanly scale up the voltate of data coming SDO from the AD7142 and shifting into the BS2? Hope that makes sense.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-07 21:44
    The BS2 accepts anything above 1.4V as a high and anything below 1.4V as a low, so your 2.3V should easily be seen as a high.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Piper984Piper984 Posts: 74
    edited 2006-06-07 23:57
    Success!

    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!!
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2006-06-09 17:07
    Great that it works! So it was simply a matter of the higher 5 volts overdriving the 3.3 volt inputs?

    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
  • Piper984Piper984 Posts: 74
    edited 2006-06-16 01:57
    Hi Tracy,
    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:
    FOR i = 0 TO 424 STEP 4
      
      READ i,   iMessage.LOWBYTE
      READ i+1, iMessage.HIGHBYTE
      READ i+2, iCode.LOWBYTE
      READ i+3, iCode.HIGHBYTE
      iMessage = 57344 + iMessage 'Write
      GOSUB ADwrite
      DEBUG "W:",IBIN16 iMessage, " ", IBIN16 iCode, " initialized",CR
    
    NEXT
    

    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!!
Sign In or Register to comment.