Skip to main content

Getting Started with RevPi Core 3 for PLC Applications

RevPi_top_9ab283f210492fd7d6a1951074c55ed94af0c3b3.jpg

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 (181-1142) , 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

RevPi_as_PLC2_b0a73f5369b65deed3d6fcbae4469c7ef0ecaba0.jpg

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.

Hardware setup

RevPi_as_PLC_62e5239a1bf9339949e36f7959242b66ef94de3e.jpg
I mounted the Revolution Pi core 3 module, a DIO module (181-1143) and some terminal blocks on a short length of DIN Rail (742-4138) fixed to a piece of laser cut MDF. Three 24V Led lights (763-7915) 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.

Support resources

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.

RevPi-setup_51c4ca4ebeed8ceac3fb855cfe6e40e4b514002c.png

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.

unknown_system_library_718497e2902e801ba5bc9925745456793665dacd.png

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".

logiCAD3Templates_5fbd8d1b7b206159b783942e3040afdd258c1750.png

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.

logiCadSample2_933c450231cbf2d798544e2e3c2a696d1250aada.png

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.

PiCtory_config_export_9f38bfddd634405c58638ab1d8ce77b42fde7fcf.png

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.

PiCtory_config_export2_794c0a959b8a79d30de81ca0787a5e2f76252033.png

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.

What Next?

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.

I have a background in the arts, environmental conservation and IT support. In my spare time I do a bit of DJing and I like making things.
DesignSpark Electrical Logolinkedin