barcode reader application in asp.net RTOS02: MULTITASKING APPLICATION EXAMPLE in Software

Paint QR Code 2d barcode in Software RTOS02: MULTITASKING APPLICATION EXAMPLE

RTOS02: MULTITASKING APPLICATION EXAMPLE
QR Decoder In None
Using Barcode Control SDK for Software Control to generate, create, read, scan barcode image in Software applications.
QR Code 2d Barcode Creation In None
Using Barcode creation for Software Control to generate, create QR Code ISO/IEC18004 image in Software applications.
The rst example application in this book is a digital clock and thermometer that runs on a PIC18C452 with a Dallas Semiconductor DS1820 temperature sensor and a Hitachi 44780 based two-line liquid-crystal display (LCD). The circuit used for this application is shown in Fig. 13.4. If you have read the TAB Electronics Microcontroller Handbook, this application probably will look pretty familiar to you. I used this application to demonstrate how different microcontrollers would implement the same application. For this book I am using this application to show how a typical microcontroller application can be implemented using an RTOS for controlling the application s execution. The bill of materials is listed in Table 13.6 The application code interfaces with three hardware devices, the LCD, and the DS1820, and a button is used to set the time. The circuit itself is pretty easy to wire because I arranged the PORTB pins to be wired directly across to the LCD. The LCD s pin 14, if it lines up with pin 40 of the PIC18C452, will allow mostly straight-through wiring to the LCD. The DS1820 has a 10-k pullup on its line and uses one of the I/O pins as a simulated open-drain driver. The DS1820 will pull down the line when data is read back. By simulating the open drain and putting the I/O pin in input mode while the DS1820 is driving the line low, there is no opportunity for bus contention between the PIC microcontroller and the DS1820. The button circuit consists of a pulled-up line that is tied to ground when the button is pressed. When I created this application, I used a 4-MHz ceramic resonator simply because it was already on the breadboard that I had wired previously for a PIC16F877 application, and the core circuit was identical to what I needed for the PIC18C452. The same pinout is a useful feature of the PIC18C452 and allows you to easily replace a mid-range PIC microcontroller with the PIC18x without changing the connections. If you are going to use this application as a clock, you might want to put in a 4-MHz crystal (with external capacitors) to get the most accurate timing possible.
Recognizing QR Code JIS X 0510 In None
Using Barcode recognizer for Software Control to read, scan read, scan image in Software applications.
Make QR Code In Visual C#
Using Barcode drawer for VS .NET Control to generate, create QR image in .NET applications.
Screen shot of executing RTOS code in the MPLAB IDE simulator.
Printing QR Code JIS X 0510 In .NET
Using Barcode maker for ASP.NET Control to generate, create QR Code 2d barcode image in ASP.NET applications.
QR Creator In Visual Studio .NET
Using Barcode maker for Visual Studio .NET Control to generate, create Denso QR Bar Code image in Visual Studio .NET applications.
PIC18 RTOS DESIGN
QR Code Creator In Visual Basic .NET
Using Barcode creator for VS .NET Control to generate, create QR-Code image in .NET framework applications.
ANSI/AIM Code 128 Creator In None
Using Barcode encoder for Software Control to generate, create Code 128 image in Software applications.
LCD PIC18C452
Draw Barcode In None
Using Barcode generator for Software Control to generate, create barcode image in Software applications.
Encoding Data Matrix In None
Using Barcode maker for Software Control to generate, create DataMatrix image in Software applications.
0.1 uF Tantalum Gnd Vcc 10 K
GTIN - 128 Drawer In None
Using Barcode drawer for Software Control to generate, create GTIN - 128 image in Software applications.
Generate UCC - 12 In None
Using Barcode drawer for Software Control to generate, create UPC A image in Software applications.
11, 32 V dd
Postnet 3 Of 5 Printer In None
Using Barcode generator for Software Control to generate, create Delivery Point Barcode (DPBC) image in Software applications.
Printing Barcode In Objective-C
Using Barcode maker for iPad Control to generate, create bar code image in iPad applications.
11 14
Creating Bar Code In VB.NET
Using Barcode encoder for VS .NET Control to generate, create bar code image in .NET framework applications.
Code-39 Creation In Objective-C
Using Barcode printer for iPhone Control to generate, create Code 39 Extended image in iPhone applications.
6 5 4 3 2 1
Scanning Barcode In Visual Studio .NET
Using Barcode Control SDK for ASP.NET Control to generate, create, read, scan barcode image in ASP.NET applications.
Barcode Decoder In Visual Studio .NET
Using Barcode scanner for .NET framework Control to read, scan read, scan image in .NET framework applications.
PORTB7-4 PORTB3 PORTB2 RA1
Create ECC200 In None
Using Barcode maker for Excel Control to generate, create ECC200 image in Microsoft Excel applications.
Reading Bar Code In C#
Using Barcode scanner for VS .NET Control to read, scan read, scan image in .NET applications.
37 40 36 35
10 K
1 _MCLR 13 Osc1 14 Osc2 12, 31 Vss
4 MHz
10 K
DS1820
Time Set 10 K Button
Figure 13.4 This simple circuit can be used to demonstrate the operation of a multitasking RTOS.
With the circuit designed, I then looked at how I would architect the application software. Because this code would be running under the RTOS, I wanted to make sure that I could develop it without using any more than the available resources. I always nd creating a simple block diagram of how I expect the tasks to execute to be invaluable when I am designing an RTOS application. For this application, I was able to create the task block diagram shown in Fig. 13.5 and allow only ve tasks in total to be created.
TABLE 13.6 MATERIALS PART
RTOS DIGITAL CLOCK/THERMOMETER APPLICATION BILL OF
DESCRIPTION
PIC18C452 DS1820 LCD 4-MHz 10-k 10-k 0.1- F Button Misc.
PIC18C452 10/JW DS1820 in TO-92 package Hitachi 44780 based alphanumeric display 4-MHz ceramic resonator or 4-MHz crystal and capacitors 3 10-k , 1/4- W resistors 10-k single-turn potentiometer 0.1- F tantalum capacitor Momentary on button Prototyping card, wiring, +5-V power supply
REAL-TIME OPERATING SYSTEMS
All Task Time Task
StartTask Task1, Priority = 1; while (1 == 1) NextTask;
TCount = 0; Seconds = 0; Minutes = 0; Hours = 0; while (1 == 1) { Delay(1/64 Second); if (ReadMsg != Error) { Minutes = Minutes + Message; TCount = 0; Seconds = 0; MsgAck(ReqTask); UpdateTime(); } TCount = TCount + 1; if (TCount > 63) { TCount = 0; Seconds = Seconds + 1; if (Seconds > 59) { Seconds = 0; Minutes = Minutes + 1; UpdateTime(); } } }
Task1 (LCD Task)
StartTask TimeTask, Priority = 2; StartTask TempTask, Priority = 1; StartTask ButtonTask, Priority = 1; InitLCD; while (1 == 1) { ReqTask = MsgWait; ReqMsg = MsgRead; MsgAck(ReqTask); if (ReqTask == TimeTask) UpdatedTime(ReqMsg); else UpdateTemp(ReqMsg); }
Copyright © OnBarcode.com . All rights reserved.