Using Linx RF modules ?


Closed Thread
Results 1 to 21 of 21

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    I would use the transmitter & receiver code shown in the first two sections atIt uses the same protocol that X-10 has used successfully for 30 years. It can handle up to 256² codes and has built-in error detection.
    Last edited by dhouston; - 22nd August 2009 at 22:17.

  2. #2
    Join Date
    Mar 2004
    Posts
    92


    Did you find this post helpful? Yes | No

    Default

    That looks great, I will study it (more) and give it a try.

    Thanks for all your help Dave !

    Sam

  3. #3
    Join Date
    Mar 2004
    Posts
    92


    Did you find this post helpful? Yes | No

    Default

    Dave,

    I've loaded your TX code into one 12F675 and connected to the Linx TX and it is transmitting data. ( I changed the interval from 15 seconds to 1.5 seconds)

    I then loaded your RX code as seen below into another 12F675 and I'm not getting anything out of GPIO.2. I connected a LED to the data out of the receiver and it does flash in sync with the TX data going out.

    I connect GPIO.2 of the RX PIC to Hyperterminal set at 8N1, 9600 and get nothing at all and I connected an LED to GPIO.2 and nothing there either.

    Shouldn't I be getting something on the RX PIC ?

    Code:
    
    '==============================RECEIVER============================	
    '-----PIC12F675-----
    'USE PIC12F675 if you need to measure linear output (e.g. to tune) 
    'Receives 32 bits of NEC protocol RF with initial lead-in of 8.8mS
    'outputs received codes via RS232 @ 9600bps on GPIO.2
    
    '12F675
    _CONFIG
    @ DEVICE PIC12F675
    _NOCLKOUT  
    _WDT_ON 
    _PWRTE_ON
    _MCLRE_OFF
    _BODEN_ON
    DEFINE OSC 4
    INCLUDE "modedefs.bas"
    
    DEFINE PULSIN_MAX 968				'>968 RETURNS 0
    DEFINE DEBUG_REG GPIO
    DEFINE DEBUG_BIT 2 				'GPIO.2
    DEFINE DEBUG_MODE 1 				'Inverted
    DEFINE DEBUG_BAUD 9600
    DEFINE OSCCAL_1K 1
    
    RF      VAR     byte[4]
    space   VAR     byte
    i       VAR     byte     
    bits	VAR	byte  	         	
    stx  	VAR     word            		'start of transmission
    
            CMCON = 7                       	'comparators off
    
    init:	RF[0]=0:RF[1]=0:RF[2]=0:RF[3]=0
    	bits=0:i=0
    	PulsIn GPIO.1, 1, stx			
    	If (stx<792) Then init                   
            While GPIO.1=0:Wend			'wait pulse
            'use SerIn here instead of Repeat loop & $FF tests
            Repeat
              PulsIn GPIO.1, 0, space
              If (space<40) Or (space>175) Then init
              If (space>75) Then
                RF.0(i)=1				'set bit
              EndIf
              i=i+1 
            Until (i>31)
    	If RF[0]+RF[1]<>$FF Then init
    	If RF[2]+RF[3]<>$FF Then init        
            For i = 0 to 3
      	  Debug (RF[i] REV 8)
            Next           
            GoTo init
    
            End

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


    Did you find this post helpful? Yes | No

    Default

    Give me a day or two to finish something else and dig out my PIC hardware and I'll try to run this down.

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


    Did you find this post helpful? Yes | No

    Default

    I apologize for the delay. I have a spinal cord injury which incapacitates me when it acts up and it's been acting up for several days. What follows is revised slightly from the earlier code. I have not tested this with a terminal program (right now I'm working with Linux and do not have a terminal program handy) but I have looked at the GPIO.2 output with a 'scope and it appears to be a valid RS232 signal. Here's the transmit code:
    Code:
    '-----PIC12F629-----
    ' Sends 2 bytes + their bitwise complements using the NEC protocol
    ' repeats every 15 seconds
                         
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
     
    DEFINE OSCCAL_1K 1
     
    RF 	VAR	byte[4]
    Copies 	VAR	byte			'RF copies 
    c	VAR	byte			'loop index (RF copies)
    b	VAR	byte			'loop index (RF[b])
    i	VAR	byte			'bit index
    wb	VAR	byte                    'work byte
    
            CMCON = 7	
            Copies = 4       
            'Put data in RF[0] & RF[2] & complement in RF[1] & RF[3] 
    SendRF:	RF[0]=80:RF[1]=~RF[0]:RF[2]=66:RF[3]=~RF[2]
    	Low GPIO.2
    	For c=1 To Copies
    	  PulsOut GPIO.2, 880           '8.8mS pulse
              PauseUs 4400                  '4.4mS space
    	  For b=0 To 3
                wb=RF[b]
    	    For i=0 To 7                'LSB first
    	      PulsOut GPIO.2, 50        '0.5mS pulse
    	      If wb.0=1 Then
    	        PauseUs 1500            '1.5mS space 
    	      Else
    		PauseUs 500             '0.5mS space
    	      EndIf 
    	      wb=wb>>1
    	    Next
    	  Next
    	  PulsOut GPIO.2, 50            '0.5mS pulse
    	  Pause 40:                     '40mS GAP
    	Next
    	Pause 15000                     '15 SEC DELAY
    	GoTo SendRF
    	
            End
    and here is the receiver code:
    Code:
    '12F629
    
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
    
    DEFINE PULSIN_MAX 968				'>968 RETURNS 0
    DEFINE DEBUG_REG GPIO
    DEFINE DEBUG_BIT 2				'GPIO.2
    DEFINE DEBUG_MODE 1 				'Inverted
    DEFINE DEBUG_BAUD 9600
    DEFINE OSCCAL_1K 1
    
    RF      VAR     byte[4]
    space   VAR     byte
    i       VAR     byte	         	
    stx     VAR     word            	'start of transmission
    
            CMCON = 7                   'comparators off
            Debug "RF NEC PROTOCOL"
    init:   RF[0]=0:RF[1]=0:RF[2]=0:RF[3]=0:i=0
            PulsIn GPIO.1, 1, stx	
            If (stx<792) Then init  		
            'debug #stx                 
            While GPIO.1=0:Wend			'wait pulse
            Repeat
              PulsIn GPIO.1, 0, space
              If ((space<40) Or (space>180)) Then init
              If (space>75) Then
                RF.0(i)=1				'set bit
              EndIf
              i=i+1 
            Until (i>31)
            If (RF[0]+RF[1]<$FF) Then init		'corrupt
            If (RF[2]+RF[3]<$FF) Then init		'corrupt
            RF[1]=RF[0] REV 8
            RF[3]=RF[2] REV 8
            Debug RF[1],32,RF[3]
            GoTo init
    
            End

  6. #6
    Join Date
    Mar 2004
    Posts
    92


    Did you find this post helpful? Yes | No

    Default

    Hi Dave,

    I'm sorry to hear about your spinal chord injury ! I know a little about that personally also, unfortunately.

    Thanks for posting the code re-done, in the meantime I went ahead and ordered some encode/decode chips from Rentron and they work excellent. I am extremely impressed by the range and reliability of this combination of Linx modules and these chips.

    I did get a machine "status system" set up with the TX/encoder mounted in a small project box with a real whip antenna mounted on the top of my milling machine. When a section of the machine moves to a specific location, a button is pressed and that activates a 12F675 that turns on the TX and it transmits for .5 sec. then turns off for .3 sec., it does this 15 times with a "for/next" routine then goes to sleep until next time.

    The receiver is in a very small project box that resembles a pager with the option of either a beep or flashing an LED. This tells me when the machine is ready for a tool change.

    I'll give your new code a try soon, I want to have more status reports for other components of the machine sent to a receiver with an LCD display.

    Thanks for the help and hope you're doing well now.

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


    Did you find this post helpful? Yes | No

    Default

    Sam,

    I've added a more generic RF Receiver example to the Code Examples forum.

Similar Threads

  1. RF Modules (Zigbee)
    By Chris Barron in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 4th March 2010, 18:28
  2. Linx RXM-900-HP3 Rf Modules
    By Steve_88 in forum Off Topic
    Replies: 1
    Last Post: - 3rd June 2008, 15:58
  3. RF Transceiver modules help
    By davewanna in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th May 2008, 14:54
  4. Help with CC1100 RF Modules.
    By charudatt in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 27th November 2006, 20:58
  5. Wireless comms with Linx LR modules
    By telemark in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 2nd July 2006, 01:58

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