Controlling the Linx Technologies FCTN-RLY4-XXX Receiver From Your PC

The FCTN-RLY4-XXX receiver/relay module, when paired with the CMD-HHLR-XXX hand-held RF transmitter, offers an excellent solution for remote control of up to 4 relays with the hand-held remote.

Note: The XXX in Linx LR series RF module part numbers refer to the operating frequencies. These RF modules are available in frequencies of 315, 418, and 433MHz. Which one you choose depends on where you are located, and which frequency is acceptable in your area. They ALL work equally well for this application.

This article will show you how to control the FCTN-RLY4-XXX receiver/relay module from your PC with just a few inexpensive components. The applications for this are HUGE since it allows you to remotely control just about anything you can control with the Linx FCTN-RLY4-XXX receiver modules directly from our PC VS using the hand-held remote control transmitter. You're really only limited by your imagination with this one.

Applications include; automated remote control of equipment in your shop, home, or business, all controlled by your PC, at specific designated ON/OFF times.

The Holtek 8-Bit Encoder/Decoder ICs:

The CMD-HHLR-XXX transmitter and FCTN-RLY4-XXX receiver/relay module both use the Holtek 8-bit series encoder & decoder ICs. So we'll first look at how these ICs are wired, and how they operate, in both units.

The CMD-HHLR-XXX Transmitter:

Figure #1 below shows the keypad layout. Keys are connected internally to the Holtek HT-640 IC data input pins D0 through D7. Pressing D0 on the keypad places a logic 1 on the encoders ICs D0 pin, and on the encoders TE (transmit enable pin) through the diode. The purpose of the diodes shown in the schematic HERE are to provide a logic 1 on the encoders TE pin, which causes it to transmit.

On key release, the encoders TE pin is pulled to ground through the 100K pull-down resistor, which ends the transmission.


Figure #1 CMD-HHLR-XXX RF Transmitter

We're going to replace the CMD-HHLR-XXX hand-held transmitter with just a few parts, and interface the new transmitter circuit to the PC.

The FCTN-RLY4-XXX Receiver/Relay Module:

Now that we know how the transmitter works, let's look at how the receiver/relay module works, how the 8-bit Holtek decoder inside it is wired for operation, and how this all affects operation of the FCTN-RLY4-XXX receiver/relay module.

Before moving on, please download the FCTN-RLY4-XXX receiver/relay module data sheet HERE

Figure #2 below shows the FCTN-RLY4-XXX address DIP switch. This is used to set the address of the HT-658 Holtek 8-bit decoder inside the receiver/relay module.

Note that the address set with this DIP switch must match the exact address set on the CMD-HHLR-XXX transmitter - or the receiver will simply ignore all data received from the transmitter.


Figure #2 FCTN-RLY4-XXX Address DIP Switch

Figure #2 above shows the address DIP switch on the FCTN-RLY4-XXX. Note that the receiver only has 8 switches. Figure #3 below shows the transmitter address DIP switch. The transmitter has 10 address switches.


Figure #3 CMD-HHLR-XXX Address DIP

This is important since the address of both transmitter & receiver must match exactly or the receiver will simply ignore all data received. On the receiver, address pins A8 and A9 on the Holtek decoder IC are left floating. So the A8 and A9 DIP switches on the transmitter must always be in the OFF position for address pins A8 and A9 on the encoder to float.

Look at Figure #4 below for an example of how the FCTN-RLY4-XXX address DIP switch physically connects to the HT-658 decoder IC.

Take special note that the address DIP switch does NOT connect any address input pins to Vcc. Only ground or open. The 8-bit Holtek encoder/decoders address pins are tri-state, which means the address pins can be connected to Vcc, ground, or left floating (not connected).


Figure #4 HT-658 Decoder Address DIP Switch Connections

As mentioned above, the HT-658 decoder address pins A8 and A9 are not connected to the address DIP switch. The pins are left floating and this requires a special code from the 8-bit encoder that tells the decoder these address pins are floating. The 8-pin encoder we have created specifically for this project handles this for you.

What Turns Relays ON/OFF?:

