Tag Archives: plc

Use the Raspberry Pi as a PLC for Automation

If you thought the popular single board computer, the Raspberry Pi (RBPi) is suitable only for children learning to write programs in computer languages, you need to think afresh. Vytas Sinkevicius is using the RBPi as a PLC for applications in automation. Increasingly, others are also using the RBPi as a PLC replacement in automation applications.

Basically, the RBPi replaces the actual PLC, and works as the main controller. The design specifications for the RBPi PLC are:

  • 8 digital Inputs
  • 16 Analog Inputs each supporting 4-20 mA current loops
  • 4 Analog Outputs each supporting 4-20 mA current loops
  • 12 Relay Outputs for control
  • 90-264 VAC Power Supply
  • 24 VDC Power Supply (Field)
  • Real Time Clock
  • Industrial Grade Enclosure

The enclosure has an aluminum back panel with ABS sides and a clear Polycarbonate cover. The cabinet is 14 inches in width, 16 inches in height, and 7 inches in depth. Installation is simple as DIN rail mounting is followed for all modules. While the local wiring employs ribbon cables, for field wiring the center of the panel has been left wide open. The enclosure uses industrial grade terminal blocks with rising clamp screw types.

A Delta Chrome series power supply block powers the unit. The power unit accepts AC voltages from a wide range of 90 to 264 VAC, and supplies an output of 24 VDC, with several safety approvals. While the input 4-20 mA signals are from powered transmitters, all the PI-SPI-DIN modules are supplied by high efficiency switching power supplies.

A PI-SPI-DIN-RTC-RS485 module forms the heart of the system. Apart from supporting the RBPi, the module also supplies power to the RBPi via the GPIO ribbon cable. For external displays and Modbus I/O modules, there is an RS485 interface and a battery backed Real Time Clock. The PI-SPI-DIN modules also have a buffered 16-pin GPIO bus, which also carries power from the 24 VDC to the modules.

The project has software written in the C language. It emulates a gas detection system with 16 points. There are digital inputs for manual control of fans, and analog inputs for controlling fans with variable speed. The software is undergoing testing presently. It will be published after it is found to work without issues.

Although the total number of IO points is substantial, the GPIO loading on the RBPi is not very high. For instance, the SPI bus uses only three GPIO pins, since the SPI routines allow any arbitrary GPIO lines to be used for chip selects. The I2C bus uses 2 GPIO lines, while the two 4-20 mA modules use two GPIO chip selects. While the PI-SPI-DIN-8DI module uses one GPIO for chip select, the relay modules use an MCP23508 GPIO expander with 4 addresses, but uses only one GPIO chip select. Direction control takes up one GPIO pin on the RS485, while it uses GPIO UART Rx and Tx.

The entire setup of enclosure, power supply, all modules, DIN rails, and RBPi3 cost less than $600. This easily rivals any PLC on the market with the same number of IO points.

What is a Programmable Logic Controller?

Programmable Logic Controllers (PLCs) are miniature industrial computers. The hardware and software in a PLC are meant to perform control functions. Specifically, a PLC helps in the automation of industrial electromechanical processes. This includes controlling machinery on assembly lines in a factory, rides in an amusement park, or instruments in a food processing industrial establishment.

Most PLCs are designed to facilitate multiple arrangements of analog and digital inputs and outputs. They typically operate with extended temperature range, resistance to impact or vibration, and immunity to electrical noise and disturbances. The basic sections of a PLC usually consist of two sections—the first, the central processing unit (CPU), and the second, an Input/Output (I/0) interface system.

The CPU uses its processor and memory systems to control all system activity. Within the CPU is the micro-controller, memory chips, and other integrated circuits for controlling logic, monitoring, and communications. The CPU may operate in different modes—programmable or run. The programming mode allows the CPU to accept changes to the logic received from another computer. In the run mode, the CPU will execute the program to operate the process.

