The design and application of an external switching board which receives binary on-off signal or command via the PC RS-232 port (serial port) of a PC was explained to accommodate the needs to control the activation and de-activation process of industrial actuators based on the controller input-output parameters. The binary on-off signal used to drive the operation of the external switching board was a sequence of electric voltage which in the form of +5V DC for the process of switching off and on the device. The +5 V DC electric pulses were sent to the input of the device through a connection at pin no. 3 (Tx) of the 9-pins RS-232 port connection. There were two models of circuit designed, the first one used Silicon Controlled Rectifier (SCR) as the self-locked or latch component, while the second model used electromagnetic switch (relay) as the self-locked or latch components. The electric pulsed which were send through RS-232 port connection were generated by a simulated automatic controller build by using Matlab Software.
Keywords: serial port, switching board, Matlab
I. Background to the Design
There was a need to send on-off (binary) command signal or output from PC which can be used to switch on or switch off a system or industrial actuators such as electric motors, heating elements, electro-pneumatics valves, etc. In the application, the on-off command signal will be generated by software applications in the form of an automatic controller system which built by using software such as Matlab, C++, and Pascal. The serial port (RS-232 port) of a PC can be used to send the signal to an external switching board which functions as the hardware that controls the operation of an industrial actuator. In the operation, the external switching board connected to the RS-232 port received on-off signal from the automatic controller system build or simulated in a PC. Further, the signal which is in the form of electric voltage of +5Volt DC for switch on command and 0 Volt for switch off command will then used to trigger the external switching board. The cycle of electric voltage send to the input of external switching board can be seen as a sequence of electric pulses which has 0 Volt for minimum value and +5 Volt DC for maximum value. In this case, the sequence of electric pulses send from RS-232 port of the PC will determine statuses of the external switching board (i.e., on or off switching statuses). The external switching board will be equipped with relays that added to increase the rating current and voltage which can be handled by the device. The usage of relays add functionality of the designed switching board to handle the switching process of high power electric apparatus such AC motors and high power heating elements. There are two design and application sides of the external switching board which will be discussed in brief in this report. The first part which will be discussed or explained is the software side. The software side discussion explains basic software application using Matlab to provide binary on-off decisions used to send sequences of electric pulses to activate and de-activate the external switching board which connected the serial port.
Figure 1. Schematic Diagram of the System
The arrangement of the system for the application of the external switching board is shown in Figure 1. The PC send the pulse to the external switching board through RS-232 port which then interpreted by the switching board to switch on or switch off the electric load to AC 220 V power supply line.
II. Determining Binary ON-OFF Output Scheme (Software Side)
The determination of binary on-off signal which would be used to trigger the external switching board was made through the application of a simulated automatic controller build in Matlab programming environment. The Controller system consisted of the controller core system and the switcher block which was tested every 5 minutes to produce a decision as to whether the relay of the switching board is to be turned ON or OFF. The switcher block was build using a set of Matlab switching script that used to compare the previous and the recent output of the switcher block. Based on the comparison of the previous and the
recent output values from the switcher block then a decision was made to switch the relay of the external switching board to ON or OFF.
The switching script implemented for the switcher block in Matlab environment to produce switching decision for an electric load (i.e., heating element) is shown below.
If value_out_old < 5 & value_out_new < 5 ...
disp('*** NEW=OLD -> LOW - No Switching ');
elseif value_out_old >= 5 & value_out_new >= 5 ...
disp('*** NEW=OLD -> HIGH - No Switching');
elseif value_out_old < 5 & value_out_new >= 5 ...
disp('*** NEW > OLD -> HIGH - Switch ON');
pulse_com2; % sending pulse via com 2
elseif value_out_old >= 5 & value_out_new < 5 ...
disp('*** NEW < OLD -> LOW - Switch OFF');
pulse_com2; % sending pulse via com 2
else disp('NO Decision made');
There were two values of the output used in the code, they are value_out_old and value_out_new. The value_out_old was the previous value of the output from controller core system and the value_out_new was the recent one which produced by the switcher block. By the process of comparing the status between the previous and the recent value of the output, a decision was made.
In the test scheme of the external switching board, there were four switching conditions produced based on the comparison between the previous and the recent output of the switcher block as shown in Matlab programming code of the previous page. These conditions are listed below.
- If the previous and the recent value of the switcher block output were both less than 5, and the current switching status of the electric heating element was already OFF, then there was no action produced, in this condition, hence the relay was kept OFF.
- If the previous and the recent value of the switcher were both greater or equal to 5, and the current switching status of the electric heating element was already turned ON, then there was no action produced, in this condition, hence the relay was kept ON.
- If the previous output of the switcher block was less than 5 and the recent one was greater or equal to 5, an action occurred to produce a switching pulse to the external switching board. In this condition, if the heating element was already turned ON, then after the pulse was fired, hence the condition was changed from ON to OFF.
- If the previous output of the switcher block was less than 5 and the recent one was greater or equal to 5, the there was an action occurred to produce a switching pulse to the external switching board. In this condition, if the electric heating element was already turned OFF, then after the pulse was produced, hence the condition was changed from OFF to ON.
One of the four switching schemes above was executed based on the output from the switcher block. When switching scheme no. 3 or no. 4 was executed, another Matlab script was called and then applied to generate the signal to activate the external switching board.
The Matlab script applied was aimed at sending a pulse to the serial port no. 3 of the PC to anexternal switching board. The Matlab script was named pulse_com2.m. The script named Cport used to generate the pulse is shown below.
Port = 'com2';
Data_port = 2000;
The CPort function used in the above Matlab script was originally written by Eyal Doron and the script basic form was taken from http://www.Mathworks.com under the directory of user contributed m-files for Matlab version 5.x.
When it was executed, the pulse_com2.m script produced positive voltage which then used to activate the external switching board. The external switching board was designed to change its condition from switch ON to switch OFF or switch OFF to switch ON based on the triggered pulse received from serial port’s pin no. 3 of the PC.
When the switching board was triggered ON, it connected an electric load (for example an electric heating element) of a hot water system to the mains supply (220 V AC), and vice versa. The complete diagram of the external switching board is shown in Figure 2. The list of electronic components used in the external switching board is given in Table 1.
Table 1. List of Components
|R1 = 1K ohm||C1 = C2 =
|RLY1 = RLY2 = RLY3 = 12V/1A||Thyristor (SCR1) = BT152 600R|
|R2 = 560 ohm||–||–||Transistor (TR1) = 2N2055|
|R3 = 1K ohm||–||–||Diode (D1 – D4) = 1N4001|
|R4 = 220 ohm||–||–||LEDs (red and green)|
|R5 = R6 = R7 = 330 ohm||–||–||–|
III. The operation of the Switching Board in Figure 2
When the external switching board was connected to a power supply (+10 – 12V DC), Relay RLY2 was energised and it connected Diode D1 (i.e. input) to Resistor R1 which was connected to the Gate of Silicon Controlled Rectifier SCR1. Relay RLY2 was energised because it receives power from RLY1 (Relay 1) which was in the Normal Close (NC) status. At the same time capacitor C1 (Capacitor) was charged. The RLY3 which also in NC status connected the Cathode (K) of SCR1 to negative terminal. At this time, there was no power delivered to the Load terminal (to relay for the electric heating element).
When a pulse was sent from serial port via Diode D1, it triggered SCR1 and turned it ON. When SCR1 was ON, it energises RLY1 and disconnected RLY2 from the power supply. When Relay RLY2 was disconnected from the power supply, the disconnection of RLY2 changes the connection of the input line from resistor R1 to resistor R3 which was connected to the Base (b) of transistor TR1. At this stage, the switching status of Relay RLY3 was unchanged. At the same time, power was delivered to the Load terminal (i.e. solenoid valve or relay for the electric heating element).
When another pulse was received from the serial port through Diode D1, it activated Transistor TR1 and charged the capacitor C2. At the same time, TR1 energised Relay RLY3 and it disconnected the connection of the Cathode (K) pin of Silicon Controlled Rectifier SCR1 from the negative terminal. Hence, SCR1 reset itself and deactivated Relay RLY1. The switching status of Relay RLY1 was restored to the initial condition as in point 1. At this time, Relay RLY1 disconnects the power supply to Load terminal, and the status of the switching board was restored back to the status in point 1.
IV. Alternative Circuit of the External Switching Board
The alternative electronic circuit of the external switching board is shown in Figure 3. The circuit was a modified version of the original circuit in Figure 2. It was provided to be used for the simulation purpose using electronics simulation software. Instead for the simulated purpose in the computer, the circuit have been tested in a real application and it was proven to have an operation similarly to the original external switching board of Figure 2.
The alternative circuit consists of 5 relays, 1 transistor, 5 diodes, 4 resistors, 2 electrolytic capacitors and 2 lamps used as indicator for switching status. Lamp L1 was used as the indicator for Output A and Lamp L2 for Output B. In the alternative circuit, the function of SCR was replaced by Relay RL4. At its initial condition the Output A was switched ON as shown in Figure 3. Resistor R1 and R2 functions as a voltage divider, the voltage divider output was feed to the Base terminal (B) of transistor TR1. When the Push button was activated the voltage divider sends its output to the base terminal (B) of transistor TR1. Transistor TR1 activates and current flows through the coil of RL1 as the collector-emitter (C-E) connection of TR1 was open. The activation of TR1 changed the switching position of relay switch of RL1 temporarily from C-NC connection changed to C-NO (and back to default at C-NC position). At the time Relay RL1 connected its C-NO connection, current flowed through C-NC connection of relay RL2 to activate coil of Relay RL4. When RL4 was activated, the two sets connection of its switch changed from C-NC to C-NO and C1-NC1 to C1-NO1. At this condition Output A which indicated by Lamp L1 was turned OFF as Shown in Figure 4. While the connection of C1-NO1 switched on Relay RL5 which then activated Output B and Lamp L2 was turned ON. The changed positions of switches of Relay RL4 are shown in Figure 4.
The Relay RL4 was in self-locked or latched condition when connection C-NO of RL4 connected. At this condition, Relay RL4 remained activated until the self-locked status was reset. The reset function for RL4 was carried out through the activation of Relay RL3. Relay RL3 was activated by C-NO connection of Relay RL 2. When Relay RL3 activated for resetting RL4, it disconnected the connection of coil RL4 from the negative terminal of the DC power supply. Once the reset connection of Relay RL3 achieved, the default connection status of C-NC was restored. The default connections of Relay RL3 were shown in Figure 3 and Figure 4. The default connections for RL1 which has similar operation scheme with RL3 are also shown in Figure 3 and Figure 4. In the circuit, Capacitor C1 and C2 functioned as elements to delay the Set and Reset process of Relay RL4. Capacitor C2 was used to delay timing of the self-locked condition of, while capacitor C1 was used to delay timing of reset process of Relay RL4. Diodes D1-D5 were used to block the reversed high current voltage generated when coils of Relay RL1-RL5 were switched on or switched off. The connection to RS-232 port of a PC was made at the connection between the voltage divider formed by R1-R2 and the Base terminal of Transistor TR1 as labelled ‘IN’ in Figure 3 and Figure 4. The list of electronic components used for the alternative external switching board shown in Figure 3 and Figure 4 are given in Table 2.
Table 2. List of Components for the Alternative External Switching Board
|Components Type||Values and Descriptions|
|Relay:||DC 9V / coil current max 250 mA with double switches|
|Resistor:||RL1-RL5: R1: 2.2k Ohm, R2: 22k Ohm,
R3=R4: 100 Ohm
|Switching Transistor:||2SC1062 (NPN)|
|Silicon Diodes:||D1-D5: 1N4002|
|Indicator Lamp:||L1 & L2: 9V DC / 100 mA|
|Capacitor:||C1=C2: 100 uF/16V|
V. Concluding Remarks
To conclude the discussion of the design and application of an external switching board which controlled by pulse voltage send via RS-232 port of a PC, here are important notes regarding the device.
- The changeover or switching speed of the device to switch between ON to OFF or from Output A to Output B and vice-versa were determined by the value of C1 and C2. The smaller the value of capacitor C1 and capacitor C2 the faster switching time or changeover achieved. However, the experiments showed that the applicable capacitance value for the device range from 10 – 470 uF.
- The voltage and current (VA) limit that could be handled by the device were determined by the peak voltage and current that could be passed by Relay contacts. Therefore, it is important to make sure that Wattage of the electric load and its peak current and operating voltage are matched with the current and voltage that could be handled by relay contacts.
- Alciatore, D. G., & Histand M. B., 2003, Introduction to Mechatronics and Measurements Systems, McGraw-Hill, New York.
- Bolton, W., 1996, Mechatronics – Electronic Control Systems in Mechanical Engineering, Addison Wesley Longman Ltd, Essex, UK.
- Alexander, C. K., & Sadiku, M. N. O., 2002, Fundamental of Electric Circuits, McGraw-Hill, New York.
- Mathworks Inc., 1999, Getting Started with Matlab Version 5.0, The Mathworks Incorporated, Natick, MA – USA.
- Mathworks Inc., 1999, Using Matlab Version 5.0, The Mathworks Incorporated, Natick, MA – USA.
Written by: Jonny Latuny – email: firstname.lastname@example.org
Mechanical Engineering Department, Universitas Pattimura
Jl. Ir. M. Putuhena, Poka – Ambon, Maluku 97000