Shop OBEX P1 Docs P2 Docs Learn Events
sensirion returning starnge value — Parallax Forums

sensirion returning starnge value

avionikerenavionikeren Posts: 64
edited 2009-03-08 14:18 in Propeller 1
My sensirion sensor sensor returns 65535 for both temp and hum, what am I doing wrong?
«1

Comments

  • bozobozo Posts: 70
    edited 2009-02-21 14:22
    sounds like you might not have the protocol sequence right ... you're reading all 1s, typical of the data line being held high ... double-check that you are correctly timing the acks and waiting for the sensor to signal that it is ready to send the measurement etc. Not only after sending the addr/command but also for each of the 2 result bytes that the sensor sends back. Also it helps to send a string of 9 clocks to the unit at the outset to clear it out in case it is stuck. cheers, Mark.

    Post Edited (bozo) : 2/21/2009 2:34:47 PM GMT
  • avionikerenavionikeren Posts: 64
    edited 2009-02-21 15:13
    But I`m using the·sensirion·object, I guess·I should not need to change anything in the object?
  • bozobozo Posts: 70
    edited 2009-02-21 15:42
    OK, you just need to tackle it logically, one step at a time. Excuse me if the steps below are too obvious but I don't know your level of experience, so I just assume beginner ...

    assuming that the object is fault-free,
    (a) check that the propeller pins you're using for data and clock align with your definitions for SHT_DAT & SHT_CLOCK.
    the definitions in the object code might use pins 0 and 1 and if you are using different pins you need to change the definitions in the CON block
    (b) if that checks out OK, make sure you are connecting the propeller DAT pin to the SHT DAT pin (pin 1 from memory)
    and that the propeller SCK pin connects to the SHT SCK pin (pin3)
    (c) if that checks out OK, make sure ground and Vdd are correctly set up to the SHT (eth to pin4, Vdd to pin8)
    (d) if that checks out OK, either the SHT is faulty or the object needs debugging

    I doubt the SHT is faulty, mine has had a hard life and still works fine, but it could be possible.
    \cheers, Mark
  • avionikerenavionikeren Posts: 64
    edited 2009-02-21 17:26
    I`m a beginner with propeller, but experienced with electronics... smile.gif

    Have checked the connections over and over, and also observed the clock and data stream

    with scope, looks good, but will·get another probe so I can watch them simultaneously...
  • bozobozo Posts: 70
    edited 2009-02-21 17:55
    FWIW I just downloaded the object and it seems to run fine (previously I was using my own code). It is definitely sending commands and reading data correctly. Either you have a really obvious error in your setup or your module is cactus. Good luck!

    Post Edited (bozo) : 2/21/2009 6:22:10 PM GMT
  • avionikerenavionikeren Posts: 64
    edited 2009-02-21 18:25
     var
     long datastring[noparse][[/noparse]17] 
     pub main
     datastring[noparse][[/noparse]8] := (sht.readTemperature)
     serial.dec(datastring[noparse][[/noparse]8])
    

    This·is·from my code, can you see anything wrong?
  • bozobozo Posts: 70
    edited 2009-02-21 18:49
    have you included code to start the sht before you use it?

    i.e.
    pub main
    sht.start(SHT_DAT, SHT_SCK)
  • avionikerenavionikeren Posts: 64
    edited 2009-02-21 19:06
    yes, forgot to mention...

    also tried with and without the reset command...
      sht.start(temphumdata, temphumclk)
      sht.reset
    
  • bozobozo Posts: 70
    edited 2009-02-21 22:57
    beats me, without looking at all the code ... are you sure you got the pins right on the SHT module - it's not the same as for the SHT chip itself ...
  • whickerwhicker Posts: 749
    edited 2009-02-21 23:06
    what an unfortunate choice of 3 letters to name an object... Alright, enough with the teenage-level humor, I'll go away now.
  • avionikerenavionikeren Posts: 64
    edited 2009-02-22 00:15
    Checked again with the scope, looks perfect there, different values for temp and hum, clock puls and data pins tripple checked.

    Started to think if the input could have been damaged, i`m using a 1k resistor on the data line, shouldn`t that be enough?
  • bozobozo Posts: 70
    edited 2009-02-22 08:45
    say what? take it out and try again

    in the module itself the data line is pulled high by a 4k7 resistor (between sensiron chip pin 2 and Vdd) and there's a 330R resistor in series (between sensiron chip pin 2 & pin 1 on the module board)

    so if you've added 1k, it's quite likely you're upsetting the actual voltage on the data line ... and your commands are not reaching the sensiron and/or the data results are not reaching the prop with 1s and 0s within the voltage tolerance ranges

    just a direct connection between prop and sensiron module is all that's needed

    hopefully that'll cure everything
  • avionikerenavionikeren Posts: 64
    edited 2009-02-22 10:03
    That did not help... but I thought when the sensirion is powered with 5volt, then there should be a·resistor in series, since the prop runs on 3,3v...

    could that be the propblem, the sensirion on 5volt and the prop on 3,3?· when I look at the scope, there is 4,0volt on dataline high...
  • bozobozo Posts: 70
    edited 2009-02-22 10:14
    no, mine runs off 5v and works just dandy ... the 330R series resistor on the module should take care of limiting the current into the prop when the sht end of the line is high. More importantly, what voltage do you see when the line is being pulled low? - does it go low enough?

    what object is defined as serial in your code? is there a possibility that everything is working ok but the call to the serial.dec routine is not translating the value properly? (does it convert a binary into a decimal? ...)

    Post Edited (bozo) : 2/22/2009 10:30:08 AM GMT
  • avionikerenavionikeren Posts: 64
    edited 2009-02-22 10:33
    The low`s are totally zero volt....

    I`m using the Extended_FDSerial object. And I tried to set (datastring[noparse][[/noparse]8] := 100) and that is transmitted perfect...
  • bozobozo Posts: 70
    edited 2009-02-22 11:15
    I hate to say it but it looks like the sensiron is cooked.

    You've checked the board for obvious faults such as broken tracks, dry joints, corrosion, ...?

    When you observe the data line are you able to confirm that both the propeller and the sensiron are responsible for driving it? When the addr/command is sent, the propeller is driving the line, when the data/measurement is being sent the sensiron is driving the line ... it happens so fast that unless you have a storage cro it can be tough to determine whether the data line is being used for addr/command or measurement data

    one possible thing to try is to edit the sensiron object to put a few seconds of delay between the addr/command and reading the data ... that'll let you observe whether the sensiron is actually taking control of the data line

    otherwise there aren't many other avenues to explore [noparse]:([/noparse]
  • avionikerenavionikeren Posts: 64
    edited 2009-02-22 16:07
    Here is a scope capture, hope you can tell from that? =) Checked at the sensor and at the prop. exactly the same...
    794 x 522 - 78K
  • bozobozo Posts: 70
    edited 2009-02-22 16:59
    it looks like the prop is not pulling the data line low ... one of those first two sequences of 9 clocks should contain the address/command, and the first 3 bits have to be zero (address), followed by 5 bits of command. If the first seq of 9 clocks is a reset, then the 2nd seq is the command and looks faulty. If there's no reset in the picture, then the first set of 9 clocks is the command, and also looks faulty. The data line is pulled low after the 8th pulse by the sensiron and released after the 9th clock pulse (ack from propeller). It looks like you are sending a command of '11111' which is not defined, so whatever results the sensiron sends back are meaningless.

    Triple check that the physical propeller pin you are using for the data line is the one that you've defined in your code, or try another pin.
  • avionikerenavionikeren Posts: 64
    edited 2009-02-22 17:41
    I have now tested the data out pin and it works. Also downloaded the latest propeller tool and redownloaded the sensirion object, still the same...

    What is the status for? should I use the writeStatus command?
  • bozobozo Posts: 70
    edited 2009-02-22 18:08
    no it's not necessary to use the writeStatus, it is for setting the number of bits of resolution, detecting low voltage etc

    which pin on the module are you connecting the propeller data pin to?
  • avionikerenavionikeren Posts: 64
    edited 2009-02-22 23:07
    The data pin to module`s pin 1 and clock to 3 with 4,7k resistor to ground...
  • rjo_rjo_ Posts: 1,825
    edited 2009-02-23 00:29
    There's yer problem...
    Use 3.3V... and a single 1k on your data line
    I don't have anything on the ground line... except ground(of course)

    I promised to feed my son ... yesterday; so I really don't have time to look at the pinouts. Will check back later.

    Rich
  • bozobozo Posts: 70
    edited 2009-02-23 20:10
    huh?
    how do either of those suggestions fix the problem?
  • rjo_rjo_ Posts: 1,825
    edited 2009-02-23 23:50
    I configured the unit as above... also as described in the Parallax 8 page document with a 4.7k between the clock and ground... and I also set it up with no resistors at all... and it worked all three times.

    There is some possible confusion if you use the data sheet supplied by Sensirion. On page 7 the pinouts are not what you would expect from the Parallax document and might lead you astray.
  • avionikerenavionikeren Posts: 64
    edited 2009-02-24 00:06
    I have checked the pins and everything to the parallax document ten times now, and I`m totally sure that this is either software or broken sensor problem, but the sensor and the propeller is brand new, so I got a feeling it`s my code... maybe I should give up and order a new one... the problem is, three weeks waiting time for a new one [noparse]:([/noparse]
  • bozobozo Posts: 70
    edited 2009-02-24 00:35
    the cro traces tend to indicate the sensiron is ok
    can you post the full code you're using?
  • rjo_rjo_ Posts: 1,825
    edited 2009-02-24 00:37
    I have been where you are dozens of times... it was always me. The Prop was fine, the device was fine...
    Usually it was a pin assignment in the software that I had read and re-read and just read it wrong.

    We are the worst ones to edit our own mistakes.

    At most you have blown a pin on the Prop... move things around.

    You should be using the demo code to debug your setup.

    If you can post a picture of your set-up that might help.

    I also had a power supply problem... that I didn't know I had. Everything measured out ok with my multimeter... but I was getting crazy stuff that didn't go away until I plugged a power supply from SpinStudio into my breadboard.
  • rjo_rjo_ Posts: 1,825
    edited 2009-02-24 00:38
    Also... charge can build up inside any of these devices. So, it never hurts to turn all power off and wait for a few moments.
  • avionikerenavionikeren Posts: 64
    edited 2009-03-02 23:17
    Thanks a lot for your time, trying to help me!
    Here`s· the full code, tell me if you see something wrong...(Everything else works perfect,·only the sensirion that is the problem)
    CON
      _clkmode      = xtal1 + pll8x
      _xinfreq      = 10_000_000
      led           = 6
      wateralarm    = 5
      rx            = 1
      tx            = 7
      temphumdata   = 12
      temphumclk    = 11
      adccs         = 14
      adcclk        = 13
      adcdata       = 15
      
    VAR
      long stack1[noparse][[/noparse]50]
      long stack2[noparse][[/noparse]50]
      long datastring[noparse][[/noparse]17]
      
      byte ip
      byte ir
      
                        
    OBJ
      serial        : "Extended_FDSerial"
      compass       : "Compass_IO_mini"
      sht           : "Sensirion" 
      acc           : "memsic2125"
      acc2          : "memsic2125"
      bs2           : "BS2_FUNCTIONS"  
      convert       : "Simple_Numbers"
      math          : "Floatstring"
      f             : "Floatmath"
    
    PUB main
      BS2.start (8,9)
      'cognew(temphum, @Stack2)  
      'compass.start
      
      dira[noparse][[/noparse]led]~~
      dira[noparse][[/noparse]adccs]~~
      dira[noparse][[/noparse]adcclk]~~
      acc.start(4, 2)
      acc2.start(0, 3)
      ip := 0
      ir := 0
      
      datastring[noparse][[/noparse]0] := "s"
      datastring[noparse][[/noparse]1] := ","  
      datastring[noparse][[/noparse]2] := 0      'pitch
      datastring[noparse][[/noparse]3] := ","
      datastring[noparse][[/noparse]4] := 0      'roll
      datastring[noparse][[/noparse]5] := ","
      datastring[noparse][[/noparse]6] := 0      'heading
      datastring[noparse][[/noparse]7] := "," 
      datastring[noparse][[/noparse]8] := 20     'temp
      datastring[noparse][[/noparse]9] := "," 
      datastring[noparse][[/noparse]10] := 20    'hum
      datastring[noparse][[/noparse]11] := "," 
      datastring[noparse][[/noparse]12] := 736   'depth 
      datastring[noparse][[/noparse]13] := "," 
      datastring[noparse][[/noparse]14] := 0     'water alarm
      datastring[noparse][[/noparse]15] := "," 
      datastring[noparse][[/noparse]16] := "e"
      
      Serial.start(rx,tx,3,38400)           '(rx pin, tx pin, mode, baudrate)
      repeat                
        serial.tx(datastring[noparse][[/noparse]0])
        serial.tx(datastring[noparse][[/noparse]1])   
        serial.dec(datastring[noparse][[/noparse]2]*-1)
        serial.tx(datastring[noparse][[/noparse]3])   
        serial.dec(datastring[noparse][[/noparse]4]*-1)
        serial.tx(datastring[noparse][[/noparse]5])   
        serial.dec(datastring[noparse][[/noparse]6])
        serial.tx(datastring[noparse][[/noparse]7])   
        serial.dec(datastring[noparse][[/noparse]8])
        serial.tx(datastring[noparse][[/noparse]9])   
        serial.dec(datastring[noparse][[/noparse]10])
        serial.tx(datastring[noparse][[/noparse]11])   
        serial.dec((datastring[noparse][[/noparse]12]))
        'serial.tx(datastring[noparse][[/noparse]13]) 
        'serial.dec(datastring[noparse][[/noparse]14])
        serial.tx(datastring[noparse][[/noparse]15])
        serial.tx(datastring[noparse][[/noparse]16])
        'serial.tx(13)
        waitcnt(4_000_000 + cnt)   
        'datastring[noparse][[/noparse]6] := compass.heading    'read compass   
        'datastring[noparse][[/noparse]14] := ina[noparse][[/noparse]wateralarm]    'read water alarm input pin    
        !outa[noparse][[/noparse]led]                           'flash status led
        'pitch
        if ip == 0
          datastring[noparse][[/noparse]2] := (acc.my/1680)-187  
        if datastring[noparse][[/noparse]2] > 45
          ip := 1
        if datastring[noparse][[/noparse]2] < -45
          ip := 2     
        if ip == 1
          datastring[noparse][[/noparse]2] := ((acc.mx / 1680) - 337) * -1
          if datastring[noparse][[/noparse]2] < 45
            ip := 0
          if datastring[noparse][[/noparse]2] > 90  
            ir := 2
            if datastring[noparse][[/noparse]2] > 135
              ip := 0
            if datastring[noparse][[/noparse]2] < 136  
              datastring[noparse][[/noparse]2] := (datastring[noparse][[/noparse]2] * -1) + 181
        if ip == 2
          datastring[noparse][[/noparse]2] := ((acc.mx / 1680) - 336)             
          if datastring[noparse][[/noparse]2] > -45
              ip := 0
          if datastring[noparse][[/noparse]2] < -90
            ir := 1
            if datastring[noparse][[/noparse]2] < -135
              ip := 0
            if datastring[noparse][[/noparse]2] > -136
              datastring[noparse][[/noparse]2] := (datastring[noparse][[/noparse]2] * -1) -180 
        if ip == 0
          datastring[noparse][[/noparse]2] := (acc.my/1680)-187
          
        'roll
        if ir == 0
          datastring[noparse][[/noparse]4] := (acc2.my/1600)-249     
        if datastring[noparse][[/noparse]4] > 45
          ir := 1
        if datastring[noparse][[/noparse]4] < -45
          ir := 2     
        if ir == 1   
          datastring[noparse][[/noparse]4] := ((acc2.mx / 1600) - 162)
          if datastring[noparse][[/noparse]4] < 45
            ir := 0  
          if datastring[noparse][[/noparse]4] > 135
            datastring[noparse][[/noparse]4] := ((acc2.my/1600) - 434) * -1
            if datastring[noparse][[/noparse]4] > 180
              ir := 2   
        if ir == 2  
          datastring[noparse][[/noparse]4] := ((acc2.mx / 1600) - 167) * -1              
          if datastring[noparse][[/noparse]4] > -45
            ir := 0
          if datastring[noparse][[/noparse]4] < -135
            datastring[noparse][[/noparse]4] := ((acc2.my/1600) - 72) * -1 
            if datastring[noparse][[/noparse]4] < -180
              ir := 1     
        if ir == 1   
          datastring[noparse][[/noparse]4] := ((acc2.mx / 1600) - 162)
          if datastring[noparse][[/noparse]4] < 45
            ir := 0  
          if datastring[noparse][[/noparse]4] > 135
            datastring[noparse][[/noparse]4] := ((acc2.my/1600) - 434) * -1
            if datastring[noparse][[/noparse]4] > 180
              ir := 2                
        if ir == 0
          datastring[noparse][[/noparse]4] := (acc2.my/1600)-249
        'depth  
        outa[noparse][[/noparse]adccs] := 0                                                            
        datastring[noparse][[/noparse]12] := bs2.SHIFTIN(adcdata, adcclk, BS2#MSBPost,12)
        outa[noparse][[/noparse]adccs] := 1
     
    PUB temphum 
      sht.start(temphumdata, temphumclk)
      repeat
        datastring[noparse][[/noparse]8] := (sht.readTemperature) 
        'datastring[noparse][[/noparse]10] := (sht.readHumidity)
     
    
  • rjo_rjo_ Posts: 1,825
    edited 2009-03-04 05:21
    missed your post... out sick.
    will take another look in the morning.

    Hang in there, you are almost done... and ready to start producing some interesting numbers. Make sure you post your results... and for that it would be useful if you had an SD card to record to.

    For now, just look at the demo code by Cam Thompson...

    For example he reads the temperature value into a long, which I call "getvalue," below:

    getvalue:= f.FFloat(sht.readTemperature)

    and then he does a string conversion on getvalue and then displays that value.

    Try breaking out the code and just worry about the sht.... set it up, and run the demo...
    once you have that working... it should work in your main program... unless you run out of cogs first[noparse]:)[/noparse]

    I don't have mine set up at the moment and don't remember if voltage was an issue in your setup... but I used 3.3Volts and then as long as I got my the data and clock lines right, the rest didn't seem to matter. Of course it is best to set it up as documented[noparse]:)[/noparse]

    By the way... I assume sht means... "sense humidity and temperature," but the guy that named it deserves a prize... it is hard to forget the name, which isn't true for most chips. I liked this chip first time I saw the name...

    Rich
Sign In or Register to comment.