In the run mode, the CPU will accept input data from connected field devices such as switches, sensors, and more. After processing the data, it will execute or perform the control program stored in its memory system. As the PLC is a dedicated controller, the single program in its memory is processed and executed repeatedly. The scan time, the time taken for one cycle through the program, is typically of the order of one-thousandth of a second. The memory within the system stores the program, while at the same time holding the status of the I/O and provides a means to store values.

Typically, industrial users can fit a wide range of I/O modules to a PLC to accommodate various sensors and output devices. For instance, there are discrete input modules for detecting the presence of objects or events using photoelectric or proximity sensors, limit switches, and pushbuttons. Similarly, with discrete output modules it is possible to control loads such as motors, lights, solenoid valves, mainly to turn them On or Off.

The PLC can be fitted with analog input modules to accept signals generated by process instrumentation such as temperature, pressure, flow, and level transmitters. The modules interpret the signal from their sensors, and present a value within the range determined by the electrical specification of the device.

In the same way, the PLC can use analog outputs to command loads requiring a varying control signal, such as analog flow valves, variable frequency drives, or panel meters. PLCs can also use specialized modules such as serial or Ethernet communications, and high-speed I/O or motion control.

The greatest benefits of a PLC are its ability to change and replicate or repeat the operation of a process while simultaneously collecting and communicating critical information. In the industry, all aspects of a PLC—cost, power consumption, and communication capabilities—are subject to consideration when selecting the right one for the job. Industry automation owes a lot to the PLC or Programmable Logic Controller.

Integrated Motors Simplify Motion Control

With machines getting more robust, smaller, less expensive and more reliable, engineers are facing the challenges of designing newer types of motion control. One way of addressing such motion control challenges, without being an expert in mechatronics is to use integrated motion control systems. Typically, these solutions combine the motor, the drive and the system components within a single unit. The system components include the intelligence or motion controller and input outputs all onboard. The use of an integrated solution allows the designer to focus more on the development of the machine and less on solving compatibility issues between various system components. The integrated motion system usually has all the components within a complete unit and sized for proper use. The decision to use an integrated motion system or an integrated motor usually depends on several factors. Major among them are requirements based on machine size, cost, reliability, modularity and distributed control.

With integrated motors, engineers can reduce the amount of space a machine needs. This is mainly the result of consolidation of components resulting in elimination of cabling. For example, an integrated motor may replace a drive and motor housed in separate enclosures, eliminating one of the enclosures. The panel space required reduces significantly for an integrated motor, while for a multi-axis system the real estate reduction can be substantial. However, an existing machine design must contain adequate space to house the integrated motor as this type of motor is larger than conventional motors.

Using integrated motors results in definite cost savings in contrast to using conventional components. One of the major saving in expenses comes from the absence of cabling that is no longer required with integrated motors. For example, the conventional drive may be located in a centralized cabinet with the motor a distance away on a long conveying machine. This arrangement needs considerable power cabling and feedback wiring between the motor and the drive. With the integrated motor, the drive being directly on the motor, much of the cabling is eliminated contributing to cost reduction.

With improvements in motor technology, the concern with reliability in integrated motors is outdated. The major point of concern earlier was heat buildup and dissipation. With reduced components making up the system, the reliability of integrated motors has improved because of the lower number of wire connections used. Better construction technology has improved the efficiency, decreasing the heat generated and the need for dissipation.

Industrial automation today requires modular machines. That essentially means smaller machines focusing on singular tasks combined to form a bigger system responsible for multiple functions. The smaller machines may operate independent of each other. This arrangement is beneficial because it allows engineers to change on modular section and transform the system into another customized machine. The modular concept is beneficial in shipping individual modules to the factory floor as the motor and drive of the integrated motor is placed directly in the machine.

As more and more industrial control is through PLC or Programmable Logic Controls, motor operations and synchronization through digital data signals is the norm. Since each integrated motor has its own controller, a distributed control system provides faster response and greater accuracies.