Multi-Tasking and Real-Time Operating Systems:Voltmeter with RS232 Serial Output
PROJECT 10.3—Voltmeter with RS232 Serial Output In this RTOS project, which is more complex than the preceding ones, the voltage is read using an A/D converter and then sent over the serial port to a PC. The project consists of three tasks: Live, Get_voltage, and To_RS232. • Task Live runs every 200ms and flashes an LED connected to port RD7 of the microcontroller to indicate that the system is working. • Task Get_voltage reads channel 0 of the A/D converter where the voltage to be measured is connected. The read value is formatted and then stored in a variable. This task runs every two seconds. • Task To_RS232 reads the formatted voltage and sends it over the RS232 line to a PC every second. Figure 10.12 shows the block diagram of the project. The circuit diagram is given in Figure 10.13. A PIC18F8520-type microcontroller with a 10MHz crystal is used in this project (though any PIC18F-series microcontroller can be used). The voltage to be measured is connected to analog port...