Shop OBEX P1 Docs P2 Docs Learn Events
serial Protocol — Parallax Forums

serial Protocol

ArchiverArchiver Posts: 46,084
edited 2003-04-14 01:13 in General Discussion
This should get you started. If you specify 8N1 to SEROUT, it will
send one start bit, then 8 data bits (transmitted least significant
bit first) from the your variable, then one stop bit (10 bits all
told). Serial data sent 701 has one start bit, then 7 data bits, an
odd parity bit, and finally a stop bit--again, a total of 10 bits.

The trick is to make the eighth data bit serve as an odd parity bit.
So prior to the SEROUT, you take your 7-bit value, calculate odd
parity and stuff the result in the high-order bit, then send the
result as N81. To the receiver, it will look just like 7O1.

This should generate the odd parity bit for a 7-bit value contained
in "outbyte":

outbyte.BIT7 = 1 ^ outbyte.BIT6 ^ outbyte.BIT5 ^ outbyte.BIT4 ^
outbyte.BIT3 ^ outbyte.BIT2 ^ outbyte.BIT1 ^ outbyte.BIT0

After this instruction the high order bit serves as the parity bit
for 7O1 even when the byte is transmitted as 8N1, because the
receiver interprets the first seven data bits as data and the last
data bit as the parity bit.

Regards,

Steve

> Can anyone help me i need to communicate at BAUD=9600 PARITY=O
> DATA=7 STOP=1 and the manual seems to tell me i can't, can
> anyone clear this up for me???
>
> I have Been told that Using 8N1 and or in the high bit as needed to
> make it come out to odd parity...

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-02-28 15:07
    Can anyone help me i need to communicate at BAUD=9600 PARITY=O
    DATA=7 STOP=1 and the manual seems to tell me i can't, can
    anyone clear this up for me???

    I have Been told that Using 8N1 and or in the high bit as needed to
    make it come out to odd parity will work but i have only been playing
    with the stamp 2 for 2 days, how would you do what was discribed???


    Andy
  • ArchiverArchiver Posts: 46,084
    edited 2002-02-28 15:49
    >Can anyone help me i need to communicate at BAUD=9600 PARITY=O
    >DATA=7 STOP=1 and the manual seems to tell me i can't, can
    >anyone clear this up for me???
    >
    >I have Been told that Using 8N1 and or in the high bit as needed to
    >make it come out to odd parity will work but i have only been playing
    >with the stamp 2 for 2 days, how would you do what was discribed???
    >
    >
    >Andy

    Hi Andy,

    Calculate parity of a 7-bit code as follows:

    code var byte ' send lower 7 bits of this
    parity var code.bit7 ' the most sig. bit of code

    parity=1 ^ code.bit0 ^ code.bit1 ^ code.bit2 ^ code.bit3 ^
    code.bit4 ^ code.bit5 ^ code.bit6
    debug bin8 code,cr ' show it as binary

    The"^" in Stampese means "exlusive OR" and is a way of adding
    together the bits. You could also use "+". I always get confused
    about which is even and which is odd parity, but with odd parity, the
    sum of all the bits in the code (including the parity bit) should be
    odd. This URL for reference:

    http://www.rad.com/networks/1994/err_con/parity.htm

    I hope that helps,
    -- Tracy
  • ArchiverArchiver Posts: 46,084
    edited 2002-03-03 01:22
    just wanted to say thanks to those who gave me advice, it worked
    perfectly.....thanks.......
  • ArchiverArchiver Posts: 46,084
    edited 2003-04-10 22:58
    I tried to write a VB app to send an 18 byte packet to the BSII. I
    followed the serial protocol to the tee and i can't get the firmware
    version to send back the response. Can someone help. My goal is to
    make an object file loader on win ce and to use the BSII for my
    classroom experiments. I have succeeded in win 98 and win ce up to
    the point i mentioned.
    Thanks,
    Curtis
  • ArchiverArchiver Posts: 46,084
    edited 2003-04-11 07:55
    I did that successful with C++ on Linux. My be I can help, but
    you need to be more specific about your problem and code.
    There are a few tings to take into account.

    1. the BS echoes each character you send
    2. to download object code or identify the stamp you have to
    send a reset and break condition first.
    3. watch out not to keep the reset line high and hold the BS in
    reset state.

    and some more

    Regards
    Adrian
  • ArchiverArchiver Posts: 46,084
    edited 2003-04-14 01:13
    Hello,
    Thanks for your response. I started with one mscomm
    control and three timer controls. I set dtr and the
    comm break for the right number of ms as per the
    parallax serial protocol document. The on comm event
    was used to trap responses and a case statement made
    the choice of what to send next. Each time i received
    the right return from the stamp except when the
    firmware version was checked. When I sent a "0" in
    the identify sequence, I get back a "0" but no
    firmware version or anything. Thats as for as i got.
    I tried everything. Iam using VB 5.0. The reset
    works i am pretty sure becuase the simple program in
    the bsII which i have an led blinking ten times
    resets. I also wrote the same program on a win ce
    pocket pc using nsbasic ce and i have the same
    problem. My goal is to load an object(hex) file
    generated by the BSII ide and load to the stamp using
    my pocket pc. I don't think the present tokenizer dll
    will work on ce. Parallax states they will come out
    with a ce dll in the future. I have developed a number
    of experiment for the BSII including a paper
    chromatography reader using the toas sensor. I would
    like to create a module based educational tool using
    the BSII oem and different modules to teach science
    with. I will be glad to publish all my projects when
    complete for everyone to use free. Thanks for your
    help.
    Curtis Desselles

    --- Adrian Schneider <adrian.schneider@t...>
    wrote:
    > I did that successful with C++ on Linux. My be I can
    > help, but
    > you need to be more specific about your problem and
    > code.
    > There are a few tings to take into account.
    >
    > 1. the BS echoes each character you send
    > 2. to download object code or identify the stamp you
    > have to
    > send a reset and break condition first.
    > 3. watch out not to keep the reset line high and
    > hold the BS in
    > reset state.
    >
    > and some more
    >
    > Regards
    > Adrian
    >
    >
    > 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! Tax Center - File online, calculators, forms, and more
    http://tax.yahoo.com
Sign In or Register to comment.