Shop OBEX P1 Docs P2 Docs Learn Events
Adding tsl230_pi object to a modified SensirionDemo spin file — Parallax Forums

Adding tsl230_pi object to a modified SensirionDemo spin file

djtdjt Posts: 19
edited 2009-12-11 21:24 in Propeller 1
I have modified the SensirionDemo (Attachment #1)·spin file to collect and output·data using the FullDuplexSerial (Attachment #3)spin file in the format fashion I want. The program·compiles, runs and outputs the data·as I want it to.·Now I want to add a light output reading from·the tsl230_pi spin file (Attachment #2). I have run the tsl230_pi_Demo file successfully (so my board is connected properly and the tsl230 sensor is working), but I·have not been successful in getting·the tsl230_pi file to run in the modified SensirionDemo file.
Any help in this area would be greatly appreciated.

Thank's,· djt

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2009-12-08 07:59
    Hello djt,

    I would like to see your fist TRY how to add the tsl230 code to it

    Did you examine the file tsl230_pi_DEMO.spin how it is done there ?

    post another SPECIFIC question here to get help

    best regards

    Stefan
  • djtdjt Posts: 19
    edited 2009-12-08 16:22
    I apologize for not supplying enough detail.
    Attached is·a copy of my SemsirionDemoLight spin file with the attempt to incorporate the tsl230_pi object. As mentioned previously·without incorporating the tsl230_pi object the·program runs and supplies the correct output---Temperature, relative humidity and dew point. When I run the attached file the output is ***.* and 0.0 for all the various variables.··Obviously, I don't know how to input an object (tsl230_pi)from another file into a new file(SensirionDemoLight).

    The SH11 sensor is connected to propeller pins 1 and 2. The tsl230 sensor is connected to propeller pins 3 and 4. The program SensirionDemo (as I interpert it) indicates the SH11 sensor data pin and clock pin are connected to the propeller pins 0 and 1 respectively.·I know the propeller pins begin at 1 not 0. What am I missing?

    Thank's for your help.

    djt
  • BRBR Posts: 92
    edited 2009-12-08 16:56
    djt: The tsl230_pi object returns measurement data through the "getSample" method. You should try adding a couple lines inside your repat loop near the top like:
        _scale := light.getScale
        _raw := light.getRawSample
        _sample := light.getSample
    
    



    Also, just to be clear, the TSL230 requires 3 connections to the propeller if you want to run it in "auto" mode: inpun, ctrlPinBase, and ctrlPinBase+1. That third pin HAS to be next to ctrlPinBase. In your demo code, this would be Propeller pin 5.

    I'm not sure I understand what you mean by "I know the Propeller pins begin at 1 not 0." The prop pins are labeled 0-31.

    Hope this helps.
  • djtdjt Posts: 19
    edited 2009-12-08 17:09
    Thank you BR. That 0 to 31 explains a lot.·I thought I had checked that several times, but somehow I·missed it.

    I will add the lines you indicated and·try again.

    Thank's again,

    djt
  • djtdjt Posts: 19
    edited 2009-12-09 22:28
    BR, I have added the lines you suggested. After several modifications I got the program to run and output the data from tsl230. Thank you.
    I still have a problem I don't recognize.·With both of the sensors running the output from the SH11 is like this ***.*% and soforth.All elements output but only ***.*.The tsl230 output is normal.I have attached the updated SensirionDemoLight spin file so that you can view the modifications.·I've reviewed the board wiring and can find no problems. There is interference from somewhere---the board/program??I've reviewed the program and when I eliminate the line "light.start(inpin,ctrlpinbase,samplefreq,autoscale)", the SH11 output is correct, but get no·output from the tsl230.
    Any suggestions· from any one would be greatly appreciated. Remember, I'm·new to the spin language.

    Thank's,·djt
  • BRBR Posts: 92
    edited 2009-12-09 23:32
    djt:

    I don't have a sensirion temp/humidity sensor, but I do happen to have a TSL230 hooked up on my prop demo board at the moment. If I load your program and run it on my demo board (leaving the sensirion pins 0 & 1 unconnected), I get the following:
         Sensirion SHT-11 Demo
    ‘Temperature  ‘     |,‘Rel. Humidity‘    |,‘Dew Point    ‘|Scale  ||Raw  ||Sample  |
    -39.4°F‘              | -4.6% ‘            0.0°F‘,        3,        3012,        120480,
    
    -39.4°F‘              | -4.6% ‘            0.0°F‘,        3,        2574,        102960,
    
    -30.2°F‘              |  4.4% ‘          -79.8°F‘,        3,        2802,        112080,
    
    -39.4°F‘              | 12.7% ‘          -72.1°F‘,        3,        3066,        122640,
    
    -34.8°F‘              | -4.6% ‘            0.0°F‘,        3,        3347,        133880,
    
    -39.4°F‘              | -4.6% ‘            0.0°F‘,        3,        3387,        135480,
    
    



    So your code seems to be working; I get a return value for everything even though the temperature and humidity readings are obviously bogus. Is it possible that it's some kind of problem with the floating point number format you've specified for the output? Might be worth playing around with the format a bit just to be sure that isn't it.

    I've attached the code I used to test this...you might want to check to be sure I'm using the same thing that you've got. I went out to the obex to get the sensirion driver object, I presume it is the same one you're using. FYI, the propeller tool has an option under file/archive/project that will kick out a zip file with all required objects needed for someone else to run your code. The archive feature is the best way to make sure we're looking at exactly the same code and can replicate exactly the same behavior you're seeing.
  • djtdjt Posts: 19
    edited 2009-12-10 00:33
    Thank you BR. I've had some·suspicions of the floating point calculations, but I'm at a loss to explain how anything I've done could have changed·them.They will be tough for me, but I'll get to work on this problem. I'll let you know if or what I find. In the mean time I plan on testing a new Tsl230 object and a new SH11 object. Both are on the web site

    · Thank's····· djt
  • BRBR Posts: 92
    edited 2009-12-10 01:42
    Well, one easy check is to disconnect your sensirion temperature/humidity sensor and run the above code on your setup. That would at least confirm that we can both reproduce the same results in that configuration.

    I've been looking at the sensirion and tsl230 objects and so far I don't see anything obvious that would cause the problem you describe.
  • djtdjt Posts: 19
    edited 2009-12-10 03:43
    I downloaded your attachments under a different name and ran the code with the sensirion connected and disconnected. With it connected I got the same readings that I got with my original code---Same problem. With the sensirion sensor disconnected I got readings similar to the ones you got. I would have sent you the readings, but I don't know how to capture them off the Parallax Serial screen. This of course confirms we have the same code. I'll keep trying.

    Thank's, djt
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-12-10 05:44
    hello djt,

    I tested your code with no sensors connected.

    if you take a look into the file floatstring.spin

    PUB FloatToFormat(single, width, dp) : stringptr | n, w2
    
    ''Convert floating-point number to formatted string
    ''
    ''  entry:
    ''      Single = floating-point number
    ''      width = width of field
    ''      dp = number of decimal points
    ''
    ''  exit:
    ''      StringPtr = pointer to resultant z-string
    ''
    ''  asterisks are displayed for format errors 
    ''  leading blank fill is used
    
      ' get string pointer
      stringptr := p := @float_string
    
      ' width must be 1 to 9, dp must be 0 to width-1
      w2 := width  :=  width #> 1 <# 9
      dp := dp #> 0 <# (width - 2)
      if dp > 0
        w2--
      if single & $8000_0000 or positive_chr
        w2--
    
      ' get positive scaled integer value
      n := F.FRound(F.FMul(single & $7FFF_FFFF , F.FFloat(teni[noparse][[/noparse]dp])))
    
      if n => teni[noparse][[/noparse]w2]
      [b] ' if format error, display asterisks [/b]
        repeat while width
          if --width == dp
            if decimal_chr
              byte[noparse][[/noparse]p++] := decimal_chr
            else
              byte[noparse][[/noparse]p++] := "."
          else
            byte[noparse][[/noparse]p++] := "*" 
        byte[noparse][[/noparse]p]~
    
    
    



    you can see that "***" means format error

    So I increased the digits from 5 to 7 and then values are displayed.
    With no sensors connected the values are Smile of course.
    So I suggest increase the digits from 5 to 7

    To get the PST.EXE output to a posting you do it like always:
    mark the desired area with the left mouse button hold down and do a copy&paste

         Sensirion SHT-11 Demo
    &#8216;Temperature  &#8216;     |,&#8216;Rel. Humidity&#8216;    |,&#8216;Dew Point    &#8216;|Scale  ||Raw  ||Sample  |
      255.5°F&#8216;              |   -3.0% &#8216;              0.0°F&#8216;,        3,        0,        0,
    
      550.4°F&#8216;              | -991.3% &#8216;              0.0°F&#8216;,        3,        0,        0,
    
    
      550.4°F&#8216;              |-5679.7% &#8216;              0.0°F&#8216;,        3,        0,        0,
    
      -39.4°F&#8216;              |   -4.6% &#8216;              0.0°F&#8216;,        3,        0,        0, 
    
    



        'term.str(fp.FloatToFormat(rh, 5, 1))
        term.str(fp.FloatToFormat(rh, 7, 1))
     
    
    



    that you get real digits displayed and then narrow down why the values have such a great range

    This might be a hardware related problem and this would explain why you get this error without having changed the code

    best regards

    Stefan
  • djtdjt Posts: 19
    edited 2009-12-11 21:08
    BR & Stefan38,

    Thank you for your excellent info. I now have the program (See attachment)running and out-putting the data I want and in the format I need. The next stages are to add an LCD for local display, a data logger and a hi-lo temperature measurement. I'm sure I'll be back with more questions from the experts.

    Thank's··· djt
  • BRBR Posts: 92
    edited 2009-12-11 21:24
    djt:

    You're welcome. Here's a "get you started" for the LCD:
    http://www.parallax.com/tabid/781/Default.aspx

    The September 2009 column is about LCDs. Also, there's several LCD drivers in the Display OBEX.

    Good luck.
Sign In or Register to comment.