Starting with CODESYS on the Raspberry Pi

NOTE THIS POST IS OUT OF DATE. Please see starting-with-codesys-on-raspberry-pi

I’ve finally decided to give CODESYS a try on the Raspberry PI. This post tracks what I had to do to get CODESYS functioning, I’ll post more on sample projects in the future.

First of all, my setup: I’m running a fresh install of Windows 8.1 x64 in a virtual machine hosted on vmware Fusion on a Macbook Pro. I have a Raspberry Pi 2 connected by ethernet on my local network, the virtual machine is bridged so that it is on the same subnet as the Raspberry Pi. I am using an 8Gb SanDisk Ultra microSDHC card.

Installing CODESYS on Windows

I downloaded CODESYS V3.5 SP6 Patch 3 from CODESYS download area (You need to register, but then the download is free). I then ran the installer accepting all defaults.

CODESYS on the Raspberry PI

CODESYS for the Raspberry PI is available as a free download from the CODEYS store, again you have to register to get access, and again this is free. I downloaded  CODESYS_Control_for_Raspberry_PI.zip, and unzipped it to give me a folder with the following content.

Installation basically consists of two parts, firstly updating the CODESYS IDE with a package to add support for the Raspberry Pi, and secondly loading a runtime image onto an SDCard. 

Installing the package

I launched CODESYS V3.5 SP6 Patch 3 from the link on the windows desktop, selected the Standard environment when prompted. I then launched the Package Manager from Tools/PackageManager… I then selected Install… and browsed to the CODESYS_Control_for_Raspberry_PI package,

I then accepted the license agreement and all defaults

(Take a note of the target directory), Allow UAC to make changes.
I clicked Finish

Then clicked Close before exiting CODESYS.

Loading the Image

Following the advice in the product data sheet I downloaded and installed Win32diskimager 0.9.5 from http://sourceforge.net/projects/win32diskimager/. I plugged the microSDHC card into an SDCard carrier and then plugged this into a USB SDCard reader (The internal SDXC slot on my MacBook is not recognised by vmware Fusion, see vmware kb1035825). I then launched Win32DiskImager, and browsed to codesysrasp35620.img in the directory I had previously unzipped, selected device G: which corresponds to the SDCard, and clicked Write.

Programming the card took a few minutes, I then clicked Exit. Using Windows Explorer I was able to see the content of the SDCard,

still using Windows Explorer I right clicked on the device and selected Eject, before physically removing the card from the reader.

I then plugged the card into my Raspberry Pi and powered it on. Notice in the startup messages
codesyscontrol started
At the login prompt I entered the default credentials, username pi, password raspberry.
I chose at this point to expand the filesystem to fill the available space on the card, so at the command prompt
sudo raspi-config


I selected the option to Expand Filesystem, then tabbed to Finish and rebooted.

Testing the Installation

I launched CODESYS V3.5 SP6 Patch 3 and then from the Start Page selected New Project…

I selected the default type of a Standard project gave it a name and clicked OK.

I then selected the Device and programming language I wished to use.
This created a project with this content below

I then double clicked the Device (CODESYS Control for Raspberry Pi) which brought up the Communications Settings tab for the device.

I selected Scan Network, this found the device, which I selected and then clicked OK.

Now we are connected to the Raspberry Pi. 

Posted in Uncategorised and tagged , .

14 Comments

  1. Hi! Thanks for a great tutorial! I have a problem finding my Raspberry Pi 2 on the network. I can SSH into it from the same PC I am running Codesys on. Do you know what I am doing wrong?

  2. thanks for the blog. I have a error when booting 'openbox syntax error llxde-pi-rc.xml line 1 with message:start tag expected '<' not found
    Should I ignore or solve the message ?

    thanks

  3. I haven't seen this issue, I've had a look on the CODESYS forum , which is often helpful but didn't find anything. A bit of googling and I found this which looks helpful.
    This isn't a CODESYS issue as such, and I don't think it will cause you issues unless you are using the Pi desktop (startx). Having said that I don't like seeing any errors – so personally I would fix the issue. Good luck.

  4. You need to register with 3S on the website to download CODESYS and register with the CODESYS store to download CODESYS for the Raspberry Pi. If you have problems registering or finding the content that you need please contact 3S.

  5. Hi tigerbajs, there are several possibilities.
    1) I think the most likely cause is a firewall on your PC. If you can temporarily disable the firewall that would show if this was the cause.
    2) CODESYS on the Raspberry Pi without a license is for evaluation and will timeout after 2 hours. So if it is more than two hours after you started your RPI then reboot the RPI and try again.
    3) I have seen the gateway on the PC get confused. From the Communications Settings tab on the device, select Gateway->Manage Gateways, then select the gateway, delete it, then click add, accept the defaults and close the window, scan the network – this may work.
    When you get it working please post another comment to help others – good luck

  6. I'm afraid I am confused, you are the second person who has said that they cannot locate the .rar file. I don't mention any .rar file in the post, what is making you think that there should be a .rar file? The files to be downloaded are a windows executable that installs the codesys IDE on windows, then there is a ZIP file with the support for the Raspberry PI. In that ZIP is a .package file that extends the CODESYS IDE with support for the RPI, and a .img file which is a binary image of an SDCard for the RPI.

  7. Hi David,

    EtherNet/IP communication tra Raspberry PI2(scanner) and a PLC work fine.
    But if I reboot the raspberry the communication does not work.
    To start the communication it need a hot reset or a cold reset.
    How is it possible to run the communication itself after a reboot?
    Thank you

  8. Hi Fabio,
    I'm sorry but I don't have direct EtherNET/IP experience on the Raspberry PI. My guess would be to look at the devices tree to see which is the top device to have failed, is it the Ethernet device, the EtherNET/IP Scanner or the slave? Whichever one it is have a look at the detail for the reason for the failure of the device. That may give you enough of a clue, if not then I'd then try posting the detail in the CODESYS forum, people are usually pretty helpful an responsive there.
    Good luck
    David

Comments are closed.