Linux and RTAI for Building Automation
This article presents the design and development of a control system for centralized operation of different air-conditioning equipment in a building by using Linux and the real-time Linux application interface (RTAI). Each air conditioner, distributed throughout the building, has it own infrared (IR) remote controller. The goal is to replace them with a centralized computer-based control system to operate the air conditioners, including turning them on or off and setting the desired temperature and fan speed.
The idea for this project came from the need of a local university to have a centralized and flexible way to operate its air conditioners at a cost within its budget. Commercial software and hardware exists for the same purpose, but normally they are too expensive and manufacturer-dependent.
This project's hardware solution consists of a central control computer, running Linux, connected to an RS-485 microcontroller network. The microcontrollers have the capability to send commands to the related air conditioner using infrared signals to operate the nearby equipment.
The software design of the system includes two real-time tasks—a main control task and the RS-485 network control task—as well as two non-real-time tasks—a Web server and a database. The Web server is in charge of the user interface, making it available from any browser in the university's computer network. The PostgreSQL database is used as the main data repository.
The implementation is a low-cost solution with the flexibility to extend it as necessary. Moreover, it is not manufacturer-dependent, and it works with any air conditioner that supports an IR remote controller. Each air conditioner works independently using its own temperature control system. To supervise the operation of this equipment, each microcontroller in the network is equipped with a temperature sensor to monitor the actual classroom temperature and report it to the central computer.
The entire user interface is based on Web pages. The first page displays a summary of the actual state of each air conditioner. This information includes an identification string, the room in the building where it is located, the actual room temperature and whether the equipment has a preprogrammed operation sequence according to which it actually is operating. For each air conditioner, this page has a link to the operation interface for the specific piece of equipment. Before going to this page, the system asks for a user name and password. At this level, it is possible to interact with the system directly controlling the air conditioner or to create or change the actual program for automatic operation (Figure 1).

Figure 1. From the operation interface, an authorized user can turn the air conditioner on, set a new temperature or turn it off.
The most interesting part of the system is the programmed operation. For example, every day the system can turn on the air conditioners automatically, with a predefined temperature setting for each room, before classes begin. Then, the system can turn off the air conditioners at a time in the evening when the activities in the building or in a specific classroom end.
The hardware architecture is composed of a central control computer and microcontrollers commanding the air-conditioning equipment. All the microcontrollers are connected to an RS-485 two-wire network. The microcontroller used in this application is the AT89C2051, an Intel 8051 derivative from ATMEL. It is encapsulated in a 20-pin DIP package and is equipped with 128 bytes of data RAM, 2KB of ROM for code, one asynchronous serial port and 14 independent digital I/O ports. Figure 2 shows the microcontroller board and its parts.
The software in the microcontroller generates the IR signal using one digital output port. The serial port connects the microcontroller to the RS-485 network. Each microcontroller board is equipped with a temperature sensor, the DS1620 from Dallas Semiconductor. The microcontroller communicates with the temperature sensor using a digital three-wire synchronous serial interface. The microcontroller has no hardware support for synchronous serial ports; therefore, it is implemented in software using normal I/O ports.
The RS-485 network is used in this application because it is easy to deploy, cheap to implement and easily can connect a useful number of nodes. Only one pair of Category 3 telephony grade cable connects the nodes. Due to the hardware driver limitation, the maximum number of allowed nodes is 32, but this number easily can be extended using network repeaters. The maximum cable length between the control computer and the first repeater or between repeaters is 1,200 meters.
A master-slave protocol controls access to the physical cable. The computer running Linux is the master, which polls each node with a predefined rate. On every polling the master can send commands to the node; the polled node answers by sending data to the master or by sending an empty packet to say that the node is active. A drawback of using this access-control protocol occurs if the master goes down—the entire network goes down too.
Considering the limited resources of the microcontrollers, the 9th-bit protocol is used to determine whether the packet sent through the network is for this controller. Each byte transmitted through the network has an additional bit. The packet destination address is the only one transmitted with this additional bit set to high. The microcontroller's UART (universal asynchronous receiver and transmitter) is programmed by default to generate an interrupt only if the 9th bit of the received byte is high. The interrupt service routine then compares the received byte with the node address. If there is a match, the routine programs the UART to receive all the bytes regardless of the 9th-bit state, until the end of the packet. If the destination address does not match this node address, the interrupt service routine returns.
The central control computer UART, which is PC hardware, does not directly support the 9th-bit protocol. To overcome this limitation, the driver simulates it by using the parity bit. Before transmitting a byte, the driver configures the parity to generate a one in the 9th bit of the address byte and a zero in the 9th bit of the other bytes.
Figure 3 shows a diagram of the tasks in the system and the communication links between them.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- New Products
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- What's the tweeting protocol?
- New Products
- RSS Feeds
- Readers' Choice Awards
- Dart: a New Web Programming Experience
- Reply to comment | Linux Journal
13 hours 20 min ago - Reply to comment | Linux Journal
15 hours 53 min ago - Reply to comment | Linux Journal
17 hours 10 min ago - great post
17 hours 45 min ago - Google Docs
18 hours 7 min ago - Reply to comment | Linux Journal
22 hours 56 min ago - Reply to comment | Linux Journal
23 hours 43 min ago - Web Hosting IQ
1 day 1 hour ago - Thanks for taking the time to
1 day 2 hours ago - Linux is good
1 day 4 hours ago
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.






Comments
RS-485 driver availability in linux
Please let me know how have you implemented the RS-485 functionalities in linux. Whether RS-485 driver is built-in driver of linux or we have write by our own?