Shop OBEX P1 Docs P2 Docs Learn Events
I wish - SERIN 7, Baud56k7, 65000, timeout_label, [WAIT('STRING')] - would wor — Parallax Forums

I wish - SERIN 7, Baud56k7, 65000, timeout_label, [WAIT('STRING')] - would wor

jacksmith99jacksmith99 Posts: 7
edited 2007-02-17 12:39 in BASIC Stamp
Before you say: Of course that doesn't work... Please bear with me - I had to substitute [noparse][[/noparse]WAIT("STRING")] with [noparse][[/noparse]WAIT('STRING')] in the subject line, because of the quotes.

Hi All,

I am new to all this (BASIC Stamp) and I have burned my fair share of midnight oil lately, but got a OEM BS2sx working
with most of the code I have written.

However... There is one problem I cannot solve confused.gif

I'd like the SX to wait for a string of chars (6 in total) and then hop into a do loop. It does this without any problem. Fine!

BUT if the string does not arrive within 65sec, it should hop into a different subroutine. This, I cannot figure out how to program.
The packets arrive every 60sec and are between 150 and 250 bytes long and within this data stream I'd like to fish out the 6 characters.

I'd very much appreciate any tips, comments and thoughts!

Thanks,

Jack

Comments

  • BeanBean Posts: 8,129
    edited 2007-02-16 23:06
    Jack,
    The command should jump to your timeout_label if no data is detected within 65 seconds.
    I'm pretty sure that as long as data is coming in it will wait forever for the "STRING" characters.
    If you post your code we can probably help you more.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
  • jacksmith99jacksmith99 Posts: 7
    edited 2007-02-16 23:19
    Hi Bean,

    Thank you for the quick reply.
    There is, however, not much more code I could post. All the rest is working but this one line.

    This is how the code looks like at the moment:

    ...
    SERIN 7, Baud56k7, 65000, timeout_label, [noparse][[/noparse]WAIT("STRING")]

    workbyte = IR_stop_command ' When STRING detected load 16bit into VAR workbyte
    goto SEND_COMMAND ' and send out

    timeout_label: ' If no STRING detected within 65 sec, goto MAIN program loop
    goto MAIN

    ...


    Thanks,

    Jack
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-02-16 23:50
    Hi Jack, you need a variable to catch your data.

    data_in VAR Byte(6)
    main:
    DO
    SERIN 16,16468,65000,t_label,[noparse][[/noparse]WAIT("string"),STR data_in\6]
    DEBUG STR data_in
    LOOP
    t_label:
    DEBUG "No data"
    GOTO main

    Jeff T.
  • jacksmith99jacksmith99 Posts: 7
    edited 2007-02-17 11:58
    Hi Unsoundcode,

    Thanks for the tip.

    I have tried, but it doesn't make difference as I am not interested in the STRING itself. I'd like to use STRING
    as a trigger.

    However, after adding a LCD display and some diagnostic, I found out that

    SERIN 7, Baud56k7, 65000, timeout_label, [noparse][[/noparse]WAIT("STRING")]

    does not wait for about 65seconds, it does only wait for about 32seconds!!! and than hops to the timeout label!!!

    Is this particular to my setup or is this a bug, I wonder?

    Jack
  • CCraigCCraig Posts: 163
    edited 2007-02-17 12:32
    Jack,

    The units on the 2sx is 0.4 ms (point 4). The BS2 is 1 ms.

    been there, done that.

    HTH, Chris
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-02-17 12:36
    Jack -

    The SERIN TIMEOUT sub-parameter value is based on timer units, not some singular finite value for all PBASIC Stamps. For the BS-2 the value of 1 timer unit is 1 ms. For the BS-2SX the value of a timer unit is .4 ms.Thus, there is a rather large difference between the two.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • jacksmith99jacksmith99 Posts: 7
    edited 2007-02-17 12:39
    Hi Chris, hi Bruce

    You are spot on... How can I have not seen this rolleyes.gif ???

    I feel suitably silly now - but problem is solved. Thanks for the hint!

    Regards,

    Jack
Sign In or Register to comment.