In Figure #5 below you'll see a photo of the Linx CMD-HHLR-XXX hand-held transmitter. When used with the Linx FCTN-RLY4-XXX relay/receiver modules, the green buttons to the right are for ON. The red buttons to the left are for OFF, for each of the 4 relays on the FCTN-RLY4-XXX modules.


Figure #5 CMD-HHLR-XXX Transmitter

Figure #6 below shows relay connections. Relay #1 is on the left, relay #4 is on the right, just before the power supply input connections marked GND and 5-16VDC.


Figure #6 FCTN-RLY4-XXX Relay Connections

The top green button, on the right, of the CMD-HHLR-XXX, turns ON relay #1. The left red button turns relay #1 OFF. Each corresponding ON/OFF buttons from top down, turns ON/OFF the other 3 relays.

The actual 8-bit binary codes for DATA transmitted on each button press on the CMD-HHLR-XXX are;

OFF 1 = 128 A binary value of 10000000 
ON  1 = 64  A binary value of 01000000
OFF 2 = 32  A binary value of 00100000
ON  2 = 16  A binary value of 00010000
OFF 3 = 8   A binary value of 00001000
ON  3 = 4   A binary value of 00000100
OFF 4 = 2   A binary value of 00000010
ON  4 = 1   A binary value of 00000001

For an understanding of the 8-bit Holtek encoders data structure, download this .PDF document

Notice how data being sent varies depending on the logic state of pins at logic 0, logic 1, and floating.

What we need now is something that can;

bullet

Provide the physical interface between our RF transmitter & PC by a USB interface.

bullet

Provide a minimum of +3V DC power for the encoder IC + RF transmitter module.

bullet

Convert data received from the PC to control the FCTN-RLY4-XXX, which emulates the Holtek 8-bit encoder IC in the CMD-HHLR-XXX transmitter.

bullet

PC software to control our new transmitter circuit.

The PC USB Interface:

The easiest solution for the PC interface now days is to go with a USB to Serial converter. Most new PCs' do not have a serial port, so the USB to Serial converter is the way to go. Figure #7 shows a simple cable, which connects to your PCs' USB port, and provides TTL level signals to your external hardware that appears to be a serial port on your PC.

It also provides POWER from the USB port to our external circuit, so we don't need a separate power supply.

The BIG advantage here is that you can use pretty much any serial terminal application to communicate with your external device. The drivers for this cable create a Virtual Serial Port so it looks like a serial port as far as your PC is concerned, and not a USB connection.


Figure #7 TTL-232R-3V3 Converter Cable

These cables are available from the following distributors for around $20.00 each;

bullet

http://www.digikey.com part #768-1015-ND

bullet

http://www.mouser.com part #895-TTL-232R-3V3

Be sure to get the 3.3V version cable. The PIC and LR series transmitter operate from the regulated 3.3V of the LP2950CZ-3.3G low-power regulator. The TTL-232R-3V3 converter cable cable will output data at 3.3V logic levels on pin #4 to the PIC12F609, which is required with the PIC running from the 3.3V regulated supply.

On To The Hardware Interface:

The circuit has been kept as simple as possible to reduce the parts count, and make it inexpensive to build.

The LP2950 3.3V regulator can be replaced with any 3.3V regulator with similar specs, and the Linx surface mount TXM-XXX-LR-S transmitter modules can replace the TXLC-XXX-LR pinned modules making the whole circuit extremely inexpensive.

Connections in Figure #8 below show the TTL-232R-3V3 converter cables 6-pin black header. #1 is circuit ground. #3 is +5V output from the converter cable, which provides power to the LP2950 3.3V regulator. #4 is serial data output from the cable, which sends data to the PIC12F609.


Figure #8
RF transmitter, encoder, and PC Interface circuit

The PC Software:

The PC software was created with Visual Basic 6 pro version. Of course, any serial terminal program can also be used since the PIC encoder can accept serial data from any software running on your PC that can send serial data. I'll give an example of using a free serial terminal software program below.

ALSO NOTE: Any microcontroller that can send serial data, in non-inverted mode, can also be used to control the PIC12F609 used in this project. It does not necessarily have to be connected to a PC.


