Automation and Process Control Workshop
This workshop will combine engineering, science, and process control programming with some gameplay. My new virtual science lab will become the learning centre for this venture. The idea stems from my 28 years years in the process control industry, which was one of the most exciting times in my life. I have a great desire to try and communicate some of this knowledge and experience, in the best way possible for me... through the use of gameplay and computer simulation. In the relatively short space of 50 years the world has seen some amazing advances in the technology and scientific fields. However, I fear that the lack of youngsters taking up careers in this area will lead to future technologic stagnation, and eventual decline. I am of the hope that this project will allow me to throw at least one starfish back into the sea
The workshop will comprise a series of practical experiments, of gradually increasing complexity, whereby the user will be able to "wire" various control devices to a central process controller (termed Programmable Logic Controller, or PLC for short). Using a very basic script, the user will be able to program this PLC to perform various tasks by controlling its connected devices.
25/03/2013
Here is an overview picture of the initial "getting aquainted" Experiment #1:
It shows my "BlackBox" PLC, surrounded by some control devices... a motor, a push button switch, a potentiometer and a toggle switch.
A closeup of the PLC itself:
A closeup of the PLC itself:
Along each side of the PLC are a number of different colored ports... on the left are 8 red digital input ports (DINs), on the right are 8 green digital output ports (DOTs), at the front are 4 yellow analogue input ports (AINs), and at the back are 4 blue analogue output ports (AOTs). Situated at the centre of the PLC are 3 LEDs (Light Emitting Diodes)... a green 'heartbeat' running LED which will flash continually for a successfully running loaded script program, a red 'stopped' LED for a non-loaded or aborted program, and an orange flashing LED for a 'failed' loaded program script containing some syntax error.
I mentioned earlier, that the PLC must be "wired" to the devices that it will be controlling. In the real world this is actually true... physical wires do connect PLCs and their devices. However, in our virtual world, we would end up with a clutter of confused spaghetti on the workbench, so I take "poetic license" and make all connections "wireless". Now, you ask, how does one know which device is connected to which PLC port? Well, this is where "color coding" comes into the picture.
Lets look at all the devices used in this first experiment:
I mentioned earlier, that the PLC must be "wired" to the devices that it will be controlling. In the real world this is actually true... physical wires do connect PLCs and their devices. However, in our virtual world, we would end up with a clutter of confused spaghetti on the workbench, so I take "poetic license" and make all connections "wireless". Now, you ask, how does one know which device is connected to which PLC port? Well, this is where "color coding" comes into the picture.
Lets look at all the devices used in this first experiment:
Motor
Push Button Switch
Potentiometer
Toggle Switch
You will notice that each device has one or more colored nipples. This is the key... by equating the color to that of the port color on the PLC, you can tell if your device is to be connected to a DOT, a DIN, an AIN, or an AOT on the PLC. So, from this, one can conclude that the Push Button Switch and the Toggle Switch must each be connected to any of the 8 red DIN ports on the PLC and thus provide a digital ON/OFF input signal to your PLC program script. Likewise, the Potentiometer will supply a varying analogue signal via one of its 4 yellow AIN ports. The Motor, however, is a device that is to be driven by the PLC logic... and so it needs to be connected the output ports of the PLC.
It has two nipples... a green one for connection to one of the 8 green DOT ports of the PLC, which will provide an ON/OFF command to the Motor. The blue nipple is to be connected to one of the 4 blue AOT ports of the PLC, which will deliver a variable analogue signal to the Motor ( for the Motor this signal provides for speed control)
Ok, so now we know which device belongs to which set of PLC ports.
But how will your PLC script know which of the numbered ports to use?
The answer lies in the interactive method of making the connections. Let's take a closer look at connecting up the Motor to the PLC:
For my particular example, I require that the Motor be connected to DOT port #4 on the PLC.
A series of screen snapshots will demonstrate this.
1) Place the mouse cursor on the Motor's green nipple, like so:
It has two nipples... a green one for connection to one of the 8 green DOT ports of the PLC, which will provide an ON/OFF command to the Motor. The blue nipple is to be connected to one of the 4 blue AOT ports of the PLC, which will deliver a variable analogue signal to the Motor ( for the Motor this signal provides for speed control)
Ok, so now we know which device belongs to which set of PLC ports.
But how will your PLC script know which of the numbered ports to use?
The answer lies in the interactive method of making the connections. Let's take a closer look at connecting up the Motor to the PLC:
For my particular example, I require that the Motor be connected to DOT port #4 on the PLC.
A series of screen snapshots will demonstrate this.
1) Place the mouse cursor on the Motor's green nipple, like so:
2) While still on the green nipple, click the Left Mouse Button (LMB):
And at the same time the PLC DOT port #1 will light up orange, like so:
However, we do not require a connection to DOT port #1. We require a connection to DOT port #4
3) Each click of LMB will advance the port selection forward by one. So click the LMB three more times, ending up like so:
3) Each click of LMB will advance the port selection forward by one. So click the LMB three more times, ending up like so:
4) So now make the connection to PLC DOT port #4 by clicking the RMB, and the connection will be confirmed, as follows:
That's really all it is to set up device connections to the PLC ports?..easy, eh !
Just proceed in exactly the same manner for all devices that your PLC control script requires.
By placing the mouse cursor at any time over a device nipple you will get an appropriate message stating if the device is not connected, or that it is connected and to which port #.
You can change device connections by continuous left clicking on the nipple, which will cycle through the port numbers until you reach the one required, then click the mouse right button to connect (the previously connected port will be automatically disconnected)
You can only cycle forwards and not backwards. After the last port #, the cycle loops round to the first port # again.
You will see one other option in the cycle, namely:
Just proceed in exactly the same manner for all devices that your PLC control script requires.
By placing the mouse cursor at any time over a device nipple you will get an appropriate message stating if the device is not connected, or that it is connected and to which port #.
You can change device connections by continuous left clicking on the nipple, which will cycle through the port numbers until you reach the one required, then click the mouse right button to connect (the previously connected port will be automatically disconnected)
You can only cycle forwards and not backwards. After the last port #, the cycle loops round to the first port # again.
You will see one other option in the cycle, namely:
At this stage, I must mention that prior to publishing here, I had the program tested by a small number of 3D enthusiasts at the 3dfoundry forum (of which I'm a member). From the feedback I received, the general opinion was that, for a non-technical person, the above method was found to be rather complex. Taking heed of this advice, I added two extra buttons called INPUTS and OUTPUTS which, when activated, bring up two seperate window frames, that show which devices are currently connected to which PLC ports, and those devices which are unused (not connected) The feedback for this method was positive. So at this stage, both methods are active.
I've mentioned the PLC program script, and now is the time to take a closer look
I chose the AngelScript library since, through 3DRad, I was most familiar with it. I spent a week or two trying this and that, until I ended up with the VERY simple working version which is integrated into this current project application. You just write the script as an ordinary text file, using the SciTE AngelScript Editor , and load it into the application during runtime.
It will compile automatically and run. You can load scripts at any time while the application is running. The scripts are all stored in a designated folder called 'PLC_Scripts ' off the root folder of this application. This folder must not be moved nor its name changed. There are eleven scripts recognized by the system. These scripts also have designated names that must not be changed. The names are 'empty_script.as', 'script_01.as','script_02.as', 'script_03.as' .......up to 'script_10.as'The script called
' empty_script.as' is a template to which you add your own code in a designated area within the script. Two of the scripts ( 'script_01.as' and 'script_02.as' ) contain some simple example code for two of the tasks in this particular demo. The remaining scripts are just copies of 'empty_script.as', to be used by the user for experimentation purposes.
Just a few steps as to how to proceed when up and running:
1) I've included the SciTE AngelScript Editor in the download for this project. It can found in its own folder included within the PLC_Scripts folder off the installation folder of this PLC app. Start it up and open the script_01.as AngelScript text file:
I chose the AngelScript library since, through 3DRad, I was most familiar with it. I spent a week or two trying this and that, until I ended up with the VERY simple working version which is integrated into this current project application. You just write the script as an ordinary text file, using the SciTE AngelScript Editor , and load it into the application during runtime.
It will compile automatically and run. You can load scripts at any time while the application is running. The scripts are all stored in a designated folder called 'PLC_Scripts ' off the root folder of this application. This folder must not be moved nor its name changed. There are eleven scripts recognized by the system. These scripts also have designated names that must not be changed. The names are 'empty_script.as', 'script_01.as','script_02.as', 'script_03.as' .......up to 'script_10.as'The script called
' empty_script.as' is a template to which you add your own code in a designated area within the script. Two of the scripts ( 'script_01.as' and 'script_02.as' ) contain some simple example code for two of the tasks in this particular demo. The remaining scripts are just copies of 'empty_script.as', to be used by the user for experimentation purposes.
Just a few steps as to how to proceed when up and running:
1) I've included the SciTE AngelScript Editor in the download for this project. It can found in its own folder included within the PLC_Scripts folder off the installation folder of this PLC app. Start it up and open the script_01.as AngelScript text file:
2) You will have to examine the user code in this script so that you will know what connections to make to the PLC:
Line 46 tells us that the script requires ToggleSwitch_01 to be connected to DIN_01, and Potentiometer_01 to be connected to AIN_01. These are Inputs to the PLC script.
Line 48 tells us that the script is sending a digital signal to Motor_01 via DOT_04. So this requires that you connect Motor_01 (green connection) to Output DOT_04.
Line 49 tells us that the script is sending an analogue signal to Motor_01 via AOT_01. So this requires that you connect Motor_01 (blue connection) to Output AOT_01
You, the user, need only write your program in the area indicted. This area is continually executed. There is no need to concern yourselves with the non-designated areas of the script. If you use global variables in your program then declare them just above 'void main()'. Otherwise, you should be able to use all the AngelScript syntax that you are used to from 3DRad. You will obviously NOT be able to use any of the 3DRad related functions, but you can build up your own.
The in-built variables supplied by my application are:
Eight booleans which are read-only: DIN_01 to DIN_08
Eight booleans which are write-only: DOT_01 to DOT_08
Four floats which are read-only: AIN_01 to AIN_04
Four floats which are write-only: AOT_01 to AOT_04
At this stage, I provide only one function for your use, namely 'bool Wait(int number_of_msec)'
Thus, using these output variables in your own logic you will be able to control the devices which you have connected to the PLC, based on the values of the input variables, or any value you supply by means of your own global variables. The best way to get the gist of this is to study my two example scripts, make the required PLC-to-device connections, and run the script. Experiment by changing to your own logic statements and input/output connections.
3) You can now use the PLC app. to make the connections via one of two methods: the engineer's method or the non-engineer method. I've already posted instructions on the first method, and the second method I'd like you to figure out for yourselves, using the INPUTS and OUTPUTS buttons. I'm sure you'll find it pretty straightforward: just use the mouse and follow the 'help tip' mouseovers.
4) Once all is connected, use the SCRIPT button to bring up the SCRIPT sub-menu and use it to replace the currently running empty_script.as with the script_01.as
Line 48 tells us that the script is sending a digital signal to Motor_01 via DOT_04. So this requires that you connect Motor_01 (green connection) to Output DOT_04.
Line 49 tells us that the script is sending an analogue signal to Motor_01 via AOT_01. So this requires that you connect Motor_01 (blue connection) to Output AOT_01
You, the user, need only write your program in the area indicted. This area is continually executed. There is no need to concern yourselves with the non-designated areas of the script. If you use global variables in your program then declare them just above 'void main()'. Otherwise, you should be able to use all the AngelScript syntax that you are used to from 3DRad. You will obviously NOT be able to use any of the 3DRad related functions, but you can build up your own.
The in-built variables supplied by my application are:
Eight booleans which are read-only: DIN_01 to DIN_08
Eight booleans which are write-only: DOT_01 to DOT_08
Four floats which are read-only: AIN_01 to AIN_04
Four floats which are write-only: AOT_01 to AOT_04
At this stage, I provide only one function for your use, namely 'bool Wait(int number_of_msec)'
Thus, using these output variables in your own logic you will be able to control the devices which you have connected to the PLC, based on the values of the input variables, or any value you supply by means of your own global variables. The best way to get the gist of this is to study my two example scripts, make the required PLC-to-device connections, and run the script. Experiment by changing to your own logic statements and input/output connections.
3) You can now use the PLC app. to make the connections via one of two methods: the engineer's method or the non-engineer method. I've already posted instructions on the first method, and the second method I'd like you to figure out for yourselves, using the INPUTS and OUTPUTS buttons. I'm sure you'll find it pretty straightforward: just use the mouse and follow the 'help tip' mouseovers.
4) Once all is connected, use the SCRIPT button to bring up the SCRIPT sub-menu and use it to replace the currently running empty_script.as with the script_01.as
You use the arrows to cycle forward and back through the scripts. The LOAD button will load the selected script into the PLC and the PLC red "stopped" status LED will be lit. If the PLC orange 'fault' light starts flashing then this means that there is a syntax error in your script, and you will have to load the script into your text editor (SciTE) and try to locate and correct the error.
( NOTE: When the demo is initially started a default empty 'do nothing' script is running in the PLC, so the user will have to select and LOAD to change to a script which does do something.... the supplied example script 'script_01.as' can be used ). A loaded script is run by activating the RUN button, and the green 'heartbeat' LED will flash, indicating that your script is running. If you have programmed your logic correctly, and you have all the relevant I/O connected, then your devices will do their thing.
5) When you have the script running, then test all is working correctly by switching on the ToggleSwitch_01, and turning the Potentiometer_01 knob to the right to increase the motor speed from nil to max. Also, ensure your sound system is on, to hear the change of frequency as the motor speed is increased.
To really get familiar with the application:
a) change the I/O connections then edit the script accordingly.
b) load up script_02.as and change the connections accordingly.
c) rename my example script Experiment1Task3.as to script_03.as and load/run it.
d) write your own script as script_04.as
Just a last word on the remaining command buttons at the bottom of the screen:
HELP
Toggles a help window listing user navigation and object manipulation commands
ABORT
This will stop a running script and close off all PLC outputs, but leave all connected I/O intact. The green 'running' LED will go off, and the red 'stopped' LED will come on.
RESET
Same as for ABORT, except that all I/O devices will be disconnected from the PLC.
EXIT
Exits the demo.
The app. should be run in its default windowed mode (800x600) so that your SciTE AngelScript Editor can be run in conjunction as follows:
( NOTE: When the demo is initially started a default empty 'do nothing' script is running in the PLC, so the user will have to select and LOAD to change to a script which does do something.... the supplied example script 'script_01.as' can be used ). A loaded script is run by activating the RUN button, and the green 'heartbeat' LED will flash, indicating that your script is running. If you have programmed your logic correctly, and you have all the relevant I/O connected, then your devices will do their thing.
5) When you have the script running, then test all is working correctly by switching on the ToggleSwitch_01, and turning the Potentiometer_01 knob to the right to increase the motor speed from nil to max. Also, ensure your sound system is on, to hear the change of frequency as the motor speed is increased.
To really get familiar with the application:
a) change the I/O connections then edit the script accordingly.
b) load up script_02.as and change the connections accordingly.
c) rename my example script Experiment1Task3.as to script_03.as and load/run it.
d) write your own script as script_04.as
Just a last word on the remaining command buttons at the bottom of the screen:
HELP
Toggles a help window listing user navigation and object manipulation commands
ABORT
This will stop a running script and close off all PLC outputs, but leave all connected I/O intact. The green 'running' LED will go off, and the red 'stopped' LED will come on.
RESET
Same as for ABORT, except that all I/O devices will be disconnected from the PLC.
EXIT
Exits the demo.
The app. should be run in its default windowed mode (800x600) so that your SciTE AngelScript Editor can be run in conjunction as follows:
Here's the installer for this app. (approx 17Mb):
(Latest version (20th April 2013) - a couple of small improvements added)
(Latest version (20th April 2013) - a couple of small improvements added)

automationworkshop_experiment01_installer.zip | |
File Size: | 18222 kb |
File Type: | zip |