RF Remote Control & Infrared Navigation


 Back To Index

This project uses infrared for autonomous navigation together with RF remote control. We'll use the Ming 4-button TX-99K4A transmitter, Ming RE-99 receiver, and Holtek HT-12D decoder IC. Three primary components required for the RF remote control are shown below.


The TX-99K4A 4-Button RF Transmitter


The Holtek 4-Bit Decoder IC


The Ming RE-99 V3.0A RF Receiver

The TX-99K4A transmitter uses the Holtek HT-12E 4-bit encoder IC, so we'll need the matching Holtek HT-12D decoder IC for the receiver circuit. The Ming RE-99 300MHz RF receiver module operates at the same frequency as the TX-99K4A, so we have a perfect match between transmitter & receiver. The CD-ROM has datasheets for the TX-99K4A Schematic , TX-99K4A DatasheetHT-12D, and Ming RE-99 in Adobe .PDF format.

Project Goal:

Micro-Bot will begin exploring the environment using infrared sensors for obstacle avoidance. He will continue to roam until a button is pressed on the remote transmitter. Commands from the remote control unit will take precedence over any autonomous operations. Once the transmitter ends the transmission, Micro-Bot will be released to resume autonomous operation.

Micro-Bot will be programmed to read the 4-bit data patterns on the outputs of the HT-12D decoder IC in the RF receiver circuit. These 4-bit binary data patterns will cause program execution within the Check_Remote sub-routine to alter Micro-Bots direction of travel or command him to stop. This gives us a way to remotely control Micro-Bot should he wander too far off course or get into trouble. He will navigate on his own using the infrared sensor until we decide to take remote control of him.

Below are the infrared circuits used for several other projects. If you have these already constructed, then move on to the RF section. If not, construct both circuits as shown below.


Infrared LED Drive Circuit


Infrared Detector Circuit

The Decoder IC:

The HT-12D decoder IC has four latching data outputs, and one momentary output. The 4-bit data pattern on output pins D0-D3 will latch, and stay at the last transmitted 4-bit value until we press another button on the transmitter sending a different 4-bit logic pattern.

Note: We can't use output pin D3 of the HT-12D. The TX-99K4A transmitter does not change this bit. As shown below in Figure#1, the HT-12E encoder inside the TX-99K4A does not have a switch connected to data input pin #13 or D3.

Switch SW-1 [button A] connects to D2, SW-2 [button B] connects to both D1 and D2, SW-3 [button C] to D1, and SW-4 [button D] to D0. There are no switch connections to D3.


Figure #1 Partial TX-99K4A Schematic

It's not shown in the partial schematic in Figure #1, but when any button is pressed power is supplied to the encoder circuit initiating the transmission of data. Releasing a button ends the transmission by removing power from the HT-12E encoder.

At the receiver end the decoders VT output pin idles at logic 0. When a transmission from an encoder with the same address as the decoder is being received, the decoders VT output will transition from ground to +5V during the transmission. When we release the transmitter button and end the transmission, VT returns to ground. Hence, VT gives us a momentary bit to use with the 3 latching data bits.

We'll sample the decoders VT output with PortA3 looking for logic 1 or +5V. If the VT output is logic 1 we'll jump to a sub-routine named Check_Remote to read the 4-bit binary value present on the decoders latching outputs D0, D1, D2 and the momentary VT output. Within the Ckeck_Remote sub-routine we'll determine which button on the TX-99K4A transmitter is being pressed, and alter Micro-Bots direction or command him to stop if Button D is being pressed.

To control Micro-Bot with the TX-99K4A remote transmitter, we'll want at least four basic control functions or commands. We'll assign each the of the transmitter buttons a single function as follows --:
 

  1. Button A = Reverse

  2. Button B = Left

  3. Button C = Right

  4. Button D = Stop

Whoa..! Where's forward..? We'll make forward the default direction if the VT output is idle or logic 0 since this condition indicates we're not pressing any of the transmitter buttons. This turns control back over to Micro-Bot for autonomous operation each time we release the transmitter buttons. I.E. Micro-Bot can continue on his own using his onboard IR sensor for exploration. Our program code will occasionally check the status of the VT output connected to PortA.3 for logic 1 to determine if any buttons on the transmitter are being pressed. If VT=0 Micro-Bot will ignore the Check_Remote sub-routine.

If a button is pressed PortA.3 [aliased as VT] will be logic 1, and we jump to Check_Remote, determine the button that's being pressed, and execute the command assigned to that specific button.

Data Patterns:

