Turn Raspberry Pi into a P.L.C (Programable Logic Controller) Advanced


181 posts   Page 7 of 8   1 ... 4, 5, 6, 7, 8
by DWomack » Thu Feb 06, 2014 11:47 pm
The CoDeSys Demo has two tasks. The Main task runs every 20 mSec. The Visualization (web) task runs every 100 mSec.

I changed the added code in the Main task like this:

REPEAT
rTemp := rTemp + 1.0;
UNTIL
rTemp = 200000.0
END_REPEAT;
rTemp := 0.0;

What this code does is increment a REAL variable and compares it to the end value of 200000.

Two hundred thousand additions and comparisons every 20 mSec.

The Linux top command shows the codesyscontrol. task is consuming 77% of the CPU.

WOW!

Now to repeat the test as LONG REALS...

I can't wait for the CoDeSys release in April.
Posts: 20
Joined: Thu Jan 30, 2014 11:55 am
by DWomack » Thu Feb 06, 2014 11:49 pm
The CoDeSys Demo has two tasks. The Main task runs every 20 mSec. The Visualization (web) task runs every 100 mSec.

I changed the added code in the Main task like this:

REPEAT
lrTemp := lrTemp + 1.0;
UNTIL
lrTemp = 200000.0
END_REPEAT;
lrTemp := 0.0;

What this code does is increment a LONG REAL variable and compares it to the end value of 200000.

Two hundred thousand additions and comparisons every 20 mSec.

The Linux top command shows the codesyscontrol. task is consuming 69% of the CPU.

WOW!

Don't know why LONG REALS are faster. Maybe LONG REALS are the native floating point in the Pi CPU hardware.

I can't wait for the CoDeSys release in April.
Posts: 20
Joined: Thu Jan 30, 2014 11:55 am
by DWomack » Fri Feb 07, 2014 3:20 am
Another CoDeSys on RaspberryPi Benchmark...

I have a background in PLCs and like the ladder language for general controls. The resulting program is easy to visually troubleshoot. The development tool will show you "power flow" through the contacts and coils. Ladder diagrams are familiar to electricians and engineers from the days of hardware relays, counters, and timers.

For this benchmark, I created a program, also called a POU in IEC 61131-3 terminology, and ran it as a part of the 20 mSec task.

The program (POU) has 10,000 lines of ladder code. Each line, also called a rung, has 4 relay contacts in series and is connected to a coil. Contacts and coils are BOOLEAN data.

This gives a pretty big control system. Think 10,000 real relays. I would hate to have to work on that system.

According to the tools in the development environment, this ladder program was executing in 3 mSec.

The linux top utility shows the codesyscontrol. task is consuming about 8% cpu.

That is super!


Dennis
Posts: 20
Joined: Thu Jan 30, 2014 11:55 am
by Richard-TX » Fri Feb 07, 2014 6:34 am
So what is the scan time from top to bottom and for how many rungs?
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
User avatar
Posts: 1297
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas
by DWomack » Fri Feb 07, 2014 11:13 am
10,000 rungs that look like this:

