Transmission works with wires but not always with wireless


Results 1 to 40 of 43

Threaded View

  1. #31
    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.

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