Microcontrollers in Practice

This chapter contains the description of a device capable of reading the status of a number of digital inputs, or the values of a number of analog inputs, to store this information, and to report it when it receives a specific interrogation from a master device. It is implemented using an AVR microcontroller, and uses a RS485 line to communicate with the master. The aim of this chapter is to introduce the basic concepts of distributed data acquisition systems.
The simple data acquisition modules described in this chapter are meant to be connected as slaves in a RS485 network, as shown in Fig. 13.1.
The master device in this network is a personal computer (PC), which uses one of the asynchronous communication ports (COM1/COM2) connected to the network through a RS232-to-RS485 interface converter.
Two different slave devices are described for this application: one, called SLD, is designed to read and report the status of three digital inputs, such as relay contacts; the other, called SLA, reads the values of three analog inputs in the range 0 2.56 V.
It is possible, in principle, to design and add more slave devices, with different functions, provided that they communicate according to the same protocol as the others. According to the recommendations of the RS485 standard, the total number of slaves connected to the same bus is limited to 32.
This...