EDN Access

July 3, 1997


µC provides analog data to PLC chip

Luke Barker, Reinke Mfg Co, Deshler, NE

The low price of programmable-logic controllers (PLCs) makes these small devices a good choice for many system designs. Most of the controllers, however, accommodate only digital inputs. One such model is Allen Bradley's (Milwaukee, WI) MicroLogix 1000 PLC, which has 10 digital (on/off) inputs and six relay or solid-state outputs. In certain applications, the need exists to provide analog inputs to the PLC. The circuit in Figure 1 sends analog data serially to a PLC, using only one digital input on the PLC. The Microchip PIC16C71 µP provides A/D conversion and sends four converted channels to the PLC. The µP sends the data to the PLC using only one output pin on the µP and one input port on the PLC. (Note that the PLC must be the 24V-dc-input version.)

The µP receives its power from the 24V power supply (200 mA maximum) and a 5V regulator. The chip sends 12 bits of information to an optoisolated IC relay. The relay, in turn, translates the 5V pulses to 24V pulses for the PLC's input. The data consists of 1 start bit, 2 channel-ID bits, 8 bits corresponding to the analog value, and 1 stop bit. In receiving the data, the PLC uses its selectable-timed-interrupt feature. The fastest interrupt time is 10 msec, but here you use 20 msec to minimize interrupt latency. The PLC accepts 48 data bits (12 bits, four channels) to receive all four channels of analog data. Thus, it takes approximately 0.96 sec to receive all four channels, corresponding to a baud rate of 50 bps. If the data stops transmitting for some reason, the PLC simply stops interrupting until it detects a start bit again; normal operation then continues.

The 2.4576-MHz crystal oscillator provides accurate 20-msec time-delay intervals that the PLC needs for synchronization. The start bit is 30 msec long, and each data bit is 20 msec long. The longer start bit allows the PLC to recognize the beginning of a start bit, perform an interrupt after 20 msec, and systematically interrupt every 20 msec thereafter. The synchronization is such that the PLC interrupts at the center of each data bit. (Click here to download the PIC16C71 Parallax-compiler code, as well as a graphical representation of the PLC source listing from DI-SIG, #2051.) (DI #2051)


Figure 1
 
An inexpensive µP and a handful of components make it possible to provide analog data to a digital-only programmable-logic controller (PLC).

| EDN Access | Feedback | Table of Contents |


Copyright © 1997 EDN Magazine, EDN Access. EDN is a registered trademark of Reed Properties Inc, used under license. EDN is published by Cahners Publishing Company, a unit of Reed Elsevier Inc.