Shop OBEX P1 Docs P2 Docs Learn Events
Sensirion SPD610 pressure transducer. I2C comms — Parallax Forums

Sensirion SPD610 pressure transducer. I2C comms

DurbanFlyBoyDurbanFlyBoy Posts: 7
edited 2013-10-08 00:58 in Propeller 1
I am quickly going mad here trying to get data out of this device. I have tried several of the I2C objects available, can get the device to respond, but I cant get data out of it into a variable. I think the problem is the handshake, where the Command is sent to the slave sensor, and there is a processing time before it responds. During this time the SCL line is pulled down by the slave which should hold the execution of clock pulses to clock out the data. Anyone with experience with this device?

Comments

  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-09-27 09:47
    The driver needs to support "clock stretching", also called "clock hold". The SPD610 calls it "hold master". There has to be a pullup on the scl line. The driver will say that it requires pullups on both sda and scl.

    Have you tried jm_i2c.spin? It supports clock stretching, by means of a hold condition if scl remains low after a Stop condition. However, some devices (evidently the SPD610 is one, also the SHT25 RH/T) do not have a Stop associated with the stretching. The stretching occurs after the ACK for the device address, no Stop at that point, and continues until the device releases scl. At that point the Prop has to issue a repeated start and then read 2 bytes of data, NAK and finally Stop.
  • photomankcphotomankc Posts: 943
    edited 2013-09-27 10:58
    You might PM me. I had somewhere in my junk drawer a modified driver that would handle clock stretching from a slave device. I'll see if I can dig it up if you are interested. It's a SPIN/PASM deal but I never totally finished it well enough to publish it.
  • ChrisGaddChrisGadd Posts: 310
    edited 2013-09-27 16:34
    Either the SPIN or PASM I2C driver in my sig might work, though the only clock-stretching device I tested them with was a CY85C9520A 20-port I/O expander that stretched the clock between the byte and the ack/nak.

    Might not be an issue with your SPD610, but my CY85C9520A stretched the clock regardless of which device was being addressed, which created big problems when trying it on P28&29. The Prop bootloader does not support clock stretching, actually driving SCL high and low, so a slave holding the SCL low prevents the Prop from booting from EEPROM.
  • DurbanFlyBoyDurbanFlyBoy Posts: 7
    edited 2013-09-27 22:47
    Thanks Tracy, will revisit this object. I am ptetty good at hardware so will probably write a custom object and post it to OBEX when it works.
  • davekorpidavekorpi Posts: 20
    edited 2013-09-30 19:16
    OMG!

    I am working on the EXACT SAME Thing with LabVIEW and having a PISSER HARD time because their docs are not very clear...
    All I want to get out of the thing is the raw ticks 0 - 65535 for -50 Pa to + 500 Pa...

    I have a LabVIEW link you can see but it will not be much help because I do not even know the correct command.. F1 or F3 should work...

    If the link is broken click here..

    http://forums.ni.com/t5/LabVIEW/Sensirion-EKP-3-Code-to-read-the-raw-ticks-from-the-SDP6xx/td-p/2515498

    <<<<There are 3 pages to that crazy thing!!!>>>>>>

    I am just setting up with the Propeller Demo Board to see what I can get going...

    Anyone have the secret trick to get this thing to work?

    I have included C-Code and LabVIEW info and spec sheets so yall can see what this thing is all about.

    Happy to work on SKYPE or TeamViewer with someone and can return in like kind with LabVIEW..

    I am about 4 mm away from getting it to work with the IOWarrior I2C to USB with LabVIEW but really want to do the Propeller thing.. In the end I want 4-20 mA and 0 - 5 VDC out with 2 DACS and do some scaling...

    I think someone who is good at Spin-to-C code could do this lickety split!

    Are we allowed to put in our emails or pay folks for help in this forum??

    Here is a video I made showing how close I have it in LabVIEW.. http://www.screencast.com/t/LDHeNlaStZ2w

    Thanks!

    Dave
  • davekorpidavekorpi Posts: 20
    edited 2013-10-04 17:14
    Hi Propeller Wizards!!

    Anyone got this thing to work? I am looking to get it to work too!

    I can not get the crazy thing to talk to me! If anyone has a nice Spin code I would LOVE it! I am doing work on a LabVIEW version of this but it uses a USB to I2C converter, which is pretty cool! I want to use the Propeller though!

    I thought I posted to this but perhaps I did not save it!
    I am quickly going mad here trying to get data out of this device. I have tried several of the I2C objects available, can get the device to respond, but I cant get data out of it into a variable. I think the problem is the handshake, where the Command is sent to the slave sensor, and there is a processing time before it responds. During this time the SCL line is pulled down by the slave which should hold the execution of clock pulses to clock out the data. Anyone with experience with this device?
  • davekorpidavekorpi Posts: 20
    edited 2013-10-06 10:48
    I have attached a file that has all the specifications of the chip!

    I am not sure we need Clock Stretching... but I am just not sure. I just think we need someone REALLY SMART who can figure it out! I am betting it is easy for someone who can cipher the Spec Sheets I put in the attachment.

    I can not believe Sensirion would make an I2C protocol that would be hard to use... but I could be wrong!

    In any case I have seen this thing work with their program (link in document) and that thing is probably one of the best DP sensors I have EVER used...

    Anyone up to write an object for this crazy one???
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-10-06 15:39
    Hi Dave, and FlyBoy,

    Give this a try and let me know how it works out. It is fine with the Sensirion SHT2x sensors, which appear to have exactly the same clock stretching protocol. You will see there is a command "TRIGGER" in the SPD610 data sheet and also in the attached object.
    [SIZE=1][FONT=courier new]PUB readRawPressureHold
      result := i2c.ReadNumber(DEV_ID, TRIGGER, -2)[/FONT][/SIZE]
    

    The SPD610 documentation is quite clear about the clock hold, as seen in the timing diagram at the right end of the top line...
    Screen shot 2013-10-06 at 3.24.23 PM.png

    In the attached i2c object, the clock hold comes at the top of the elemental Read routine, after the ACK and after scl has gone low again to start the conversion, and then released to be pulled high. But scl does not go high until the slave releases it at end of conversion. Once scl does go high, the above method, i2c.ReadNumber(...), continues on to read the result.
  • davekorpidavekorpi Posts: 20
    edited 2013-10-06 20:23
    Tracy:

    Wowiee! Thanks a million! I will give it a try ASAP and let you know!

    I am kind of a newbie to this processor but am very excited to do some cool stuff with it.
    I was introduced to it by Mike Lord who is a wizard at this stuff too!
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-10-06 21:02
    I'm very interested to hear how that sensor works out. The operating principle, using thermal mass flow, seems to lead to remarkable performance at low pressure differentials.
  • davekorpidavekorpi Posts: 20
    edited 2013-10-06 21:17
    Tracy:

    I have one of these SDP610 goodies and I do not want to blow it up by golly! So.. I wonder if you are up for giving a bit more info for a newbie!

    I am using the Demo Board here.. http://parallax.com/product/32100 and I will hook it up to the SDP610 and I wonder if you think I should use 10K pullup resistors (nominal or a value range for this 3.3 VDC board, VDD) for the lines SDA and SDL and if not 10K what values you think I should use when I hook up to the 3.3 VDC power.

    Sorry for asking ninny questions but I just want to make sure and get info from a wizard...
  • davekorpidavekorpi Posts: 20
    edited 2013-10-06 21:19
    Tracy:

    I WILL let you know! The concern I have is the gas has to be SUPER DUPER clean or it will plug the channels.. That is my worry on this thing! Seems we would have to put a frit in series to keep it clean!

    Thanks a million! Will be hooking things up tomorrow AM! You can call anytime if you want! Let me know how to get my number to you in a way that does not mess with the forum rules.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-10-06 21:36
    Definitely, use 10kΩ pullup resistors from the sda and scl pins to +3.3V. I was testing it on a demo board myself, with an SHT21 standing in for the SPD610. The demo program uses pin p6 for scl and p7 for sda. Sorry, it is a rigid hack of a program. Also, no math to convert from raw to pressure units, but that should be easy once you have the readings.

    As an aside, I was discussing this sensor with a prof at Berkeley last week, thinking about how it might be turned into an environmental anemometer. The contamination issue is huge there, too, of course.
  • davekorpidavekorpi Posts: 20
    edited 2013-10-06 21:47
    Ttracy:

    Thanks again! 10K it is! Indeed, that is a cool sensor but certainly needs to be kept clean!

    What Prof? I went to that crazy school by golly, Loved it.. Lived on North Side.. at Cloyne Court on Ridge above Etcheverry Hall (there is a research nuclear reactor under that building)!!

    I will see how I come along with the math.. Being a newbie I see there are lots of wrangling needed to do the floating point stuff I take for granted with LabVIEW...

    Your demo program is profoundly clear and clean and allows me to isolate the variable of concern so I am VERY HAPPY with it.

    One day I want to see how to solve a fifth order polynomial with Spin... Something like this, where I have the Coefficients A, B, C, D, E and F for a fifth order and want to find y for a given value of x:

    y = -3.467E+0 + 150.429E+4x - 136.520E-3x^2 + 247.626E+0x^3 - 71.985E+0x^4 + 7.264E+0x^5

    I have searched the OBEX and have not found anything like that yet.. Seems there are LOTS of FP Objects but I must say a polynomial would be an EXCELLENT one for folks to deal with nasty transfer functions and drive those oh so common non-linear systems!
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-10-07 08:02
    We may have been neighbors! For a while lived at the corner of Euclid and LeConte, just down the street frome Cloyne Court. The 1MW nuclear reactor is long gone from under the parking lot east of Echeverry Hall. That space is now occupied by Soda Hall, computer science mainly. I spent many many wee hours as a grad student in the basement of Echeverry in front of a PDP7 computer, with its switches to bootload the paper tape, to bootload the magnetic tape, to bootload an interactive program that used 4th order Runge-Kutta to solve systems of ODEs. That was the epoch of interest in how deterministic systems could exhibit chaotic behavior. I was working with Prof. Dave Auslander on periodic forcing of models that come out of population dynamics.

    The prof I'm talking with currently about the pressure sensor is Steve Glaser, across the street in another new building, Sutarja Dai Hall, which houses CITRIS (Center for Information Technology Research in the Interest of Society). Everything is acronyms! His group has wireless nodes strung out over a wide area along the American River and by Shaver lake, to take a long-term look at fluctuations and changes in the climate. Thus the wind speed question. Always looking for new approaches.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-10-07 08:48
    @Chris Gadd,

    I'm looking at your object for the CY85C9520A, with its odd clock stretching, and your pasm driver. I can't locate a data sheet for that part, do you have a link? I have two parts here that clock stretch, the sht21 (although it also supports polling), and the MAX1236--MAX1239 ADCs.
  • davekorpidavekorpi Posts: 20
    edited 2013-10-07 11:33
    I got it working! All SWEET! Thank you soooo much!

    I can not tell you how appreciative I am. It is AMAZING that you will help folks out like you do! Thanks again!

    I will send the code for the others with some trapping code to drop that 65,535 reading.. The numbers I am interested in are 0 - 32,767 (or what ever it goes to.. seems 32,700)

    THEN.. I want to FILTER it.. with a nice FIR filter or exponential filter and then SCALE it and then NORMALIZE it with a polynomial and THEN Drive a few DAC's (0-4 VDC and 4-20 mA)

    Then.. have it start my car!

    I had Auslander too. I was a TA for a few profs there under Etcheverry Hall and we got to see that cool purple glow in the reactor.. I was the nutcase who did the elliptical bicycle gear with the analog computer hooked to motors on a Bridgeport lathe to mill out an ellipse with the chain teeth "FM"ed" on top of it. Waaaay before folks did it they way they do it now. I put it on my StingRay and it was easier to pedal uphill but it was waaaaaay too much of an ellipse to be comfortable... THEN... someone stole my bike.. THEN.. I switched to a unicycle and NOBODY ever stole that one.. Not enough tires I guess! I think I graduated in1987 or so? Can not even remember!

    On the anemometer.. I have a black belt in those... I sold my part of http://www.sierrainstruments.com/ many moons ago and now I am working with http://www.sagemetering.com/ and we have some CHERRY CHERRY thermal anemometers that would work great for CITRIS for prof Glaser!

    Anyway.. Thanks a million and feel free to delete these silly messages so folks do not have to read them Next one will have my code with a "How To" use it for the guys...
  • ChrisGaddChrisGadd Posts: 310
    edited 2013-10-07 13:05
    @Chris Gadd,

    I'm looking at your object for the CY85C9520A, with its odd clock stretching, and your pasm driver. I can't locate a data sheet for that part, do you have a link? I have two parts here that clock stretch, the sht21 (although it also supports polling), and the MAX1236--MAX1239 ADCs.
    Ah yes, also known as the CY8C9520A, hate when that happens.

    Attaching an image showing the clock-stretching at work. Addressing the device at $21, then writing $40 to register $08, which iirc sets pin 6 of port 0 high.
    CY8C9520A.jpg
    1024 x 237 - 41K
  • davekorpidavekorpi Posts: 20
    edited 2013-10-07 19:52
    Oct 7, 2013

    Here is how to use the Sensirion SDP-601 with the Propeller Chip. I included the files as well.
    Thanks to Tracy for giving clarity!

    An overview video...
    http://www.screencast.com/t/faqyE1ZDOk5U
    A link to a DropBox account that should work...
    https://www.dropbox.com/s/8rg6vtwk018v482/SDP601VideoDMK.mp4.zip

    If the video is gone or does not work then just PM me and I will send you the file... SDP601VideoDMK.mp4

    If anyone is up to sharing a cherry digital Filter.. to make it look like I put a 0.047 cap across the thing and then do scaling and a fifth order transfer function I would LOVE it for sure!

    Will need FP math and have to let one cog do the display, one to drive two DAC's and one to monitor the i2C and then another one to deal with the comms...

    Thanks a million!

    Dave Korpi
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-10-08 00:35
    Hi Dave,

    I'm very pleased that is working, nice video to show your progress. That is whole different level from the labview presentation!

    The data sheet is sketchy isn't it? In one chart it says the resolution is 12bit, adjustable 9 to 16. I wondered what they mean by that. The scale factor for the +/- 500 Pa sensors is supposed to be 60 counts per Pa, I think. So for a full range of 1000 Pa that would have to be 60000 counts with the bias in the middle as you found. At their calibration point, anyway, 966 mbar, 425 meters altitude. Must be calibrated in Switzerland!

    It's easy to implement an exponential filter on the Prop. There have been deep threads here on the forum regarding filtering strategies and algorithms. I'm don't see where this needs the 5th order polynomial to describe the transfer function. That must be something to do with your mass transfer, huh? The work function for your unicycle?
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-10-08 00:58
    Chris, thanks for the link to the CY8C9520A. Wow, that's some chip, more like a dedicated µP.

    I2C: Manufacturers keep us guessing and on our toes with their tricky variations on the theme.
Sign In or Register to comment.