IR and RS-485 Communication Channels for an Electricity Meter
IR and RS-485 Communication Channels for an Electricity Meter
by
Ben Smith
Mar 15 2006
Abstract
When designing an electricity meter, communication is often the last thing considered. Today's electricity meters must capture more and more information and automatically convey the usage information from the meter to the utility. That is the job of the communication subsystem in the MAXQ3120 electricity meter reference design.
Why communications?
When designing an electricity meter, communication is often the last thing considered. Traditional meters communicate electric usage the old, passive way: periodically a meter reader goes to the meter and reads it. But today electricity meters must capture more and more information. It is no longer reasonable to expect trained personnel to manually collect many data points from each meter with an acceptable degree of accuracy. Instead, some mechanism must automatically convey the usage information from the meter to the utility. That is the job of the communication subsystem in the MAXQ3120 electricity meter reference design.
Two Channels
The MAXQ3120 electricity meter reference design includes two communication channels: an infrared (IR) channel for communication with handheld terminals, and a fully isolated multidrop RS-485 channel.
While the two channels share the same protocol, the operational details for the channels differ somewhat. The IR channel is always point-to-point; the handheld terminal communicates with only one meter at a time. As the terminal cannot access more than one meter at a time, it is acceptable for the meter to respond unilaterally to a broadcast message. In a networked environment that type of operation would cause a serious collision of data.
The RS-485 channel behaves differently. Since there may be many meters on the network (although never more than one host), no meter may transmit a packet in response to a network broadcast. After a host message, moreover, there can be a time delay before the host transceiver is ready to receive data. Consequently, a transmit delay before a meter responds is a prudent measure to prevent data loss.
Common Communication Elements
Regardless of the channel, some common elements are shared by the communication protocol. First, the link characteristics are identical: the channel operates at 1,200 bits per second, asynchronous, with one stop bit and even parity. Second, the link protocol is identical, as illustrated in Figure 1 here. Finally, commands on the two channels have the same meaning: a command sent on the IR channel will have the identical effect when sent on the RS-485 channel.
Figure 1. Illustration of the communications protocol.
Data packets have the following structure:
- A start flag: one byte, 0x68.
- A meter address: six bytes, variable. Every meter on the network has a unique network address. In contrast, the host (either the PC running the network or the handheld terminal) has no address; it initiates all communications and is the target of all messages sent from the meter. Thus, the address field functions as a destination address for messages from the host to the meter, and a source address for messages sent from the meter to the host. The address
99 99 99 99 99 99 is reserved as a broadcast address. - A delimiter: one byte, 0x68.
- A command byte: one byte, with the following format:
The fields in the command byte include:
- A direction bit: clear when packets are sent from the host to the meter, and set when packets are sent from the meter to the host.
- An error bit: indicates that the meter detected some error in a message from the host.
- A more bit: indicates that a meter response was too long for a single message and has been segmented into more than one message.
- A function field:
- 0x01: the read function, indicating that the host wishes to read some register value from the meter.
- 0x02: the read next function, indicating that the host received a multipart message indication, and wants to read the next part.
- 0x03: the reread function, indicating that the host did not properly receive the previous message segment, and wishes to have that segment resent.
- 0x04: the write function. The host wishes to store a value into a register in the electric meter. The data includes the two-byte register address and variable-length data.
- 0x08: the synchronize function. The data field contains the time and date. If the meter's internal clock differs from the time and date given in the message by less than ten minutes, the internal clock is adjusted to the given time. Otherwise, the time is not changed, and an error is returned.
- 0x0A: the set network address function. This is always a broadcast message. The data field contains a six-byte address that a designated meter will accept as its network address. Activating a meter's set address button designates that it is to accept the address.
- 0x0C: the change baud rate command. The baud rate is changed to the given baud rate for one transaction only, after which the baud rate reverts to 1,200bps.
- 0x0F: the change password command. The data field contains eight bytes, consisting of: (1) the superuser password designator (usually zero); (2) the superuser password; (3) the password designator to change; and (4) the new password.
- 0x10: the clear maximum demand command. When the meter receives this command, it clears all registers associated with reporting the maximum demand in each of several categories throughout the month.
- A length indicator: one byte. This is the entire length of the message, from start flag to end flag.
- Data: variable length.
- Checksum: one byte. This is the modulo-256 sum of all the bytes in the message, from the start flag to the end of data.
- The end flag: one byte, 0x16.
IR Channel Operational Specifics
The IR channel operates according to a simple tone-modulation technique. A '0' bit is represented by a beam of 850nm IR radiation modulated at 38kHz, and a '1' bit is represented by the absence of such a beam. The illustration below (Figure 2) shows how the character 'A' (0x41) would be transmitted:
Figure 2. Illustration of an IR channel tone-modulation technique.
Transmitting this physical channel is eased by a modulator in the MAXQ3120's CPU that combines the output of one of the timer channels and one of the UART channels. Demodulation is performed by an external, integrated IR receiver (Figure 3).
Figure 3. An External, integrated IR receiver performs the demodulation.
RS-485 Operational Specifics
The RS-485 channel has two specific requirements that make it more complex than the IR channel: the RS-485 channel is strictly half-duplex, and it must be galvanically isolated from the line. The first requirement is satisfied by using one of Maxim's half-duplex transceivers. The second requirement is met by using inexpensive opto-couplers to perform the electrical isolation. See Figure 4.
Figure 4. RS-485 communication is accomplished by using a half-duplex transceiver and inexpensive opto-couplers.
About The Authors
Related to this Article
Products
Product Categories
{{modalTitle}}
{{modalDescription}}
{{dropdownTitle}}
- {{defaultSelectedText}} {{#each projectNames}}
- {{name}} {{/each}} {{#if newProjectText}}
-
{{newProjectText}}
{{/if}}
{{newProjectTitle}}
{{projectNameErrorText}}