EMBEDDED SYSTEM APPLICATIONS

Page 77

Embedded System Applications

if (tmr_buz == 3) { RB7=~RB7; tmr_buz =0; }

// time = 3 x 1s = 2s //toggle buzzer

//restore TMR0H & TMR0L value TMR0H=0x0B; TMR0L=0xDC; TMR0IF=0; //clear TMR0IF } }

4.8.2 Program Timer0 Interrupt for Real Time Applications We can use timer interrupt programming to perform real time applications, for example, a counter system.

Example 4.5

A fruit packaging factory wants to install an automatic packaging system. The system used two DC motors to move two conveyor belts. The first conveyer belt is used to carry and drop the fruits into boxes and the second conveyor belt is used to move a box. A sensor is used to detect the fruits that fall into the box. When 50 of the fruits have fallen into the box, the fruit conveyor belt will stop and the second conveyor will move for 2 seconds to place a new empty box.

Sketch the control circuit using PIC18 microcontroller, and write a program using Timer0 Interrupt as a counter to perform the operation. Use any pins as output.

68


Turn static files into dynamic content formats.

CreateΒ aΒ flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.