Technical Article

Building a Temperature Controller Simulator Using OpenPLC and an Arduino

May 16, 2023 by Dr. Don Wilcher

Variable control allows external conditions, like temperature, to be monitored so the controller can activate devices to heat or cool the system as needed. Simulate a temp controller with low-cost components!

Electrical loads like DC and AC motors and solenoid-based actuators are basic electromechanical components that can provide rotational or linear motion for industrial machines.

In this project article, you will learn how a solid-state relay (SSR) can assist in operating such electromechanical actuators by building and programming a temperature controller simulator using an Arduino and OpenPLC.

Additionally, we will explore the operation of the Greater-Than-Or-Equal-To comparison function block in the OpenPLC software.

 

Using a Solid State Relay With a Resistive Load

Industrial controllers like PLCs and remote I/O modules cannot drive electromechanical loads like motors or solenoids because of the high currents needed to operate them. The electromechanical relay is designed to operate where a low-current drive signal is transformed to switch high-current devices using such a switching component.

The controller has the necessary driver circuit to energize the electromechanical relay, allowing its contacts to operate appropriately. The relay contacts are rated for the electrical load operated with the required switching current flowing through them. 

Although an electromechanical relay can switch the attached electrical load several thousands of times, eventually, the contacts begin to wear out. The SSR does not have physical electrical contacts to wear out. As the name implies, the SSR uses an internal electronic circuit to detect a control signal from an I/O module and turn on the solid-state switching component. Figure 1 illustrates a simple view of an SSR internal circuit.

 

Solid state relay diagram

Figure 1. An SSR internal circuit. Image courtesy of the author

 

SSR control circuit and switching contacts are typically optoelectronic-based light detection components like a photodiode, phototransistor, or photo-triac. For DC electrical loads, SSRs rely on internal phototransistors. A photo-triac is the control component used to operate AC electrical loads. A typical electronic symbol used to illustrate an SSR is shown in Figure 2.

 

Solid state relay electrical symbol

Figure 2. An electronic symbol for an SSR. Image used courtesy of KiCAD software

 

Bill of Materials for Temperature Control Simulator

The components required to build our temperature controller simulator can be purchased from Amazon or Digi-Key. The electrical and electronic components are listed next.

  • Arduino Uno (or compatible board)
  • A 3-6 V DC motor (simulating the cooling fan device)
  • (2x) 220 Ω (red, red, brown, gold), 1/4W resistors
  • SSR with 3-32 V DC input, with a DC output
  • 10 KΩ (brown, black, orange, gold), 1/4W resistor
  • Push button switch
  • 1N4001 general-purpose silicon (Si) diode
  • Red LED (blinking-type)
  • Solderless breadboard
  • Various cut and stripped solid wires (24 AWG size)

The Arduino Uno or compatible will serve as the PLC for the temperature controller simulator. The SSR will be controlled by the Arduino to turn on the 3-6 V DC motor.

The 220 Ω resistors will provide current limiting for the SSR and the red LED.

The push button, wired in series with the 10 KΩ resistor, will provide a control signal to the Arduino, simulating a digital temperature sensor (like a thermostat).

The 1N4001 silicon diode is used to suppress any back EMF produced by the DC motor being de-energized by the SSR. You are now ready to wire the temperature controller simulator with the electronic components obtained.

 

Wiring the SSR and Electronic Components to the Arduino

With the electronic components and the SSR available, we can assemble the parts to create the temp controller. The electronic components will be placed and wired together on a solderless breadboard. Figure 3 shows the electrical wires attached to the SRR.

 

Solid state relay with wires connected

Figure 3. Attaching electrical wires to the SSR. Image courtesy of the author

 

Note: The electrical connections of SSRs are not universal. Therefore, consult the wiring diagram of the SSR you are using to build your Temperature Controller Simulator.

Figure 4 shows an electrical wiring diagram to assist you in completing the connections between the Arduino, the electrical and electronic components, the DC motor, and the SSR. Notice the orientation of the 1N4001 (D2) and the red LED (D1), as shown in the diagram. If these electronic components are wired incorrectly, the Temperature Controller simulator will not work.

 

Arduino temp controller simulator schematic

Figure 4. The temperature controller simulator electrical wiring diagram. (Click to expand image)

 

The red and black wires extending from the solderless breadboard will be attached to the appropriate voltage source based on the selected DC motor used for the project. As an additional wiring reference, the electronic circuit schematic diagram for the temp controller is provided in Figure 5.

 

Temperature controller schematic

Figure 5. The temperature controller simulator electronic circuit schematic diagram. Image courtesy of the author

 

The completed Temperature Controller simulator is shown in Figure 6. The final stage of the project is to build the Ladder Diagram and test the simulator.

 

Arduino temp controller circuit layout

Figure 6. The temperature controller simulator final build. (Click to expand image)

 

OpenPLC Ladder Diagram for Arduino

Previous project articles have discussed the setup of the OpenPLC Ladder Diagram (LD). Please consult the introduction before diving into this more advanced tutorial. With the simulator circuit constructed, it’s time to add the control software. The program tags are shown in Figure 7. The tag listing will allow ease in building the LD in OpenPLC.

 

Arduino temp controller OpenPLC tag listing

Figure 7. The temperature controller simulator tag listing. Image courtesy of the author

 

With the aid of the tag listing, the Temperature Controller Simulator LD is shown in Figure 8.

 

OpenPLC temp controller ladder Logic diagram

Figure 8. The temperature controller simulator LD. Image courtesy of the author

 

By pressing the PB1 (CHANGE_TEMPERATURE) pushbutton switch, the up counter (CTU0) function block will increment its Current Value (CV). That CV will then be stored in the TEMPERATURE_CHANGE integer variable.

A ‘Greater Than or Equal to’ (GE) FB will compare the TEMPERATURE_CHANGE variable value to a preset TEMPERATURE value. The SSR will be energized if the TEMPERATURE_CHANGE is greater than the TEMPERATURE value (if ‘TEMPERATURE_CHANGE > TEMPERATURE’, then ‘SSR energized’).

The fan will be ON, indicating the temperature detected is higher than the preset value. The SSR bit instruction’s contact will, in turn, energize the FAN_ON_INDICATOR coil. The red LED will be flashing at this time.

The combination of the CTU and the GE function blocks allows the operator to simulate temperature changes affecting the fan’s cooling feature. Press the reset button on the Arduino Uno to reset the counter and stop the simulator.

View the video clip to see the temperature controller simulator in operation. You can experiment with the simulator by changing the values of the PRESET_VALUE and the TEMPERATURE_CHANGE variables provided on the tag listing, as shown in Figure 7. Explore some of the other comparison FB commands to see the effect on the temperature controller simulator.

 

Interactive Quiz

Wire a second digital pushbutton switch to operate the CTU FB’s R pin. What happens to the temperature controller circuit operation when pressing this pushbutton switch?

 


If you liked this, check out other Arduino OpenPLC project articles: