Shop OBEX P1 Docs P2 Docs Learn Events
BS2sx SERIN command. — Parallax Forums

BS2sx SERIN command.

BorisBoris Posts: 81
edited 2004-10-18 18:17 in BASIC Stamp
Hello,
I am programming a BS2sx board to acept values from a serial port and got a few questions:
1) I need to make a FOR loop where variable M will go fom 1 to 5 (for example)
and inside the loop i need the SERIN command to WAIT for "po:" M
so in the first execution of the loop it will wait for "po:1", second execution "po:2"

2) How long do the SERIN and WAIT commands take?
if i have these two commands in a row
SERIN 16,240,10000,NoData,[noparse][[/noparse]WAIT("r_cnt:"),DEC2 ErrCnt]
SERIN 16,240,10000,NoData,[noparse][[/noparse]WAIT("m_poi:"),DEC temp]

and i send data "err_cnt:03 err_elm_poi:4" will the BS have enough time to write 03 to variable ErrCnt and execute the next SERIN command in time to catch "m_poi:" and write 4 to variable temp?


Thank you,

Boris.
·

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-10-12 18:25
    Probably not -- but you can put them into one line. Give this a try:

    SERIN 16, 240, 10000, No_Data, [noparse][[/noparse]WAIT("r_cnt:"),DEC2 ErrCnt, WAIT("m_poi:"),DEC temp]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • BorisBoris Posts: 81
    edited 2004-10-12 21:50
    Thanks,
    Any thoughts on my 1st question?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-10-13 13:30
    Give this a try (it compiles, but I'm not sure it will work):

    · FOR idx = 1 TO 5
    ··· idx2 = idx + "0"
    ··· SERIN Sio, Baud, [noparse][[/noparse]WAIT("po:", idx2), pos]
    · NEXT

    You can't use the DEC output modifier in the middle of the WAIT parameters, so the line before SERIN converts the value of idx to ASCII.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • BorisBoris Posts: 81
    edited 2004-10-13 14:31
    yep, that worked, than you very much
  • BorisBoris Posts: 81
    edited 2004-10-18 18:17
    Back to this problem again.
    seems that this trick only works for values 0 to 9, how would i convert string value "14" to decimal 14?

    · FOR idx = 1 TO 5
    ··· idx2 = idx + "0"
    ··· SERIN Sio, Baud, [noparse][[/noparse]WAIT("po:", idx2), pos]
    · NEXT

    Thank you,

    Boris.
Sign In or Register to comment.