16 bit serin / serout
Archiver
Posts: 46,084
I am trying to use two BS2 stamps utilizing one as a transmitter and
the other as a reciever. When trying to send two 16 bit varibles
out, the reciever only sees one var as a 16 bit word and the other
as a byte. Can someone help me on this matter. Thanks
'example for transmitter:
'{$STAMP BS2}
C var word
A var word
C=25521
A=42579
Loop:
SEROUT 1, 16468,[noparse][[/noparse]dec c,a] ' Send the words.
PAUSE 2000
GOTO Loop
example for reciever:
'reciever
'{$STAMP BS2} 'STAMP directive (specifies
a BS2)
C var word
A var word
Again:
SERIN 1\0, 16468,[noparse][[/noparse]dec C,A]
DEBUG dec C, cr
DEBUG dec A, cr
GOTO Again
the other as a reciever. When trying to send two 16 bit varibles
out, the reciever only sees one var as a 16 bit word and the other
as a byte. Can someone help me on this matter. Thanks
'example for transmitter:
'{$STAMP BS2}
C var word
A var word
C=25521
A=42579
Loop:
SEROUT 1, 16468,[noparse][[/noparse]dec c,a] ' Send the words.
PAUSE 2000
GOTO Loop
example for reciever:
'reciever
'{$STAMP BS2} 'STAMP directive (specifies
a BS2)
C var word
A var word
Again:
SERIN 1\0, 16468,[noparse][[/noparse]dec C,A]
DEBUG dec C, cr
DEBUG dec A, cr
GOTO Again
Comments
davhowe@a... writes:
> SEROUT 1, 16468,[noparse][[/noparse]dec c,a] ' Send the words.
> PAUSE 2000
>
Change it to dec c, dec a
Sid Weaver
W4EKQ
Port Richey, FL
[noparse][[/noparse]Non-text portions of this message have been removed]
SEROUT 1, 16468,[noparse][[/noparse]DEC C, DEC A]
SERIN 1, 16468,[noparse][[/noparse]DEC C, DEC A]
For testing porpouses, is not necesary the "flow pin" specification as
SERIN 1\0, 16468,[noparse][[/noparse]DEC C, DEC A]
I hope to help you.
Mensaje original
De: sleeplssma2003 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=OX-jMMxYvtA9ozzM2h4sYbuTyrrND-qiLUSxcUAwrwVlDAF4AxABitwsITR6eJWpFTXAakH85LNSQ1Q]davhowe@a...[/url
Enviado el: martes, 25 de marzo de 2003 01:44
Para: basicstamps@yahoogroups.com
Asunto: [noparse][[/noparse]basicstamps] 16 bit serin / serout
I am trying to use two BS2 stamps utilizing one as a transmitter and
the other as a reciever. When trying to send two 16 bit varibles
out, the reciever only sees one var as a 16 bit word and the other
as a byte. Can someone help me on this matter. Thanks
'example for transmitter:
'{$STAMP BS2}
C var word
A var word
C=25521
A=42579
Loop:
SEROUT 1, 16468,[noparse][[/noparse]dec c,a] ' Send the words.
PAUSE 2000
GOTO Loop
example for reciever:
'reciever
'{$STAMP BS2} 'STAMP directive (specifies
a BS2)
C var word
A var word
Again:
SERIN 1\0, 16468,[noparse][[/noparse]dec C,A]
DEBUG dec C, cr
DEBUG dec A, cr
GOTO Again
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
> SEROUT 1, 16468,[noparse][[/noparse]dec c,a] ' Send the words.
> SERIN 1\0, 16468,[noparse][[/noparse]dec C,A]
When you define your variable words and assign values
to them, whether you assign it as decimal, hex, or
binary, it is ultimatly storing it as binary. The fact
that you can assign it as decimal is for your
conveniance. This being said, it is not necessary to
send the data formated as decimal as you have here
because you are "unformating" it once it is received
to the other stamp. Using the formaters will also
cause delays with long data sets and will likely lead
to errors at high baudmodes. Not to mention it leads
to a lot of confusion when trying to figure out if the
data has/has not been formated correctly.
A simpler way is:
> 'example for transmitter:
> '{$STAMP BS2}
>
> C var word
> A var word
>
> C=25521
> A=42579
>
> Loop:
>
> SEROUT 1, 16468,[noparse][[/noparse]c,a] ' Send the words.
> PAUSE 2000
> GOTO Loop
>
> example for reciever:
>
>
> 'reciever
> '{$STAMP BS2}'STAMP directive (specifies a BS2)
>
> C var word
> A var word
>
> Again:
> SERIN 1\0, 16468,[noparse][[/noparse]C,A]
> DEBUG dec C, cr
> DEBUG dec A, cr
>
> GOTO Again
Also, using an array to receive the data into can help
keep things together...
> 'reciever
> '{$STAMP BS2}'STAMP directive (specifies a BS2)
>
> waData var word(3)
>
> Again:
> SERIN 1\0, 16468,[noparse][[/noparse]str waData\2]
> DEBUG dec waData(0),tab, dec waData(1), cr
>
> GOTO Again
If you use an array, you will need to make the array 1
element larger than the data it will hold due to
ending characters. All of this is in the Stamp manual
though.
Hope this was helpful.
Andy
http://www.powderworks.com
byte unless you direct otherwise.
Declaring a variable as a 2-byte word doesn't count as directing
otherwise. If you SEROUT a word in this manner,
SEROUT 1, 16468,[noparse][[/noparse]a] ' Send the words.
you wind up sending only the low order byte of a. In order to send
both bytes that make up the word variable, you could do this:
SEROUT 1, 16468,[noparse][[/noparse]a.HIGHBYTE,a.LOWBYTE] ' Send the words.
If you do this instead,
SEROUT 1, 16468,[noparse][[/noparse]DEC a] ' Send the words.
the interpreter will send 1 -5 ASCII bytes to send a decimal numeric
representation of the value in a.
If you do this,
SEROUT 1, 16468,[noparse][[/noparse]DEC c, DEC a] ' Send the words.
anywhere from 2 - 10 ASCII numeric bytes may be sent, with no
indication of when one numeric ends and the next starts.
If you do this,
SEROUT 1, 16468,[noparse][[/noparse]DEC c, ",", DEC a, ","] ' Send the words.
The same two to ten bytes are sent plus commas inbetween. Then if
you do this on the receiving Stamp,
SERIN 1\0, 16468,[noparse][[/noparse]DEC C, DEC A]
things should sort themselves out, since the commas will delimit the
two numerics.
Regards,
Steve
"word" for some reason. I stand corrected.
Andy
--- S Parkis <parkiss@e...> wrote:
> The thing to remember about SEROUT is that it will
> send one binary
> byte unless you direct otherwise.
>
> Declaring a variable as a 2-byte word doesn't count
> as directing
> otherwise. If you SEROUT a word in this manner,
>
> SEROUT 1, 16468,[noparse][[/noparse]a] ' Send the words.
>
> you wind up sending only the low order byte of a.
> In order to send
> both bytes that make up the word variable, you could
> do this:
>
> SEROUT 1, 16468,[noparse][[/noparse]a.HIGHBYTE,a.LOWBYTE] ' Send the
> words.
>
> If you do this instead,
>
> SEROUT 1, 16468,[noparse][[/noparse]DEC a] ' Send the words.
>
> the interpreter will send 1 -5 ASCII bytes to send a
> decimal numeric
> representation of the value in a.
>
> If you do this,
>
> SEROUT 1, 16468,[noparse][[/noparse]DEC c, DEC a] ' Send the words.
>
> anywhere from 2 - 10 ASCII numeric bytes may be
> sent, with no
> indication of when one numeric ends and the next
> starts.
>
> If you do this,
>
> SEROUT 1, 16468,[noparse][[/noparse]DEC c, ",", DEC a, ","] ' Send
> the words.
>
> The same two to ten bytes are sent plus commas
> inbetween. Then if
> you do this on the receiving Stamp,
>
> SERIN 1\0, 16468,[noparse][[/noparse]DEC C, DEC A]
>
> things should sort themselves out, since the commas
> will delimit the
> two numerics.
>
> Regards,
>
> Steve
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed.
> Text in the Subject and Body of the message will be
> ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
SEROUT 1, 16468,[noparse][[/noparse]bin16 a]
or
SEROUT 1, 16468,[noparse][[/noparse]dec5 a]
thanks
Powderworks Robotics <robotics@p...> wrote:Ah, yes... My mistake. I
wasn't paying attention to
"word" for some reason. I stand corrected.
Andy
--- S Parkis
wrote:
> The thing to remember about SEROUT is that it will
> send one binary
> byte unless you direct otherwise.
>
> Declaring a variable as a 2-byte word doesn't count
> as directing
> otherwise. If you SEROUT a word in this manner,
>
> SEROUT 1, 16468,[noparse][[/noparse]a] ' Send the words.
>
> you wind up sending only the low order byte of a.
> In order to send
> both bytes that make up the word variable, you could
> do this:
>
> SEROUT 1, 16468,[noparse][[/noparse]a.HIGHBYTE,a.LOWBYTE] ' Send the
> words.
>
> If you do this instead,
>
> SEROUT 1, 16468,[noparse][[/noparse]DEC a] ' Send the words.
>
> the interpreter will send 1 -5 ASCII bytes to send a
> decimal numeric
> representation of the value in a.
>
> If you do this,
>
> SEROUT 1, 16468,[noparse][[/noparse]DEC c, DEC a] ' Send the words.
>
> anywhere from 2 - 10 ASCII numeric bytes may be
> sent, with no
> indication of when one numeric ends and the next
> starts.
>
> If you do this,
>
> SEROUT 1, 16468,[noparse][[/noparse]DEC c, ",", DEC a, ","] ' Send
> the words.
>
> The same two to ten bytes are sent plus commas
> inbetween. Then if
> you do this on the receiving Stamp,
>
> SERIN 1\0, 16468,[noparse][[/noparse]DEC C, DEC A]
>
> things should sort themselves out, since the commas
> will delimit the
> two numerics.
>
> Regards,
>
> Steve
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed.
> Text in the Subject and Body of the message will be
> ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and Body of
the message will be ignored.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Do You Yahoo!?
Yahoo! Net: La mejor conexi
of each are different.
In the first, you'll send 16 bytes, "1011000100001010"
(or whatever the binary version of 'a' is).
I'm not sure of the next -- 5 decimal characters, anyway.
The 'purest' (lowest use of bandwidth) way to send a WORD is:
SEROUT 1, 16568, [noparse][[/noparse]a.highbyte, a.lowbyte]
as this sends one byte for the upper 8 bits of 'a', and then one byte
for the lower 8 bits of 'a'.
Note the 'SERIN' device must match its data spec with the SEROUT
device to properly decode the sent data.
--- In basicstamps@yahoogroups.com, Abigail L