As mentioned previously, the TX-99K4A transmitter has four buttons labeled A, B, C and D. The four data outputs of the HT-12D decoder will provide the following data patterns corresponding to each button press on the TX-99K4A --:
 
Transmitter Button A B C D
HT-12D Data Pin D3 D2 D1 D0 D3 D2 D1 D0 D3 D2 D1 D0 D3 D2 D1 D0
Binary Logic Value 1 1 0 0 1 1 1 0 1 0 1 0 1 0 0 1

Table #1

Knowing these data patterns Micro-Bot can easily determine which button is being pressed, and quickly react to each command from the transmitter.

The Receiver Schematic:

Below is the receiver schematic. The data output pin of the Ming RE-99 RF receiver connects to the HT-12D decoder IC pin #14. Power for the receiver module is provided by Micro-Bots regulated +5V & ground. You can wire this circuit on the Micro-Bot bread board or directly onto the circuit board.

Once you have the infrared & RF receiver circuits assembled, program the code below into Micro-Bot. Notice how we have modified the include file, and saved it with the name REMOTE.INC.
'****************************************************************
'*  Name    : IR_RC.BAS                                         *
'*  Author  : Bruce Reynolds                                    *
'*  Notes   : Micro-Bot Infrared Nav & RF Remote Control        *
'****************************************************************
INCLUDE "REMOTE.INC"

Remote    VAR BYTE  ' Holds data read from decoder outputs on PortA
                    
Begin:
  GOSUB Check_Right    ' Check right side for obstacle
  GOSUB Check_Left     ' Check left side for obstacle
  IF VT=1 THEN Check_Remote ' If VT = active, check remote command    
  IF (Left_IR=No) AND (Right_IR=No) THEN Continue ' If no contact skip further checking
  IF (Left_IR=Yes) AND (Right_IR=Yes) THEN Back ' If contact on both sides then reverse
  IF (Left_IR=Yes) AND (Right_IR=No) THEN Right ' If contact on left then turn right
  IF (Left_IR=No) AND (Right_IR=Yes) THEN Left  ' If contact on right then turn left

Continue:
  FOR X=1 TO 2                      ' Begin forward motion loop here
   PULSOUT Left_Servo,ForwardLeft   ' Forward left servo
   PULSOUT Right_Servo,ForwardRight ' Forward right servo
   PAUSE 20		
  NEXT
  GOTO Begin

Back:               ' Backwards
  FOR X=1 TO 4	 
   PULSOUT Left_Servo,ReverseLeft   ' Reverse left servo
   PULSOUT Right_Servo,ReverseRight ' Reverse right servo
   PAUSE 20     
  NEXT           
  GOTO Begin      ' Return to Begin routine

Right:            ' Turn right
  FOR X=1 TO 4   
   PULSOUT Left_Servo,ForwardLeft  ' Forward left servo
   PULSOUT Right_Servo,ReverseRight  ' Reverse right servo
   PAUSE 20
  NEXT            
  GOSUB Check_Right
  IF Right_IR=Yes THEN Right
  GOTO Begin      ' Return to Begin routine
    
Left:             ' Turn left
  FOR X=1 TO 4    
   PULSOUT Left_Servo,ReverseLeft  ' Reverse left servo
   PULSOUT Right_Servo,ForwardRight ' Forward right servo
   PAUSE 20
  NEXT            
  GOSUB Check_Left
  IF Left_IR=Yes THEN Left
  GOTO Begin      ' Return to Begin routine

Check_Remote:
  Remote=PortA & $0F ' Read PortA and mask out upper four bits
  SELECT CASE Remote                  ' Stay here until Button D is released
         CASE ButtonD
              GOTO Check_Remote
         CASE ButtonA                 ' Reverse
              FOR X=1 TO 4	         
	           PULSOUT Left_Servo,ReverseLeft   ' Reverse left servo
	           PULSOUT Right_Servo,ReverseRight ' Reverse right servo
               PAUSE 20     
              NEXT
         CASE ButtonB
              FOR X=1 TO 4            ' Left turn
               PULSOUT Left_Servo,ReverseLeft   ' Reverse left servo
               PULSOUT Right_Servo,ForwardRight ' Forward right servo
               PAUSE 20
              NEXT
         CASE ButtonC
              FOR X=1 TO 4             ' Right turn
               PULSOUT Left_Servo,ForwardLeft    ' Forward left servo
               PULSOUT Right_Servo,ReverseRight  ' Reverse right servo
               PAUSE 20
              NEXT
   END SELECT

   GOTO Begin
             
    END