Figure #9 VB Control Software Interface

The Visual Basic 6 code is available for download free of charge below in a .ZIP file. It's very simple stuff, but I'll show how it works here with a few explanations on why certain values are sent with button-click routines, and explain why the 3rd byte is always 3. And how we deal with floating address bits.

If you remember, from above, the Holtek encoder on the CMD-HHLR-XXX transmitter required that the upper 2-bits of the address pins were left open by opening DIP switches A8 and A9. This matches the upper 2-bits on the FCTN-RLY4-XXX receiver module since it only has an 8-position address DIP switch. So - address pins A8 and A9 were left floating.

The little 8-pin PIC12F609 that replaces the HUGE 24-pin Holtek HT640 encoder can't recognize a floating value. It deals only with logic values, which are either a 1 or 0.

So - the PIC12F609 encoder expects to either see a 1 (floating) or 0 (ground) for address bits. And the upper 2-bits of the 10-bit encoder/decoder address will always be floating. Since we effectively lose these 2 upper bits of the 10-bit address, the VB software Address combo box only supports an address value from 0 to 255.

The upper 2-bits of the 10-bit address are always 11, which = 3 in binary. Note that all data sent from the encoder, to the decoder, is sent LSB first, which means these upper 2-bits are sent last to complete the full 10-bit address.

Clicking button #1 ON, will send 4 bytes total. The 1st byte sent is the capital letter A, which is used to synchronize the inbound data from the PC to the PIC12F609 receiving this data. The 2nd byte is the value of the address combo box, which represents the encoder/decoder address from 0 to 255.

The 3rd byte is always the number 3, which the PIC12F609 interprets as the high-2-bits of the 10-bit address. So - a 1 address bit = a floating address pin, and a 0 address bit = 0.

In short - we're dealing with a floating address bit, or a ground address bit. Never a 1 logic bit since the FCTN-RLY4-XXX decoder has no connections from Vcc to any address pins.

If you look at the Holtek encoders data structure .PDF document again, you'll see how this works. No address pins on the decoder, inside the FCTN-RLY4-XXX, are ever connected to Vcc, so we need to send the appropriate bit timing for;

bullet

A logic 0

bullet

A floating input

Clicking 1 ON, on the VB interface, sends this;

Private Sub cmdD0ON_Click()
Address = Combo1.Text
MSComm1.Output = "A" & Chr$(Address) & Chr$(3) & Chr$(64)
End Sub

Clicking 1 OFF, on the VB interface, sends this;

Private Sub cmdD0OFF_Click()
Address = Combo1.Text
MSComm1.Output = "A" & Chr$(Address) & Chr$(3) & Chr$(128)
End Sub

If you scroll back up to the binary DATA codes sent, just below Figure #6, you'll see why this works. And you'll understand how the remainder of the ON/OFF, ALL/ON, and ALL/OFF buttons work.

The ALL OFF button sends 128 + 32 + 8 + 2, which = 170 total. Like this;

Private Sub CmdAllOff_Click()
Address = Combo1.Text
MSComm1.Output = "A" & Chr$(Address) & Chr$(3) & Chr$(170)
End Sub

The ALL ON button sends 64 + 16 + 4 + 1, which = 85 total. Like this;

Private Sub CmdAllOn_Click()
Address = Combo1.Text
MSComm1.Output = "A" & Chr$(Address) & Chr$(3) & Chr$(85)
End Sub

Note that when you start the VB control software, it does NOT automatically open any PC comm port. You will need to select the comm port your circuit is attached to like shown below in Figure #10.


Figure #10 Selecting the Communications Port

Just doesn't get any easier...;o)

Important Note:

The free VB application software offered here has been tested up to Windows XP. I can't guarantee it will work with any version of Windows beyond XP. If you're a Windows programmer, and you would like to submit an application with VB.Net - or any other PC program that can replicate this application, we would be happy to post it here with this project.

If you aren't using an OS that works with the free VB6 application, not to worry. Below I'll show you how to control the PIC12F609 & FCTN-RLY4-XXX module with a FREE serial terminal program.

Controlling The FCTN-RLY4-XXX With MCS Terminal Program:

You can download the free version of MicroCode Studio HERE that include a very handy serial terminal program. Install the software, then start it, and open the serial terminal window by clicking View, then Serial Communicator.

Select the comm port your transmitter circuit is attached to, select 9600 as the baud rate, then click the Connect icon.

To turn ON relay #1, enter A#0#3#64, then click the Send button on the right.

To turn OFF relay #1, enter A#0#3#128, then click the Send button on the right.

Notice from both examples above that the capital letter A always precedes data. The next value #0 = the receivers address. This assumes all address DIP switches on the FCTN-RLY4-XXX are set to ON or grounded. The #3 is for the upper 2-bits of the 10-bit address, which are always floating, and should always be this value.

The 4th, and final value = the relays ON or OFF status. So you don't have to scroll way back up below Figure #6, I'll include the ON/OFF codes again here for you.

OFF 1 = 128 A binary value of 10000000 
ON  1 = 64  A binary value of 01000000
OFF 2 = 32  A binary value of 00100000
ON  2 = 16  A binary value of 00010000
OFF 3 = 8   A binary value of 00001000
ON  3 = 4   A binary value of 00000100
OFF 4 = 2   A binary value of 00000010
ON  4 = 1   A binary value of 00000001

So - you can use pretty much any free serial terminal program out there, that supports your particular operating system, to control the FCTN-RLY4-XXX with the RF transmitter & encoder circuit shown here.

Controlling With Another Embedded Controller:

You can also control this 8-pin encoder with a BASIC Stamp, PIC, or anything else that can send the required 4 bytes of serial data. You're not limited to just using a PC.

NOTE: You can also control the Linx Technologies RXD-XXX-KH2 receiver/decoder modules with this project since the KH2 receivers use the 8-bit Holtek decoder ICs.

Visual Basic 6 PC Control Software:

bullet

FREE Visual Basic 6 application software HERE

Parts Kit: We offer a 2-piece parts kit HERE

PicBasic Pro source code for the 12F609:

'****************************************************************
'*  Name    : PC_RF.BAS                                         *
'*  Author  : B. Reynolds                                       *
'*  Notice  : Copyright (c) 2010 Reynolds Electronics           *
'*          : All Rights Reserved                               *
'*  Date    : 03/21/2010                                        *
'*  Version : 1.0 (final version)                               *
'*  Notes   : 8-pin serial encoder to replace HT640 Holtek IC   *
'*          : Using the PIC12F609                               *
'****************************************************************
 
@ DEVICE PIC12F609, MCLR_OFF, IOSCFS_4MHZ, XT_OSC, WDT_OFF, BOD_OFF, PROTECT_ON 

    DEFINE OSC 4            ' 4MHz intrc osc
    DEFINE DEBUGIN_REG GPIO ' Define port
    DEFINE DEBUGIN_BIT 1    ' Define port pin
    DEFINE DEBUGIN_MODE 0   ' 0=true, 1=inverted (use true through MAX232)
    DEFINE DEBUG_BAUD 9600  ' 9600 bps

    ADDRESS  VAR WORD ' Holds 10-bit address
    DAT_OUT  VAR BYTE ' Holds 8-bit data byte
    BITS     VAR BYTE ' Bit index for address & data bit pointer
    LOOPS    VAR BYTE ' Loop var for encode routine
    
    ' Use this timing for a Holtek HT640 @3V, 390K osc resistor
    'LONGB    CON 732    ' 732uS for long bit & inter-bit delay
    'SHORTB   CON 382    ' 382uS for short bit & inter-bit delay
    
    ' Use this timing for a Holtek HT640 @5V, 390K osc resistor
    LONGB    CON 861    ' 861uS for long bit & inter-bit delay
    SHORTB   CON 431    ' 431uS for short bit & inter-bit delay
    
    SYMBOL  E_OUT=GPIO.0   ' Assign encoder data out (to RF module) pin here
    
    ' Bank 1 Hardware initialization
    ANSEL = 0	        ' Set all I/O to digital
    WPU = 0             ' Internal pull-ups off
    OPTION_REG = 128    ' Pull-ups = off, GPIO.2 = I/O, prescaler to Timer1
    TRISIO=%00001010    ' GPIO.0 RF out, GPIO.1 serial input, GPIO.33 inputs
    
    ' Bank 0 Hardware initialization
    GPIO=%00000000      ' All outputs low on boot
    CMCON0 = 0          ' Comparators OFF
    E_OUT = 0           ' Data output low to disable RF transmitter on boot
    
    ' sending A#2#3#64 with MCS terminal turns ON relay #1 at address #2
    ' #3 is sent since the FCTN-RLY4-xxx has the upper 2 address bits of the
    ' 10-bit decoder address left open (floating).
