PicBasic Pro Compiler

Download All Files By Clicking Here!
These files provided by Les Johnson ( les@top204.freeserve.co.uk )


 

IROUT

A new pseudo command may be added to support Infra-Red transmission. To use this new command place:-

Include "IR_TX.BAS" Load in the Transmitter Routine

at the front of the program . This will Load the Transmitter subroutine into memory. NOTE (the above include must be at the start of the program, to avoid any page boundary conflicts).

Two new defines have also been added to preset the Port and Pin on which to place the Infra-Red LED. these are:-

IROUT_PORT Port Define the Port to Transmit data

IROUT_PIN Pin Define the Pin to Transmit data

PORT may be any of the Ports on a pic microcontroller. PIN may be any number from 0 to 7, representing the bit number of the appropriate port. If the defines are omitted from the program the default is PORTA.0

To use IROUT:-

Load IR_BYTEOUT with the Byte to be sent

Load IR_IDOUT with the ID-Code for this transmitter

Then make a call to IROUT (i.e Gosub IROUT)

IR_Byteout holds the byte (0-255) to transmit, IR_IDOUT contains a unique number for that particular transmitter, any number between 1-255 can be used.

IR_BYTEOUT = 200 Send the Value 200

IR_IDOUT = 1 This transmitter is number 1

GOSUB IROUT Transmit the Value and ID

IR_Byteout and IR_IDout are pre declared variables and need not be declared in the main body of the program.

 

 

 

 

 

PicBasic Pro Compiler


IRIN

A new pseudo command may be added to compliment the IROUT subroutine. IRIN is used for Infra-Red reception. To use this new command place:-

Include "IR_RX.BAS" Load in the Receiver Routine

at the front of the program . This will Load the Receiver subroutine into memory. NOTE (this include must be at the start of the program, to avoid any page boundary conflicts).

Two new defines have also been added to preset the Port and Pin on which to place the Infra-Red sensor. these are:-

IRIN_PORT Port Define the Port to receive data

IRIN_PIN Pin Define the Pin to Receive data

PORT may be any of the Ports on a pic microcontroller. PIN may be any number from 0 to 7, representing the bit number of the appropriate port. If the defines are omitted from the program the default is PORTA.1

To use IRIN:-

Make a call to IRIN

Check the Variable IR_VALID for true or false (1 or 0)

Check the Variable IR_IDIN to extract the ID-Code of the Transmitter

Load in Actual Byte received with IR_BYTEIN

IR_Valid will return a 0 if the routine did not receive the appropriate header from the transmitter and a 1 if succesful . IR_Bytein holds the byte received, IR_IDIN contains a unique number for a particular transmitter

Main: GOSUB IRIN ' Receive the Ir Data

IF IR_VALID =0 then Goto Main ' If no reception, LOOK AGAIN

IF IR_IDIN =1 then ' Check Transmitter ID code

Debug I,Line1,#IR_BYTEIN ' Print out Value sent

Endif

Goto Main

IR_Valid, IR_Idin and IR_Bytein are pre-declared variables and need not be declared in the main body of the program.

 

PicBasic Pro Compiler


IRIN and IROUT example diagrams

 

 


Infra-Red Receiver Circuit

 


Infra-Red Transmitter Circuit

Download All Files By Clicking Here!