BS2sx SERIN command.
Boris
Posts: 81
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.
·
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
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
Any thoughts on my 1st question?
· 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
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.