Download PCB and component layout PDFs: click here
Operation. ASK receiver receives 433MHz carrier signal and demodulates the address and data before giving it to decoder HT12D. HT12D receives these bits serially through DIN pin 14 and compares the address. If received address and set address match, the data will be latched on pins D8 through D11 of decoder HT12D. The VT pin 17 becomes high momentarily as data is latched. This is indicated by LED2. If AD11 pin goes low by pressing start switch (S1) of the transmitter side, only D11 pin 13 at the receiver side becomes low and all other pins become high. Since D11 pin is connected to port pin P1.0 of microcontroller AT89C51, it gives the start signal. Data is received similarly for D8, D9 and D10. When ES key is pressed all data pins D8 through D11 are high. So at the receiver side all the pins become high. That makes the output of AND gate high, which is given to the reset pin 9 of microcontroller.
Because there is a latch action at D8 through D11 outputs, all A through D inputs to AND gate remain high till any other key is pressed at the transmitter. This will continuously apply reset signal to microcontroller AT89C51. To remove reset condition, one SPST (S9) is used in between to make and break the direct connection. Open switch S9 will break the connection and reset pin will not get high logic from the AND gate. Now, after starting the operation, to activate ES from remote, press the switch again to make the connection. Fig. 8 shows the proposed arrangement for front panel and remote control for industrial on/off timer.
The program is written in ‘C’ language and compiled through Keil µVision4 compiler. The program is well-commented and easy to understand. Complete program is divided in twelve different functions. Out of these twelve functions, four functions are for LCD handling, four for timer operation, two delay functions, one interrupt function and the last one is the main function.
LCD handling functions. The various functions are as follows:
‘writecmd’ function. It sends command byte to LCD by taking one argument byte that is sent to port P0
‘writedata’ function. It sends data byte to be displayed on LCD. It also takes one argument byte and sends it to P0
‘writestr’ function. It writes the whole string (message) on LCD taking pointer as an argument that points address of first character of string. Through the pointer it sends all the characters one by one to port P0
‘busy’ function. It checks the status of busy flag of LCD. If the flag is set that means LCD is not ready and pro-gram remains within loop. When flag is reset that means LCD is ready and program comes out of loop
‘keydly’ function. It generates key debounce delay of around 0.1 second using ‘for loop’ statement twice
‘dly1sec’ function. It generates approximately one second delay using ‘for loop’
‘takeinput’ function. This interrupt function handles external interrupt1. It just saves the status of port P1 whenever external interrupt1 occurs
Timer operation functions.
‘Start’ function. It starts the timer operation by sending high logic to port pin P3.7 and energising the relay. The countdown time is displayed on LCD as ‘Device ON.’ Then it sends low logic to port pin P3.7 and de-energises the relay. Again countdown time is displayed as ‘Device OFF.’ It then checks the status of port pin P3.6. If it is high the cycle repeats continuously and if it is low the operation stops
‘Inctime’ function. It increments ‘ontime’ or ‘offtime’ variables till maximum limit (60 second) is reached. To display the variable on LCD the value must be in ASCII format. So first two digits are separated and then converted into equivalent ASCII values using array named ‘ascii.’ This array includes ASCII values of all 0 to 9 digits
‘Dectime’ function. It is similar to ‘Inctime’ function. The difference is that it will decrement ‘ontime’ or ‘off-time’ variable till minimum limit (1 second) is reached
‘Enter’ function. It changes the messages on LCD as ‘Enter OFF time:,’ ‘Press Start,’ etc. It is also used to enter ‘ontime’ and ‘offtime’ variables, alternatively.
Main function. It first initialises LCD and then displays message ‘Enter ON time:.’ It then checks the status of port pin P3.5 of microcontroller. If port pin P3.5 is high, it means timer operation is controlled through keypad and if it is low the timer operation is controlled through remote. It waits in continuous loop till any key is pressed from keypad or remote. As the key is pressed, the function is detected and it calls the particular function corresponding to that key like ‘Start,’ ‘Inctime,’ ‘Dectime’ or ‘Enter.’
Download source code: click here
The author is lecturer in electronics and communication in EC engineering department, Government Polytechnic, Amreli