datagood???


Closed Thread
Results 1 to 6 of 6

Thread: datagood???

  1. #1

    Default datagood???

    Good Morning to All,
    I am exerimenting with Linx's new long range rxm-lr series modules, seem to be pretty nice. The datasheet shows that the receiver output may switch randomly due to the absence of a transmitter in which it does, 10101010, etc coming out of the datapin. So, shouldn't be a problem, I could add a squelch they even give the circuit for that in the datasheet.

    Now for the real question, I am telling the pic16f628a to :
    SERIN2 SERPIN, 16572,100, START,[WAIT(254),address1, address2,address3,address4,mydata1,mydata2,mydata3 ,mydata4,mydata5,mydata6]

    and of course on the TX side:

    SEROUT2 SERPIN,16572,[$AA,$AA,$AA,$AA,$AA,$AA,synch, address,address1,address,address1,keydata,keydata, keydata,keydata,keydata,keydata]

    My address is an 8bit constant and the keydata is a variable
    address con %00000001
    keydata var byte

    what I have on the rx side to check the address and it seems to work but is flaky :
    addressY con %00000001
    addressZ con %00000010
    address1 var byte
    address2 var byte
    address3 var byte
    address4 var byte

    IF ((address1 == addressy) && (address3 == addressy)) && ((address2 == addressz) &&(address4 == addressz)) then
    portb.1=1 'address matched
    else
    portb.1=0
    endif

    I am also using 8 bits for the keydata, is there a better way to check both address and keydata for being good data plus maybe pickup on good data and reject the bad?

    Thanks

  2. #2
    skimask's Avatar
    skimask Guest

    Default

    No, that's pretty much it, if you want to keep it simple anyways (without getting into CRCs, parity, checksums, and a dozen other error correction methodologies)...
    If you add everything up and compare it to a checksum, it might happen that one data BYTE is one high and another one is one low, thereby cancelling themselves out.
    But, just so I've got this straight... You send address1 twice, address2 twice, and the same keydata 6 times, correct? If so, then, yes, I think the overall best way to make absolutely sure everything is good is to compare everything to everything else. If they all compare good, then you're all good...

  3. #3

    Default

    Thanks skimask, I would have like to add up the keydata but using serial out wouldn't the packets be allowed only 8bits wide or can I send I Word 16bits wide. In that way if all of the keydata bits 0-7 were = to %11111111 then if I added them together the sum would be 10111111010 right? If I made checksum a word and stored it as %0000010111111010,
    transmitted it after the last keydata, then on the rx I could :
    checksum var word
    if ((Keydata1 + keydata2) + (keydata3 + keydata4) + (keydata5 + keydata6)) = checksum then
    datagood = 1
    else
    datagood = 0
    endif

    would this work? I thought I read somewhere I could only send a byte out not a word, if that is the case couldn't I split the word into two bytes.

    Thanks again

  4. #4
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by tazntex View Post
    checksum var word
    if ((Keydata1 + keydata2) + (keydata3 + keydata4) + (keydata5 + keydata6)) = checksum then
    datagood = 1
    else
    datagood = 0
    endif
    Ok, consider this...
    Assume keydata1...6 are all a value of 100, so therefore the checksum should be 600 right?

    What happens if the data gets scrambled and instead of everything being 100, keydata1=50, keydata2=150, keydata3=99, keydata4=101, keydata5=100, keydata6=100?
    Try it out...

  5. #5

    Default

    If the checksum value was received with its original value, and keydata1-6 are scrambled then the sum would not be equal to the value of checksum, the outcome would be datagood = 0 since keydata1-6 != checksum. That's what one would want to happen.
    I was just wondering if per say 4 keydata's out of 6 were equal then assuming their value is correct, could one say reject the last two scrambled keydata's and run. What I mean is if there were a way to say I sending six keydata's if four of any of the six match consider the data good and run. That would allow for pressing the button on the tx and allowing for multipath rf and reflection problems, and prevent from instead of the output chattering on/off but to remain on until the transmitter output is off.

    By the way am I correct that the maximum size I could make keydata or address to send out or receive throught serial would be byte size, 8bit ,on the 16f628a?

  6. #6
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by tazntex View Post
    If the checksum value was received with its original value, and keydata1-6 are scrambled then the sum would not be equal to the value of checksum, the outcome would be datagood = 0 since keydata1-6 != checksum. That's what one would want to happen.
    I was just wondering if per say 4 keydata's out of 6 were equal then assuming their value is correct, could one say reject the last two scrambled keydata's and run. What I mean is if there were a way to say I sending six keydata's if four of any of the six match consider the data good and run. That would allow for pressing the button on the tx and allowing for multipath rf and reflection problems, and prevent from instead of the output chattering on/off but to remain on until the transmitter output is off.
    Either you're too worried about it or you've had these problems in the past...
    You make it however you want to make it. The more checking you put in, the better it'll be. That's about the size of it.

    By the way am I correct that the maximum size I could make keydata or address to send out or receive throught serial would be byte size, 8bit ,on the 16f628a?
    What does the Figure in the PIC datasheet say?
    And since you're using SERIN and SEROUT, why does it matter?

Similar Threads

  1. Do I need a pause?
    By tazntex in forum Serial
    Replies: 21
    Last Post: - 29th August 2008, 04:32
  2. Oscillator stops when touching with a wire
    By Wilbert Ingels in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 25th April 2008, 08:51

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts