How do you feel about this article? Help us to provide better content for you.
Thank you! Your feedback has been received.
There was a problem submitting your feedback, please try again later.
What do you think of this article?
Hardware setup, configuration and an introduction to logi.CAD 3.
As a result of flood alleviation work that has been ongoing in the valley where I live for over 2 years now, temporary traffic lights have become a regular feature on our roads. I had a discussion with my colleague about how we should be in the temporary traffic light hire business – we would be very rich by now! We then started wondering how difficult it would be to make a set of lights, after all the modern ones are only LED lights controlled by some kind of microprocessor.
When I saw a project he was working on involving the Revolution Pi Core, it looked like just the thing, so, just out of curiosity, I set about seeing how easy it would be to create a solution based around the platform. This can be programmed in a variety of different ways, but since this is an industrial application and would need to be highly reliable, a PLC approach was decided upon.
The Revolution Pi as a classic PLC
A PLC (Programmable Logic Controller) is a computer specifically designed to control manufacturing processes. They were first developed in the car manufacturing industry to replace the complicated, hard wired, collection of relays, timers and sequencers that had previously controlled the manufacturing process and that were difficult to update when, for example, the production line changed to a new model of car. When computers were initially used to replace this system they required specialist programmers and needed a clean, temperature controlled environment in which to operate — obviously not ideal, so PLC was developed as a robust system that could be more easily programmed using a standard set of instructions.
Fast forward to today and the RevPi platform builds on these principals by utilising the Raspberry Pi in a robust industrial enclosure, so it benefits from the extensive Raspberry Pi ecosystem and software support, but can also be programmed as a PLC compliant with the IEC 61131 standard. In addition it features DIN rail mounting and is a modular system with protected inputs and outputs.
If you’d like to find out more about the platform, you can read my colleague Andrew Back’s introduction to the Revolution Pi here.
I mounted the Revolution Pi core 3 module, a DIO module and some terminal blocks on a short length of DIN Rail fixed to a piece of laser cut MDF. Three 24V Led lights were then connected using the 3 first outputs on the Revolution Pi DIO. 24V was supplied via a bench power supply.
The initial RevPi and DIO configuration are done via the PiCtory application that runs in a web browser and this process is outlined in the previously linked blog post.
In common with the majority of PLCs, the programs for the Revolution Pi are written on a PC and then downloaded to the module over the network. I am using logi.CAD 3 to create the control applications for the Revolution Pi, as per the Quick Start Guide on the Kunbus website, which includes a link to download the software.
There is also a tutorial on the logi.cals (the developers of logi.CAD 3) website that offers slightly different information. In practice, I found it helpful to refer to both of these and supplement that with a look at the tutorial on YouTube, although it is in German, there are English subtitles.
Installing and using Logi.CAD 3
First of all, I went back to the Revolution Pi setup page in my web browser, selected the Services tab and enabled Logi.RTS. This was a step I only found in the video tutorial and enables the run-time for the PLC programming environment.
Once that was done I installed Logi.CAD 3, which was simply a case of unzipping it, although I did need to use something other the Window’s native un-zipper, as that cannot handle the length of some of the file names. Once again 7Zip came to the rescue.
Next, I launched the program by double-clicking the logiCAD3.exe file (I put a shortcut to this on my desktop for ease of use in the future). I was asked where I wanted “Workplace” files saved and just chose the default. I was then greeted by a Windows security alert as the Windows Firewall had blocked some features of the program, so I clicked “Allow Access” and waited for the program to start.
At this stage, I was following the video tutorial and all was going well until I tried clicking the Build and Load button to send the "RevolutionPiTutorial17" project I had downloaded to the RevPi Core 3.
At this point, I was greeted with an error message, so I contacted Kunbus Support and they got back to me with a link to a forum post outlining how to fix the problem. Since this was in German, Google Translate was used and I then discovered that if I simply deleted 2 folders, the project would build and load fine.
In the meantime, I went back to the Quick Start Guide. I had initially given up on it after trying to open the sample project it called ‘“logi.CAD3 KUNBUS Revolution Pi Projekt” in the “logi.CAD3 Beispielprojekte für Hardware-Anbindung” file and not being able to find it anywhere.
The logi.CAD tutorial also names a project file that I could not find, but after a rummage around, I did find a sample project for the RevPi by opening the File menu, going to New/Project... and opening "Logi,CAD 3 Templates".
In there I found "logi.CAD 3 Project for Revolution P" so opened that and called it "Sample" when prompted for a "Project Name" and saved it in the default location.
Once this was opened I could follow the instructions in the guide to input the IP address of the RevPi in the globals/sample file.
Then back to PiCtory. I checked the configuration that had already been set up for me and altered the names of the 3 Outputs that I would be using and then saved the configuration by going to File/Save and then activated it with by clicking on Reset Driver in the Tools menu.
I then needed to export the configuration details to use in logi.CAD 3. This is done in File/Export, selecting Structured Text IEC 61131-3 in the pop up box, selecting “show only” and the global variables will be created and opened in a window.
Copy the contents of the window and go back to logi.CAD3, open the sample.global file in the globals folder, delete its contents and paste the text from the clipboard.
I then replaced the code in the RevolutionPiProgram.iesct file with the code found in the guide:
PROGRAM RevolutionPiCounterProgram VAR value : BOOL; END_VAR VAR_EXTERNAL RevPiLED : BYTE; Output_Pin_1 : BOOL; END_VAR IF value THEN RevPiLED := 0; Output_Pin_1 := False; value := False; ELSE RevPiLED := 1; Output_Pin_1 := True; value := TRUE; END_IF; END_PROGRAM
Then switch to the Instances View by clicking the tab at the top of the left-hand column and select RevolutionPi/RevolutionPiResource. Clicking the green gear icon to connect to the Revolution Pi and then the “Build and Upload” button. I could then see the LED on the RevPi Core3 and the LED connected to Pin 1 on the Revolution PI DIO flashing on and off.
Now all I need to do is to work out how to turn the lights on and off in the standard traffic light sequence, which is going to involve getting to grips with the basics of the PLC programming language/environment and will be covered in a future post.