Shop OBEX P1 Docs P2 Docs Learn Events
Sensors Project questions — Parallax Forums

Sensors Project questions

freshfresh Posts: 8
edited 2010-05-04 15:45 in BASIC Stamp
Hello all. Pleased to be here. I have a few questions regarding the BASIC Stamp.

A) How do constants (CON) contribute, in terms of their size, to memory use?
B) I want to export data to a spreadsheet and to my personal website. Perhaps one could point me in the direction of some documentation?

I have code regarding the 1st question if anyone wants to see it. It's demo code though, and I know it fits in memory.

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-03-23 21:07
    To dynamically retrieve data from the stamp you need a program that reads the serial port and stores the data to a file. Some terminal emulators do this or you could write something in VB Vc# or python that would do this for you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • bill190bill190 Posts: 769
    edited 2010-03-23 21:15
    Try...

    Run

    Memory Map

    (For memory usage - experiment.)

    As to exporting to Microsoft Excel (if you are using that), I found a bunch of stuff by searching google.com for the words...

    microsoft excel input serial port

    http://www.google.com/#hl=en&q=microsoft+excel+input+serial+port&aq=f&aqi=&aql=&oq=microsoft+excel+input+serial+port&gs_rfai=&fp=3582fcc58a84fb8f
  • rixterrixter Posts: 95
    edited 2010-03-23 21:23
    fresh,

    Using CON shouldn't increase memory use at all. The PBASIC editor replaces the constant throughout your code with the value you specify in the CON statement. An experiment as bill suggests may reveal this.

    Are you aware of PLX DAQ? : http://www.parallax.com/ProductInfo/Microcontrollers/PLXDAQDataAcquisitiontool/tabid/393/Default.aspx

    Rick
  • allanlane5allanlane5 Posts: 3,815
    edited 2010-03-23 23:40
    +1 that you can have any number of "CON" -- they are replaced by the compiler before the code is downloaded into the BS2.

    Note that "code check" and the memory map only shows you what the IDE will download -- it doesn't actually read the memory of the BS2.

    And yes, typically you'd run a program on the BS2 that uses SERIN/SEROUT like "SEROUT 16, 16468, [noparse][[/noparse]"Hi", CR]" to send data to the PC.
    Then, on the PC you'll need to run a program to read the serial port.
  • freshfresh Posts: 8
    edited 2010-04-06 17:44
    To all those who replied: Thank you very much! I got the PLX-DAQ working fairly well; with a little more troubleshooting for the timing I think it will work flawlessly.

    What I want to work on now is sending multiple SERINs and SEROUTs. Is there a trick to getting the receiver correctly pick out which message is which? Thanks!

    EDIT: I forgot to mention that I'm working with the RF transmitter, which limits message size to 2 words.

    Mike: Should I use an if...elseif statement with the different WAITs?

    Post Edited (fresh) : 4/6/2010 6:15:54 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-06 18:10
    Regarding multiple SERINs and SEROUTs, commonly you use punctuation and/or prefix information to distinguish between messages. Some I/O devices that use serial communications always expect a message to begin with "!" and this is usually followed by a couple of characters unique to the type of device and the specific message. One example might be "!X01Hello". The "!" marks the beginning of a message. The "X" tells what type of device is being used. The "01" marks the specific type of message and the rest of the data up to and including a CR is the actual message. If a SERIN is being used to receive this, its operands would start with WAIT("!") and the SERIN would ignore everything up to the first "!" received.
  • freshfresh Posts: 8
    edited 2010-04-06 18:14
    Mike: Would it be a good idea to use an if...elseif statement with the different WAITs?
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-06 18:36
    First, what are you trying to accomplish? What would you be trying to do with IF ... ELSEIF statements?
  • freshfresh Posts: 8
    edited 2010-04-06 18:38
    I would be putting them in the Receiver's code so that it would determine which message it was receiving and what to do with it. I have the variables for temperature, humidity and compass direction and a checksum that I'm sending over.

    Post Edited (fresh) : 4/6/2010 6:43:10 PM GMT
  • freshfresh Posts: 8
    edited 2010-04-13 21:27
    Okay, I figured out what I was doing wrong. And I used your suggestion to put in different preambles.

    Now I need to send data to PLXDAQ and accept incoming data from an RF antenna. The problem is, I can't get PLXDAQ to work with the code for the RF SERIN in the program; I know this because when I remove it, plxdaq works fine. When I leave it in, even if the RF receiver is not receiving data, plxdaq will not work. I would greatly appreciate any and all help with this problem.

    Post Edited (fresh) : 4/13/2010 9:50:34 PM GMT
  • FranklinFranklin Posts: 4,747
    edited 2010-04-14 01:33
    Could we see your code as it is now?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • freshfresh Posts: 8
    edited 2010-04-14 17:47
    '--------------------------------------------------------------------------
    '   {$STAMP BS2}
    '   {$PBASIC 2.5}
    
    ' -----[noparse][[/noparse] I/O Definitions ]-------------------------------------------------
    
    Rx              PIN     15               ' Receiver(27981)DATA pin
    
    ' -----[noparse][[/noparse] Constants ]-------------------------------------------------------
    
    sPin    CON    16         'Serial Pin - P16, Programming port
    Baud1    CON    84         'Baud mode for PLX-DAQ with a rate of 9600, 8-N-1
                              'BS2P, BS2SX use 240 for 9600, 8-N-1
    
    
    #SELECT $STAMP                          ' Select Baud constants
      #CASE BS2, BS2E, BS2PE
        T1200       CON     813
        T2400       CON     396
        T4800       CON     188
        T9600       CON     84
        T19K2       CON     32
      #CASE BS2SX, BS2P
        T1200       CON     2063
        T2400       CON     1021
        T4800       CON     500
        T9600       CON     240
        T19K2       CON     110
      #CASE BS2PX
        T1200       CON     3313
        T2400       CON     1646
        T4800       CON     813
        T9600       CON     396
        T19K2       CON     188
    #ENDSELECT
    Inverted        CON     $4000           'Value for inverted serial format
    Baud            CON     T9600+Inverted  '9600 baud, 8,N,1 inverted
    
    'Sensirion CONs
    MoveTo          CON     2                       ' for DEBUG control
    DegSym          CON     186                     ' degrees symbol for DEBUG
    ClrRt           CON     11                      ' clear DEBUG line to right
    
    ' -----[noparse][[/noparse] Variables ]-------------------------------------------------------
    
    angle          VAR      Word        'Array to hold received data
    strLen          VAR     Byte            'Length of string received
    ctemp             VAR     Word                    ' temp counts from SHT1x
    tC              VAR     Word                    ' temp - celcius
    tempF              VAR     Word                    ' temp - fahrenheit
    
    chumid            VAR     Word                    ' humidity counts from SHT1x
    humiLin           VAR     Word                    ' humidity; linearized
    humiTrue          VAR     Word                    ' humidity; temp compensated
    
    
    ' -----[noparse][[/noparse] EEPROM Data ]-----------------------------------------------------
    
    
    ' -----[noparse][[/noparse] Initialization ]--------------------------------------------------
    GOSUB Start_plxdaq
    
    
    ' -----[noparse][[/noparse] Program Code ]----------------------------------------------------
    
    DO
      ' Wait for preamble, then receive data and crc value
      SERIN Rx,Baud,[noparse][[/noparse]WAIT ("U!"), angle]
    
      SERIN Rx,Baud,[noparse][[/noparse]WAIT ("O!"), DEC ctemp]
    
      SERIN Rx,Baud,[noparse][[/noparse]WAIT ("I!"), DEC chumid]
    
      angle = angle */ 360
    
    
      tC = ctemp / 10 - 400                           ' convert to tenths C
      tempF = ctemp ** 11796 - 400                       ' convert to tenths F
      humiLin = (chumid ** 26542)
      humiLin = humiLin - ((chumid ** 3468) * (chumid ** 3468) + 50 / 100)
      humiLin = humiLin - 40
      humiTrue = ((tC / 10 - 25) * (chumid ** 524 + 1) + (humiLin * 10)) + 5 / 10
      'test run with plxdaq   ; only wants to work when the Rx is not allowed
    
      tempF = 89
      angle = 15
      humiTrue = 99
    
    'GOSUB DEBUG_MENU
    GOSUB PLXDAQ
    PAUSE 1000
    LOOP
    
    
    ' -----[noparse][[/noparse] Subroutines ]-----------------------------------------------------
    DEBUG_MENU:
    DEBUG HOME, CR, "angle = ",
      DEC angle, DegSym, CR
    DEBUG MoveTo, 0, 3
      DEBUG "tempF...... "
      DEBUG DEC (tempF / 10), ".", DEC1 tempF, DegSym, ClrRt, CR
    DEBUG "humiTrue... "
      DEBUG DEC (humiTrue / 10), ".", DEC1 humiTrue, "%", ClrRt, CR, CLREOL
    RETURN
    
    PLXDAQ:
    ' Send String with data for Excel
         SEROUT sPin,Baud1,[noparse][[/noparse]"DATA,TIME,TIMER,",DEC angle,DegSym,",", DEC (tempF / 10),DegSym, ",",DEC (humiTrue / 10),".", DEC1 humiTrue, "%",CR]
    RETURN
    
    Start_plxdaq:
    PAUSE 1000                             'Allow data communications to stabilize
    SEROUT sPin,Baud1,[noparse][[/noparse]CR]                  'Send a lone CR to ensure PLX-DAQ buffer is ready
    
            'Label columns
    SEROUT sPin,Baud1,[noparse][[/noparse]CR,"LABEL,Time,Timer,Wind Direction,Temperature,Humidity",CR]
    SEROUT sPin,Baud1,[noparse][[/noparse]"CLEARDATA",CR]      'Clear all data columns (A-J) in Excel
    SEROUT sPin,Baud1,[noparse][[/noparse]"RESETTIMER",CR]     'Reset Timer to 0
    RETURN
    
  • FranklinFranklin Posts: 4,747
    edited 2010-04-15 01:31
    Seems I remember that "Pin 16" is the same pin as pin15 but goes through the rs232 converter and has some special features. Move your rx pin somewhere else and try it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • freshfresh Posts: 8
    edited 2010-04-28 16:35
    Thanks Franklin, your suggestion worked.

    Now my problem is that I am trying to run the RF in the same room as another set of RF sensors, and it isn't working. The other guy's sensors work but they bump off mine. I've tried everything I can think of, including using different preambles, but I still can't get a signal across.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-28 17:04
    A lot of RF sensors use very simple transmitters and receivers which don't handle interference very well. There may not be anything you can do. It may be that you can switch to different RF devices that use a different band of frequencies.

    For future questions ... Please provide enough information at the beginning about your project, what devices you're using, how they're all connected, and what code you're using. This piecemeal approach is not a good use of your own or anyone else's time.
  • freshfresh Posts: 8
    edited 2010-05-04 15:29
    Thanks for the advice Mike.

    One more question: the code I'm using is partially taken from the demo code posted by Parallax with the modules. I want to enter the Parallax RF contest. I've put this bit in the beginning of my code.


    '   Author.... *Insert my name*
    '   Code excerpts for Compass module Hitachi HM55b (#29123) and Sensirion (#28018) provided courtesy of
    '   Parallax, Inc. Code for RF transmission adapted from Demo code for
    '   Parallax 433 MHz Transmitter (#27980) & Receiver (#27981) provided courtesy of Parallax, Inc. All
    '   other code and changes in code are mine.
    



    I've also marked the blocks I've directly borrowed from the Hitachi and Sensirion codes as being from their respective demos. I've changed the formatting and flow of the code for the Sensirion. The code for the RF transmitter and receiver has been adapted to a transceiver and receiver but uses some of the same variables, although the preambles and message data are different. I've kept most of the variables from the sources.

    Please tell me if this is OK and tell me what changes I should make to be in compliance. Thank you.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-05-04 15:45
    That sounds good to me. You've acknowledged those parts that you've borrowed giving credit where it's due. Parallax isn't "lawyer happy". They're more concerned about intent and integrity and it looks like you've satisfied both. As with any project being judged, the contest is about what you've done, how well you've used existing resources and information, and how well you've done and presented the whole thing.
Sign In or Register to comment.