Shop OBEX P1 Docs P2 Docs Learn Events
Recieving serial data with a bs1? — Parallax Forums

Recieving serial data with a bs1?

HwardHward Posts: 8
edited 2005-10-12 06:15 in BASIC Stamp
I have a little x10 single reciever that sends the signal out a serial port· Could someone help me just get the stamp to just read from it and debug what it recieved?

This is the reciever i have··· http://www.wgldesigns.com/w800.html

·

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-10-12 00:03
    Hello,

    ·· Besides being RS-232 levels, the baud rate for this device is listed as 4800 bps, while the BS1 can only go up to 2400 bps.· You would need a BASIC Stamp 2 for this device.· Sorry.· =(

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • HwardHward Posts: 8
    edited 2005-10-12 00:05
    not a problem· i have a bs2 i can use······ just had a bs1 that i have never done anytihng with and hoped i could use it but··· if you could help me out with the bs2 just so i can see what its recieving that would be great
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-10-12 00:34
    What you will need to do is get the rest of the specifics for the serial parameters.· Then you will also need a level shifter, such as a MAX232.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • HwardHward Posts: 8
    edited 2005-10-12 00:47
    "What you will need to do is get the rest of the specifics for the serial parameters."?? to the reciever
    http://www.wgldesigns.com/protocols/w800rf32_protocol.txt

    and what does the level shifter do?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-10-12 01:00
    The BASIC Stamp communicates at TTL Serial Levels, while the device you mentioned communicates at RS-232 levels.· You should use the data from your device, data from the MAX232 datasheet as well as the help file information for the SERIN command to write a simply program to read data from that device.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-10-12 06:15
    Hward -

    Generally speaking devices which boost RS-232 signal levels also invert the data. Thus, incoming RS-232 data can either be (so called) TRUE or INVERTED. You will need to use the SERIN command to access RS-232 data. In the SERIN command, you specify (at minimum) the receiving pin port number, the BAUDMODE (baud rate + polarity), and the name of the receiving data field, like so:

    baud_mode con 16752 ' BS-2 : 4800, no parity, 1 STOP, INVERTED
    'baud_mode con 188 ' BS-2 : 4800, no parity, 1 STOP, TRUE

    RX_Pin con 0 'Arbitrary RS-232 input pin port number

    datum var byte(4) 'Establish a 4 byte data array to receive X-10 data

    SERIN RX_Pin, baud_mode, [noparse][[/noparse]datum\4] 'Read 4 bytes of serial input data from W800
    etc

    That should get you started. Since I suspect there will be more questions about how to handle this slightly unusual data, I printed out the protocol document, which I would suggest you do as well.

    Here are two simple but slightly tricky routines which may help you in dealing with this data, and save you some precious variable space in the process:

    Rule of logic 1: Any data field exclusively ORed with itself will always result in binary zeros

    Application: X = X^X results in X = 00H

    Rule of logic 2: Any two data fields exclusively ORed with each other three times, alternating the source and destination fields, will result in a swapping of the data in those two fields without the need for an intermediate storage area.

    Application:

    Initially: A = 1, B - 2

    A = A ^ B
    B = B ^ A
    A = A ^ B

    Result: A = 2, B = 1

    One additional PBASIC hint. The REV operator will reverse the bit order in a specified data field.

    Regards,

    Bruce Bates
Sign In or Register to comment.