MAIN: 
    DEBUGIN 5000,MAIN,[WAIT("A"),ADDRESS.LOWBYTE,ADDRESS.HIGHBYTE,DAT_OUT] 
      
ENCODE_640:
    FOR LOOPS = 1 TO 8 ' 8 data packet bursts per transmit period
    '                    to simulate user button presses.        |
    ' now do synch period & synch bits      _   __    _   __    _|
        HIGH E_OUT : PAUSEUS SHORTB '      | | |  |  | | |  |  | |
        LOW E_OUT  : PAUSEUS SHORTB '      | | |  |  | | |  |  | |
        HIGH E_OUT : PAUSEUS LONGB  '      | | |  |  | | |  |  | |
        LOW E_OUT  : PAUSEUS LONGB  '      | | |  |  | | |  |  | |
        HIGH E_OUT : PAUSEUS SHORTB '      | | |  |  | | |  |  | | ADDRESS | DATA
        LOW E_OUT  : PAUSEUS SHORTB '      | | |  |  | | |  |  | | 10-BIT  | 8-BIT
        HIGH E_OUT : PAUSEUS LONGB  '      | | |  |  | | |  |  | |
        LOW E_OUT  : PAUSEUS LONGB  ' 14mS | | |  |  | | |  |  | |
        HIGH E_OUT : PAUSEUS SHORTB '_____ | |_|  |__| |_|  |__| |
    '                                             SYNCH BITS     |
    ' now encode/send address
    FOR BITS = 0 to 9  ' send 10-bit address
        IF ADDRESS.0[BITS] = 1 THEN     ' a 1 indicates the address bit is floating. NOT 1
            LOW E_OUT  : PAUSEUS LONGB
            HIGH E_OUT : PAUSEUS SHORTB 
            LOW E_OUT  : PAUSEUS SHORTB 
            HIGH E_OUT : PAUSEUS LONGB 
        ELSE
            LOW E_OUT  : PAUSEUS SHORTB
            HIGH E_OUT : PAUSEUS LONGB
            LOW E_OUT  : PAUSEUS SHORTB
            HIGH E_OUT : PAUSEUS LONGB
        ENDIF
    NEXT BITS
    
    ' now encode/send data
    FOR BITS = 0 to 7  ' 8-bit data
        IF DAT_OUT.0[BITS] THEN
            LOW E_OUT  : PAUSEUS LONGB
            HIGH E_OUT : PAUSEUS SHORTB
            LOW E_OUT  : PAUSEUS LONGB
            HIGH E_OUT : PAUSEUS SHORTB
        ELSE
            LOW E_OUT  : PAUSEUS SHORTB
            HIGH E_OUT : PAUSEUS LONGB
            LOW E_OUT  : PAUSEUS SHORTB
            HIGH E_OUT : PAUSEUS LONGB
        ENDIF
    NEXT BITS
    LOW E_OUT       ' start synch period @ start of 2nd data packet
    PAUSE 14        ' 14mS to 15mS synch period
    NEXT LOOPS      ' Close loop
    LOW E_OUT       ' Disable transmitter (turn off carrier)
    GOTO Main
    
    END,

The Linx Technologies LR modules, FCTN-RLY4-XXX, and RXD-XXX-KH2 receiver/decoder modules are available from our Remote Control Store HERE.

Regards,

Until the next project -- Have fun & don't blow anything up...;o]

Regards,

-Bruce

Click HERE For
Remote Control Store
We have the majority of the parts for this project in stock.