'****************************************************************
'*  Name    : REMOTE.INC                                        *
'*  Notes   : Hardware setup for Micro-Bot remote control       *
'****************************************************************
@ DEVICE HS_OSC,MCLR_OFF,LVP_OFF,WDT_OFF,PROTECT_OFF
DEFINE OSC 20      ' We're using a 20MHz crystal
DEFINE NO_CLRWDT 1 ' Do not auto insert watchdog timer reset code

'** Turn 16F62x Comparators OFF **'
CMCON = 7    ' Comparators = OFF, PortA = digital I/O
VRCON = 0    ' Internal A/D Vref disabled

' ** Infrared LED Control Constants ** '
Led_On  CON 0  ' Led_On = logic 0 which turns IR LED on
Led_Off CON 1  ' Led_Off turns IR LED off
No      CON 1  ' If IR Detector Output = 1, then No object detected
Yes     CON 0  ' If IR Detector Output = 0, then Yes object detected

' ** Remote Control Constants ** '
ButtonA CON 12 ' %00001100 = Button A pressed and VT active
ButtonB CON 14 ' %00001110 = Button B pressed and VT active
ButtonC CON 10 ' %00001010 = Button C pressed and VT active
ButtonD CON 9  ' %00001001 = Button D pressed and VT active

'** Setup PortB **'
' PortB.3 = PWM output. PortB.6 & B.7 unused
TRISB = %00000100       ' Set PortB TRIS register
Left_Led    VAR PortB.0 ' PortB.0 = left IRLED output
Right_Led   VAR PortB.1 ' PortB.1 = right IRLED output
IR_Detector VAR PortB.2 ' PortB.2 = IR detector input
Left_Servo  VAR PortB.4 ' PortB.4 = left servo output
Right_Servo VAR PortB.5 ' PortB.5 = right servo output
Left_Servo = 0          ' Left servo control pin = 0
Right_Servo = 0         ' Right servo control pin = 0
Left_Led = Led_Off      ' Left IRLED = OFF
Right_Led = Led_Off     ' Right IRLED = OFF

'** Setup PortA **'
' PortA.4 & A.5 unused
TRISA = %000001111      ' Set PortA TRIS register
VT      VAR PortA.3     ' HT-12D VT input on PortA.3

'** IR Flag Bit Variables **'
Left_IR VAR BIT     ' Flag bit for left IR object detection
Left_IR = No        ' Initialize to 1 [no object detected] on power-up
Right_IR VAR BIT    ' Flag bit for right IR object detection
Right_IR = No       ' Initialize to 1 [no object detected] on power-up

'** Define Constants **'
ForwardLeft  CON 800   ' 200 For 4MHz
ReverseLeft  CON 600   ' 100 For 4MHz
ForwardRight CON 600   ' 100 For 4MHz
ReverseRight CON 800   ' 200 For 4MHz
TRUE  CON 12    ' CCP1CON value for PWM ON
FALSE CON 0     ' CCP1CON value for PWM OFF

'** G.P. Working Variables **'
X     VAR BYTE      ' GP working variable
Loops VAR BYTE      ' GP working variable
ServoTime VAR BYTE  ' Time to move servos in motor control sub-routines
Loops = 0           ' Start with Loops variable clear

'** Setup For 40KHz PWM IRLED Drive **'
CCPR1L = 25      ' 63=50%, 25=20%, 94=75% PWM Duty-Cycle
PR2 = 124        ' Set PWM for approximately 40KHz
T2CON = 4        ' Timer2 ON + 1:1 prescale
CCP1CON = FALSE  ' Start with hardware PWM = OFF

GOTO Begin       ' Jump to beginning routine

Check_Left:          ' Call here to check left for obstacle
    CCP1CON = TRUE   ' ON 40KHz PWM
    Right_Led=Led_Off  : PAUSE 5 ' OFF right LED / pause
    Left_Led=Led_On    : PAUSE 5 ' ON left LED / pause
    Left_IR = IR_Detector  ' Read IR detector output
    Left_Led=Led_Off ' OFF Left LED
    CCP1CON = FALSE  ' OFF 40KHz PWM
    RETURN           ' Return to calling routine
    
Check_Right:         ' Call here to check for right obstacle
    CCP1CON = TRUE   ' ON 40KHz PWM
    Left_Led=Led_Off  : PAUSE 5 ' OFF left LED / pause
    Right_Led=Led_On  : PAUSE 5 ' ON right LED / pause
    Right_IR = IR_Detector  ' Read IR detector output
    Right_Led=Led_Off' OFF Right LED
    CCP1CON = FALSE  ' OFF 40KHz PWM
    RETURN           ' Return to calling routine


 Back To Index

Copyright © 2007 Reynolds Electronics
http://www.rentron.com