; ; Example program #2 for use with the OATLEY Electronics PICAXE Development System ; ; This program is an example of using a UHF transmitter to send 3 bytes of data to a receiver ; ; Author Jeff Monegal ; ; Microcontroller PICAXE 18X ; ; Compile date 28/3/2010 ; ;-------------------------------------------------------------------------------------------------- ; ; NOTES ; ;-------------------------------------------------------------------------------------------------- ; ; The 3 bytes of data to be transmitted are contained in the 3 byte registers. The checksum ; value is first calculated by exclusivly ORing byte_1 with byte_2. The result is stored in the ; checksum register which is then placed on the end of the data frame to be sent. A checksum is ; used t oensure that the received data is as error free as possible. At the receiver the checksum ; is compared with the result of exclusively ORing the same 2 registers. ; ;-------------------------------------------------------------------------------------------------- symbol byte_1 = b2 symbol byte_2 = b3 symbol byte_3 = b4 symbol checksum = b5 rem checksum used to ensure the data is received correctly ;-------------------------------------------------------------------------------------------------- ; ; First the 3 bytes to be transmitted are loaded into the 3 byte registers. The checksum is then ; calculated and it is used as the 4th byte to be sent. This means the data part of the frame ; consists of 4 bytes. Also part of the complete data frame is the value 85 and the word 'code'. ; ; Because many receivers use what is termed a 'data or bit slicer' in their design the receiver ; should first be calibrated. By calibrating we mean the RX should be synchronized to the incoming data ; stream. This may seem a bit strange but often the RX will sit with no incoming data for long periods ; of time. Its internal data slicer will drift high or low. What happens now is that the first few bits ; of received data can be missed until the RX again becomes synchronized. By first sending the value ; 85 (10101010) we effectively wake up the receiver so it is calibrated and ready to correctly receive ; digital data. ; ; The next value 'code' is used to ensure the receiver only receives or decodes the data stream that ; is meant for it. PICAXE calls this word the QUALIFIER. CODE can be any combination of alphanumerics ; and is not limited in length. Be careful however as the longer the Qualifier the longer the time ; taken to send the frame. By using this qualifier we can produce a data TX/RX system that is ; secure from interference caused by other PICAXE data TX/RX systems operating in the same enviroment. ; ; Serout 7,t2400 means use output pin 7 (can be what ever the user wants) and send the data at a ; baud rate of 2400 bits per second. Refering to the relavent PICAXE chip data will better explain ; this command ;--------------------------------- ; byte_1 is used to store any 8 bit data that the user wants to send to the receiver ; byte_2 is used to store 2nd 8 bit word that is to be sent to the RX ; byte_3 is the same as byte_2 start: if pin2 = 0 then send_frame tx_done: ; continue here with users own program. Note the push button should use debounce detect code goto start ;--------------------------------- send_frame: checksum = byte_1 xor byte_3 ;calculate the checksum byte serout 7,t2400,(85,"code",byte_1,byte_2,byte_3,checksum) ;send the frame. goto tx_done ;go back to the users program ;--------------------------------------------------------------------------------------------------