Shop OBEX P1 Docs P2 Docs Learn Events
Ignore data — Parallax Forums

Ignore data

philipad23philipad23 Posts: 44
edited 2006-04-29 02:52 in BASIC Stamp
Hi everyone

I have an RF receiver connected in serial with the BS2 and I use it to send a word size dara (16bit). Is there a way for the BS2 to ignore the data in the case of lost bits in the transmission, which means that the data received is less than 16 bits ?

Thanks

Comments

  • philipad23philipad23 Posts: 44
    edited 2006-04-24 21:13
    I mean to send data with a transmitter to the receiver [noparse]:)[/noparse]
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-25 01:30
    You cannot send the data 16 bits at a time.· You must break a WORD variable up into two BYTE sized variables in order to send serially.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • philipad23philipad23 Posts: 44
    edited 2006-04-25 03:30
    ok..how can I ignore the data in the case of lost bits?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-25 04:08
    I'm not sure, because you have posted no code, and your post indicates you're not sure how the data is being transmitted.· Please post your code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • philipad23philipad23 Posts: 44
    edited 2006-04-28 06:34
    my code consists of a simple SERIN instruction

    a VAR Word

    main:
    SERIN 0, 16780,5000, Timeout, [noparse][[/noparse]DEC a]
    DEBUG ?a
    GOTO main

    timeout:
    DEBUG "timeout"
    RETURN

    If I send a signal with BS1 which is connected directly to a BS2' pin, I get the signal (for example the number 65535). Through RF communication between BS1 and BS2 on the DEBUG I get 535, 5535 and rarely 65535. What I want is the 535 or 5535 to be disregarded.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-04-28 09:50
    Philip -

    Asynchronous serial data transmission is a byte-oriented protocol, so you will need to read the data in as bytes, regardless of what you want to do with it later on down the line. Here is your program changed to accomodate byte input, then stored it in a WORD sized variable:

    /code
    a VAR Word

    main:
    '·············································· 8 bits only··· 8 bits only
    SERIN 0, 16780,5000, Timeout, [noparse][[/noparse]a.highbyte,·· a.lowbyte]

    DEBUG ?a.highbyte 'Display just the top end

    GOTO main

    timeout:

    DEBUG "timed out"
    GOTO main
    END

    code/

    If that's not exactly what you were looking to do, you may need to use the SHIFT function to dump the bits you want to eliminate:
    a = a >> 8 'Dump 8 low bits into the bit-bucket near the Black Hole at the right
    a = a << 8 'Re-align the data back to where it was

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-28 14:15
    To add to what Bruce said if you're getting a lot of errors in your transmission you can try reducing the baud rate or you can implement CRC (Cyclic Redundancy Checksum) which will add a little overhead to your transmission, but will ensure the received data is accurate.· This would involve sending the CRC byte after the packet of digits.· If the CRC doesn't match on the receiving side then you discard that packet.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • philipad23philipad23 Posts: 44
    edited 2006-04-29 02:21
    I am aware that the signal must be byte sized but my code works anyway...
    I will try to reduce the baud rate and to separate the the word into bytes, but the thing is that sending a synchronization byte I can get the signal as appropriate.

    SEROUT 0, 16780, [noparse][[/noparse]126,("A"),DEC a] 'transmitter

    SERIN 0, 16780,5000, Timeout, [noparse][[/noparse]WAIT ("A"),DEC a] 'receiver

    The problem is that as the instruction waits for synchronization, it never times out. Is there a way to make it to time out or this is not supported by BS2?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-04-29 02:52
    philipad23 said...
    SERIN 0, 16780,5000, Timeout, [noparse][[/noparse]WAIT ("A"),DEC a] 'receiver
    The problem is that as the instruction waits for synchronization, it never times out. Is there a way to make it to time out or this is not supported by BS2?
    You can't make it to "timeout" away from a WAIT once you tell it to WAIT, that is a WAIT indefinitely (forever, if necessary.)· It'll bail out if there's no valid data in 5 seconds beforehand, as written, but past that it's going to stay in WAIT till it gets satisfied ("A".)·
Sign In or Register to comment.