|
Cup_IR_Software
IR Distribution and Encoding (Software)PURPOSE:The cup needs to be able to encode and transmit IR signals for pouring and sending deadly packets. CodeDESIGN:The cup will use a single CCP pin to produce a PWM signal for pouring or deadly packets. These two functions will never be active at the same time.
Pouring IR Packets:The frequency of the PWM will be set to send at 38 kHz. The duty cycle will be set to 50%. The PWM signal will run until the pouring function is terminated. Deadly IR Packets:The frequency of the PWM will be set to send to 56 kHz. The duty cycle will be set to 50%. The cup needs to be able to send ‘deadly’ IR packets to the head band unit periodically, and at the rate of one packet every two seconds. All IR signals are frequency modulated with a 56 kHz square wave signal as seen below.
For deadly IR packets, the Data Envelope and Redundant Data are to burst for 20 cycles 1. Three interrupt routines will be used to control the deadly packet transmission. The cup microcontroller will enable the HLVD module that will interrupt on the falling edges of the PWM signal. One timer will be used to interrupt every time duration of a packet frame (i.e. 150 56 kHz cycles). One timer will be used to interrupt every 2 seconds, which indicates that a new packet needs to be sent. The deadly packet transmission procedure is detailed in the following diagram. ResultsThe cup was able to successfully send a deadly IR packet with a 55.6 kHz signal. At 8 MHz internal, the cup cannot achieve a more accurate signal frequency. Flowchart
| |