Transmission works with wires but not always with wireless


Closed Thread
Results 1 to 40 of 43

Hybrid View

  1. #1
    Join Date
    Apr 2007
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dhouston View Post
    I would use a 5ms pulse as the preamble and a 20ms pause between data packets (it allows the AGC and threshold to reset).
    On the receiving end I would use PulsIn to wait for the 5ms pulse and then go into the normal receive routine once it's received. Using some type of error detection (e.g. checksum) is a necessity.

    What range do you need? How much data do you need to send?

    Looking at the digital data pin with a 'scope (or recording it with a soundcard as I suggested earlier) can eliminate a lot of guesswork by telling you whether your signal strength is adequate. I find it invaluable.
    Is the code that I wrote below what you are trying to tell me?
    I am only trying to send 4 bits (8 bits encoded). I looked at the digital data pin of the scope and my signal has an amplitude of about 3.72 v.

    Transmit:
    Pulsout PORTB.7, 500
    Pause 20000
    serout PORTB.7, n2400, [$aa,encoded2]
    Pause 20000

    Receive:
    Wait55:
    Pulsin PORTB.0,1,ct55
    If ct55 = 500 Then
    goto Waitaa
    Else
    goto Wait55
    Endif
    'goto Wait55

    Waitaa:
    serin PORTB.0, n2400, encoded1
    If encoded1 <> $aa Then goto Maina
    serin PORTB.0, n2400, encoded1
    write 0, encoded1

  2. #2
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jyi1 View Post
    Is the code that I wrote below what you are trying to tell me?
    I am only trying to send 4 bits (8 bits encoded). I looked at the digital data pin of the scope and my signal has an amplitude of about 3.72 v.
    Code:
    Transmit:
    	Pulsout PORTB.7, 500
    	Pause 20000
    	serout PORTB.7, n2400, [$aa,encoded2]
    	Pause 20000
    
    Receive: 
    Wait55:
            Pulsin PORTB.0,1,ct55
            If ct55 = 500 Then 
               goto Waitaa
            Else
              goto Wait55
            Endif
            'goto Wait55
    Yes, more or less. I would change it to...
    Code:
    Transmit:
    	Pulsout PORTB.7, 500
    	Pause 2500     'shorten space
    	serout PORTB.7, n2400, [$aa,encoded2]
    	Pause 20000
    
    Receive: 
    Wait55:
            Pulsin PORTB.0,1,ct55
            If ct55 < 450 Then Wait55
            goto Waitaa
    The important thing with the signal is that it be clean with no noise pulses interspersed with the data.

    With only 4 bits, I think I would use a variation of the NEC protocol, sending only 1 byte with each code. The NEC protocol has error detection built in so you can discard any corrupted codes. Read the NEC protocol documentation in the link I cited earlier and if you still have questions I'll try to answer them here.

  3. #3
    Join Date
    Apr 2007
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dhouston View Post
    Yes, more or less. I would change it to...
    Code:
    Transmit:
    	Pulsout PORTB.7, 500
    	Pause 2500     'shorten space
    	serout PORTB.7, n2400, [$aa,encoded2]
    	Pause 20000
    
    Receive: 
    Wait55:
            Pulsin PORTB.0,1,ct55
            If ct55 < 450 Then Wait55
            goto Waitaa
    The important thing with the signal is that it be clean with no noise pulses interspersed with the data.

    With only 4 bits, I think I would use a variation of the NEC protocol, sending only 1 byte with each code. The NEC protocol has error detection built in so you can discard any corrupted codes. Read the NEC protocol documentation in the link I cited earlier and if you still have questions I'll try to answer them here.
    I tested out the above code thats included in my code and it does not work by wireless or by wire.

  4. #4
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    I'm not going to try to read your unformatted code or write the entire application but here are code snippets that show you what you need to do. It sends 4 bits both "as is" and as bitwise complement using a variation of the NEC protocol. I've hardcoded the 4 bits of data as 1101. This is adapted from code I use to send and receive 2-4 bytes so the pins are the ones I used. There are more efficient ways to do things but I've tried to show it step-by-step so you see the logic.
    Code:
    '-----Transmit-----
    SendRF: wb.0=data0  '00000001
            wb.1=data1  '00000001 
            wb.2=data2  '00000101
            wb.3=data3  '00001101
            wb=~wb      '11110010
            wb=wb<<4    '00100000
            wb.0=data0  '00100001
            wb.1=data1  '00100001
            wb.2=data2  '00100101
            wb.3=data3  '00101101
            'bits 0-3=data, bits 4-7=~data
            Low 4
    	For c=1 To Copies
    	  PulsOut 4, 500
              PauseUs 2500
    	  For i=0 To 7
    	    PulsOut 4, 50
    	    If wb.0=1 Then
    	      PauseUs 1500
    	    Else
    	      PauseUs 500
    	    EndIf 
    	    wb=wb>>1
    	  Next
    	  PulsOut 4, 50
    	  Pause 20			
    	Next
    
    '-----Receive-----	
    DEFINE PULSIN_MAX = 550
    	
    RcvRF:  PulsIn GPIO.1, 1, STX
            wb=0
            If STX<450 Then RcvRF
            While GPIO.1=0:Wend
            For i = 0 To 7
              PulsIn GPIO.1, 0, space
              If (space<40) Or (space>175) Then RcvRF
              If (space>75) Then
                wb.0=1				
              EndIf
              wb=wb<<1
            Next i	
            comp=wb>>4
            wb=wb & 7
            If wb + comp = 15 Then
              'wb is good data
            Else
              'wb is corrupt
            EndIf
    Last edited by dhouston; - 25th April 2007 at 20:59.

  5. #5
    Join Date
    Apr 2007
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dhouston View Post
    I'm not going to try to read your unformatted code or write the entire application but here are code snippets that show you what you need to do. It sends 4 bits both "as is" and as bitwise complement using a variation of the NEC protocol. I've hardcoded the 4 bits of data as 1101. This is adapted from code I use to send and receive 2-4 bytes so the pins are the ones I used. There are more efficient ways to do things but I've tried to show it step-by-step so you see the logic.
    Code:
    '-----Transmit-----
    SendRF: wb.0=data0  '00000001
            wb.1=data1  '00000001 
            wb.2=data2  '00000101
            wb.3=data3  '00001101
            wb=~wb      '11110010
            wb=wb<<4    '00100000
            wb.0=data0  '00100001
            wb.1=data1  '00100001
            wb.2=data2  '00100101
            wb.3=data3  '00101101
            'bits 0-3=data, bits 4-7=~data
            Low 4
    	For c=1 To Copies
    	  PulsOut 4, 500
              PauseUs 2500
    	  For i=0 To 7
    	    PulsOut 4, 50
    	    If wb.0=1 Then
    	      PauseUs 1500
    	    Else
    	      PauseUs 500
    	    EndIf 
    	    wb=wb>>1
    	  Next
    	  PulsOut 4, 50
    	  Pause 20			
    	Next
    
    '-----Receive-----	
    DEFINE PULSIN_MAX = 550
    	
    RcvRF:  PulsIn GPIO.1, 1, STX
            wb=0
            If STX<450 Then RcvRF
            While GPIO.1=0:Wend
            For i = 0 To 7
              PulsIn GPIO.1, 0, space
              If (space<40) Or (space>175) Then RcvRF
              If (space>75) Then
                wb.0=1				
              EndIf
              wb=wb<<1
            Next i	
            comp=wb>>4
            wb=wb & 7
            If wb + comp = 15 Then
              'wb is good data
            Else
              'wb is corrupt
            EndIf
    If I were to run your code to test it would I code data0=0000001, data1=00000001, data2=00000101, data3=00001101 and then code data0=001000001, data1=00100001, data3=00100101, data3=00101101? Also in the for c=1 to Copies, what is Copies supposed to mean?Also, I discover that when I use my old code and send it through once and view the digital output of the receiver and transmitter input the on the oscilloscope the sequence appears but it does not get picked up by the microcontroller.
    Last edited by jyi1; - 25th April 2007 at 22:26.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jyi1 View Post
    If I were to run your code to test it would I code data0=0000001, data1=00000001, data2=00000101, data3=00001101 and then code data0=001000001, data1=00100001, data3=00100101, data3=00101101? Also in the for c=1 to Copies, what is Copies supposed to mean?Also, I discover that when I use my old code and send it through once and view the digital output of the receiver and transmitter input the on the oscilloscope the sequence appears but it does not get picked up by the microcontroller.
    Call me crazy...but I think between this thread and the other one, you're making the program/process entirely much harder than it needs to be...

  7. #7
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Call me crazy...but I think between this thread and the other one, you're making the program/process entirely much harder than it needs to be...
    OK. You're crazy!

  8. #8
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    data0-data7 represents the 8 bits of the single byte being transmitted.
    Code:
            data.bit0 = 1
            data.bit1 = 0
            data.bit2 = 1
            data.bit3 = 1
            data.bit4 = 0
            data.bit5 = 1
            data.bit6 = 0
            data.bit7 = 0
    Copies means the number of times the transmission is repeated. You will need to experiment. If you always have a strong signal you might get by with a single copy; a weaker signal will require additional copies to set the receiver AGC and threshold. Most X-10 RF transmitters send 5 copies.

    What I usually do on the receiving end is report the first valid code and then only report subsequent codes if they differ - with a time limit based on the time required to send the five (or whatever) copies.

  9. #9
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jyi1 View Post
    If I were to run your code to test it would I code data0=0000001, data1=00000001, data2=00000101, data3=00001101 and then code data0=001000001, data1=00100001, data3=00100101, data3=00101101?
    You said you are sending 4 bits of data. My example was intended to show you how to send the 4 bits twice in two different ways. One way is "as is" in the lower 4 bits of wb; the other way is as the bitwise complement of the 4 data bits in the upper 4 bits of wb. Sending it in two forms allows us to check for errors on the receiving end.

    Assuming you want to send %1101...
    Code:
    data=%1101
    wb=data
    wb=~wb
    wb=wb<<4        'bitwise complement %0010 in upper 4 bits 
    wb=wb+data      'data "as is" in lower 4 bits
    The attached GIF shows the waveform for data=%1101.
    Attached Images Attached Images  
    Last edited by dhouston; - 26th April 2007 at 13:18. Reason: Replaced the GIF - original had bit order reversed

Similar Threads

  1. Wireless Tachometer - Design Help
    By DanPBP in forum Off Topic
    Replies: 2
    Last Post: - 3rd May 2009, 09:06
  2. RS485 Vs Wireless (TWS-434A)
    By koossa in forum Off Topic
    Replies: 3
    Last Post: - 11th April 2009, 12:40
  3. Serial Wireless
    By mackrackit in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th May 2007, 16:06
  4. Serial comm - are 2 wires for TX only enough?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 30th August 2006, 03:23
  5. RS 485 wireless communication
    By Armadus in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 26th January 2006, 19:30

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