----------][---------------][----------------][----------------][-------------------------( )---------

Time to execute all 10,000 is about 3 mSec.

The CoDeSys Development software has the ability to monitor the execution times of POUs in a task.

POU is IEC 61131-3 speak for Program Organizational Unit.

The CoDeSys Development software can download the project source code to the RaspberryPi and open the project from the RaspberryPi. This means you can leave a copy of the project source in the controller, so others can maintain it.

3S Software has been working on this for roughly 20 years.

Check CoDeSys in Wikipedia.

The power of CoDeSys on the Pi is amazing. The integrated Web Visualization is cool.

I can't wait for release in April.


Dennis
Posts: 20
Joined: Thu Jan 30, 2014 11:55 am
by Rotule » Thu Feb 13, 2014 11:35 am
Its a pretty awesome tool!

i'd like to see if i'm able to integrate CAN communication trough SPI using codesys and a small board like this : http://www.industrialberry.com/can-controller/

it would be the only thing missing for a full featured PLC for me 8-)
Posts: 2
Joined: Wed Feb 12, 2014 7:48 pm
by vorrias » Thu Feb 13, 2014 9:22 pm
Yes @by Rotule
CAN bus on Raspberry is very good but an industrial PLC uses CANopen to communicate with inverters drives I/Os and so on.
CODESYS needs CANopen. This high level protocol is important and I think there is one CANopen stack open source (http://www.canfestival.org) that can implemented.
To see CANopen on Raspberry it will be fantastic as etherCAT of course which is supported in Raspberry by CODESYS
Beremiz which is free and I think it is ported in Raspberry by some nice people in this forum (www.beremiz.org) also supports CANopen.
So this little can bus interface is excellent addition!
Posts: 51
Joined: Mon Aug 15, 2011 3:31 pm
by Rotule » Thu Feb 13, 2014 11:23 pm
i don't really need the Canopen stack, i'm a pretty hardcore CAN user, i can do whatever i want just with the low level access to the module. i have done my own stacks for canopen and J1939 on multiple devices now :twisted: however, i never worked with linux so i'd like to use it in codesys for rpi :P

i understand that we need canopen to programm via can but i could live very well programming via TCP and using CAN just for the application :P however, that'd be cool to have it :lol:
Posts: 2
Joined: Wed Feb 12, 2014 7:48 pm
by moorsb » Fri Feb 14, 2014 3:04 pm
I am thinking the way to go is Modbus TCP and use Ardunio for I/O
I am trying to get the Codesys Demo to work but I am running into issues on the Raspberry side.
I do not see an icon for Codesys on the PI. How do you install the application ?
I am not a linux command line guy.
Posts: 3
Joined: Fri Feb 14, 2014 2:57 pm
by DWomack » Fri Feb 14, 2014 6:26 pm
Just like you can download images for Raspbian from this web site, you have to download an image from the CoDeSys store site.

They have it preinstalled in a Raspbian image.

CoDeSys runs as a daemon in the background. It starts automatically when the Pi boots. You have to run the development software on a Windows machine and point it to the Pi. There you develop your program and the visualization that runs as a web page put out by the Pi. When your program compiles cleanly you tell the development tool to go online. It then downloads the program to CoDeSys running on the Pi. It will let you download most program changes on the fly.

Hope this helps.


Dennis
Posts: 20
Joined: Thu Jan 30, 2014 11:55 am
by moorsb » Mon Feb 17, 2014 9:50 pm
I am using the demo codesys on Raspi and have added a Arduino to the mix to handle the I/O. Arduino has lots of code already done for most devices. I am using the modbus tcp protocol with the Arduino as a slave. I did run into an issue with Codesys not having CmpIecTask installed in the library. I contacted tech support and they gave me the fix. You fill in some tables for the Modbus Master task on the Raspberry and it polls the Arduino. I was hoping for Codesys to use the HDMI port for visualization but that is only available via the webserver on the the Raspi
Posts: 3
Joined: Fri Feb 14, 2014 2:57 pm
by Hodgy SatCom » Wed Feb 19, 2014 11:38 am
moorsb wrote:I am using the demo codesys on Raspi and have added a Arduino to the mix to handle the I/O. Arduino has lots of code already done for most devices. I am using the modbus tcp protocol with the Arduino as a slave. I did run into an issue with Codesys not having CmpIecTask installed in the library. I contacted tech support and they gave me the fix. You fill in some tables for the Modbus Master task on the Raspberry and it polls the Arduino. I was hoping for Codesys to use the HDMI port for visualization but that is only available via the webserver on the the Raspi


Would you be able to send me the fix for CmpIecTask, I've also been getting this error.
Cheers.
"Just move on up - Curtis Mayfield"
User avatar
Posts: 5
Joined: Wed Oct 02, 2013 10:56 am
by ranpitime » Fri Feb 21, 2014 3:30 pm
Hi,

the solution this is:

http://forum.codesys.com/viewtopic.php?f=21&t=5621

Hi,

there's an error in the device description of "CODESYS Control for Raspberry Pi".
This is only a problem if you use CODESYS V3.5.4.10.
I attached a corrected version of the device description. Just install this device (Tools -> Device Repository... -> Install...) and then update your device in the device tree (rightlick to that pi device update device).

that should solve it.
BR
Posts: 20
Joined: Sat Mar 23, 2013 5:21 am
by ranpitime » Mon May 12, 2014 7:24 pm
An Example for the CODESYS plc:
CODESYS and Raspberry Pi controls micro delta robot
https://www.youtube.com/watch?v=h9rLOWm ... e=youtu.be
Cheers
ranpitime
Posts: 20
Joined: Sat Mar 23, 2013 5:21 am
by DWomack » Mon May 12, 2014 8:06 pm
CoDeSys for the pi is supposed to be available for purchase at the end of May.
Posts: 20
Joined: Thu Jan 30, 2014 11:55 am
by DWomack » Tue May 13, 2014 1:58 pm
For more information on Delta Robots go to:

http://www.parallemic.org

The basic patent on the mechanism has now run out in both Europe and the United States. There are lots of suppliers showing up.

On some of the first systems, the software was written in Turbo Pascal.

They are commonly used in Pick and Place machines.
Posts: 20
Joined: Thu Jan 30, 2014 11:55 am
by Conrad Goodwin » Tue May 13, 2014 3:42 pm
This thread is really meaty.
I don't know PLC, and I haven't used my Rpi yet (I'm waiting for an HDMI-DVI cable! I think it boots because I can watch the act light), but I'm getting excited about the ability to control real switches from Debian. Thanks for your posts.
Cheers
Posts: 8
Joined: Fri May 09, 2014 3:23 am
Location: Puerto Octay, X Region, Chile SA
by ukscone » Fri Jun 06, 2014 3:02 pm
User avatar
Forum Moderator
Forum Moderator
Posts: 2800
Joined: Fri Jul 29, 2011 2:51 pm
by DWomack » Fri Jun 06, 2014 3:50 pm
Sorry, that's still the demo.

I have emailed asking when, but no answer yet.


Dennis
Posts: 20
Joined: Thu Jan 30, 2014 11:55 am
by DWomack » Fri Jun 06, 2014 7:44 pm
FYI

Now they say mid July for sure.


Dennis
Posts: 20
Joined: Thu Jan 30, 2014 11:55 am
by DWomack » Sat Jul 12, 2014 9:20 pm
Just checked...

End of July.

Patiently waiting.


Dennis
Posts: 20
Joined: Thu Jan 30, 2014 11:55 am
by jsobota » Mon Jul 14, 2014 11:08 am
Sorry to interrupt this thread, but in the meantime you might be interested in the REX Control System, which is a competitor of the CoDeSys system. See what you can do with REX on your RasPi:
http://www.rexcontrols.com/articles-category/tutorials
Posts: 34
Joined: Tue Jul 10, 2012 3:24 pm
Location: Plzen, Czech Republic
by wiseguy » Sat Jul 19, 2014 9:56 am
IEC 61131 Starter Kit for Raspberry Pi demo software
https://www.kw-software.com/en/company/ ... -downloads
Posts: 1
Joined: Sat Jul 19, 2014 9:51 am
by DWomack » Wed Jul 30, 2014 1:44 pm
CoDeSys for the Raspberry Pi is in final QA and is to be released tomorrow or Friday.


Dennis
Posts: 20
Joined: Thu Jan 30, 2014 11:55 am
by DWomack » Fri Aug 01, 2014 1:05 pm
CoDeSys has been released.

I just purchased and am now downloading.

More news to follow.


Dennis
Posts: 20
Joined: Thu Jan 30, 2014 11:55 am