CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Wed Nov 20, 2019 11:15 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 29 posts ]  Go to page 1 2 Next
Author Message
PostPosted: Mon Sep 10, 2018 1:23 pm 
Offline

Joined: Sat May 23, 2015 1:28 pm
Posts: 20
Hi,

I'm sorry if this question has been asked before. I'm teaching an IEC 61131-3 Automation class full of Electronics Enthusiasts. Thus instead of using our Beckhoff PLC's i'm using Codesys Raspberry Pi's and a handfull of I2C and SPI chips.

I've researched and reviewed a number of documents and youtube videos but the closest i came to finding an awnser to my question was in the "raspberrypi_codesysv3_firststeps_en__2_.pdf" document where it states:

Quote:
There are three typic ways to connect and run additional hardware via the i²c, spi or 1-wire interface:
1. Program a function block (FB) and declare and call an instance of it in your application
2. Program a function block (FB) and a device description file for a specific hardware that allows to insert and configure this device in the CODESYS device tree
3. Program an IO driver


Unfortunately ... The same document says a little further:

Quote:
Option 3 requires detailed knowledge of CODESYS and the IO driver concept and is out of the scope of this document.


I would however really like to make an IODriverLibrary for say the PCF8574 with my students. Can someone please point me to the right examples and / or manuals.

Kind regards,

Koen Kempeneers


Top
   
PostPosted: Mon Sep 10, 2018 3:10 pm 
Offline
User avatar

Joined: Fri Feb 10, 2017 6:12 am
Posts: 59
Cases 2 and 3 are rather complicated. There are descriptions and manuals on how to do this, but studying them will require a lot of time and perseverance. There are examples of drivers, but they are included in a special kit for developers. I don't know why, but for some reason, there is no such set for RPi.

So, you need to request a complete set of documentation and examples (SDK) from the Codesys developers. Even if you get it, it will be very difficult to understand without help. But no one will answer your questions.


Top
   
PostPosted: Mon Sep 10, 2018 8:11 pm 
Offline

Joined: Mon Dec 13, 2010 3:02 pm
Posts: 54
Hi!

If you are interested in programming for CODESYS, I'd like to invite you to the beta program of CODESYS Forge. I already wrote some descriptions about I/O drivers. Maybe it could help you. It depends a bit on your experience:

https://forge.codesys.com/drv/io-drivers/doc/Generic/

Of course you are heartly invited to share your code with us. To make the handling with SVN a bit easier you can use CODESYS SVN for free, and the extension cforge can help you to export the code, so that it can be browsed as markdown text.

https://forge.codesys.com/tol/cforge/home/Home/

https://store.codesys.com/codesys-svn.html

BR,
Ingo


Gesendet von meinem LG-H870 mit Tapatalk


Top
   
PostPosted: Tue Sep 11, 2018 10:59 am 
Offline
User avatar

Joined: Fri Feb 10, 2017 6:12 am
Posts: 59
Ingo, very interesting project, thank you. But the real SDK contains much more docs, templates and other things. I wonder, are they available for public access?

Quote:
Every device, which you can add to your CODESYS project, is described in an XML format inside of a Device Description.
For finetuning and to get a deeper understanding of the format, please check out the schema file. In the following we will just explain the basics to enable you to write your first description.

Where we can download schema file?

Quote:
To make the handling with SVN a bit easier you can use CODESYS SVN for free

Will it really work without usb-keys? Only with cforge?

Is registration required for use cforge?


Top
   
PostPosted: Tue Sep 11, 2018 7:45 pm 
Offline

Joined: Mon Dec 13, 2010 3:02 pm
Posts: 54
1) You're right, that there is an SDK for hardware vendors, who develop their own CODESYS programmable controllers. This contains much more than just those few examples. But I will do my best to improve the available examples over time. Just let me know if you lack a specific information.

2) I just added a link to the XML schema

3) You don't need a USB key to use CODESYS Forge with CODESYS SVN. Explicitely repositories on CODESYS Forge can be freely accessed. And the tool cforge should help you a bit with typical tasks, like:
- checking in and out multiple libraries
- creating CODESYS packages
- building packages
- exporting IEC code as markdown, so that it can be browsed from the web page

4) You need to register. But this time with a so called CODESYS Account. That's the first step to single sign on ;)


Gesendet von meinem LG-H870 mit Tapatalk


Top
   
PostPosted: Tue Sep 11, 2018 8:25 pm 
Offline

Joined: Wed Nov 23, 2016 2:33 pm
Posts: 74
Hi @all,

i have done some Drivers for i2c. Take a look to
https://github.com/stefandreyer/I2C-Multiplex
to check out.

If you know how to create an Driver it is realativ simple.

I startet to write a dokument About it but it isn't finished at all.

i'll try to give you an overview…

1st you have to make the part description XML. With this XML you have to describe you device ...

You have to define the lib an the Version of the lib the Devise is using.

Additional you have to describe the config view of the device. like i2c address. These are under HostParameterSet.

Them you will find later in the device tree view of codesys.

This config data is loaded by the initialize method of your device fb.

then you have to set _iState to 10 and your device will be green in the online view :D

the Methods AfterReadInputs and BeforeWriteOutputs are called by System an in them you have to do your communication by read and write command of the i2c fb from Raspberry Pi Peripherals lib.

The initialize method from my I2C_Base FB from my I2C Mux library loads the Parameters 1-10 of the device an the Parameters from 20 loaded by every child of the fb individually.

confused at all?

then ask…

BR Stefan


Top
   
PostPosted: Wed Sep 12, 2018 10:08 pm 
Offline

Joined: Mon Dec 13, 2010 3:02 pm
Posts: 54
Hi Stefan,

what a great driver collection! I'd love to see your drivers as a project on CODESYS Forge.

I wrote a short migration guide for you:
https://forge.codesys.com/forge/wiki/Mi ... 0Projects/

Best regards,
Ingo

Gesendet von meinem LG-H870 mit Tapatalk


Top
   
PostPosted: Thu Sep 13, 2018 12:15 pm 
Offline

Joined: Wed Nov 23, 2016 2:33 pm
Posts: 74
Hi Ingo,

do i need a SVN Licenzen to use cforge?

What kind of SVN plugin do i need from the store?

BR

Stefan


Top
   
PostPosted: Thu Sep 13, 2018 2:55 pm 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3539
Hi,

the package (demo and fullversion) of these two is the same... !
So no mather which you download and install.. both could deal with CODESYS Forge.
Just install it no need to order it...!

Please ignore the message which states you need a license and a dongle (this message will be removed soon)

BR
Edwin


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Thu Sep 13, 2018 3:08 pm 
Offline

Joined: Mon Dec 13, 2010 3:02 pm
Posts: 54
Hi Stefan,

I know that it's unbelievable, but the CODESYS SVN package is for free for the use with CODESYS Forge ;)
Just download and install it, and you can connect to every repository on the URL https://forge.codesys.com/svn/.

I added some links to the description, which I have sent you.
The tool "cforge" is just a recommendation. I developed it, as it felt more comfortable for myself, when dealing with a lot of packages and libraries. In fact I am using a combination of CODESYS SVN, Tortoise SVN and cforge. You just need to play around with the different tools to get a feeling for it. But for the use with CODESYS Forge, all is free.

Best regards,
Ingo


Top
   
PostPosted: Thu Sep 13, 2018 3:16 pm 
Offline

Joined: Sat May 23, 2015 1:28 pm
Posts: 20
Woow ...

I didn't think to get started this fast. I'll review all supplied information over the next few days. I'd be happy to contribute to Codesys Forge.

Thanks guys, thanks a lot!

Koen


Top
   
PostPosted: Thu Sep 13, 2018 5:44 pm 
Offline

Joined: Wed Nov 23, 2016 2:33 pm
Posts: 74
Hi Koen,

please let use know if you can deal fine with creating driver or not. I would be happy if the Knowledge from here can help other to develop Drivers.

I will have al look to codesys forge.

BR Stefan


Top
   
PostPosted: Thu Sep 13, 2018 7:05 pm 
Offline

Joined: Sat May 23, 2015 1:28 pm
Posts: 20
Hi Stefan,

I'm just playing around with the XML devdesc file for now. I have edited some entries and merged entries from the PiFaceIoDrv devdesc xml file. I ended up with a custom device called "PCF8574_OutputDrv" I can load that device in the device tree.
And I get the device configuration page that allows to map the outputs to variables ... All done with just the Microsoft's Code Writer App. I understand that there is a tool from within Codesys that creates the xml devdesc file but, where? :?
Attachment:
DevConfiguration.png

One of the upside ... Our principal will be honoured to see our school in de vendor list. 8)
Attachment:
Insert Device.png

The next thing to do is figure out how the mapped variables are to be treated by the library FB.
I sure hope those screenshots are visible. :?

Kind regards
Koen


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Thu Sep 13, 2018 7:23 pm 
Offline

Joined: Wed Nov 23, 2016 2:33 pm
Posts: 74
Hello Koen,

i see the screenshots.

i can't help you with the maping of the variable. I never used them, i communicate direct with the FB instances.

Quote:
I understand that there is a tool from within Codesys that creates the xml devdesc file but, where?


--> I think this is just a Excel to XML converter 8) i am using notepad++


BR Stefan


Top
   
PostPosted: Thu Sep 13, 2018 10:50 pm 
Offline
User avatar

Joined: Fri Jan 19, 2018 3:38 pm
Posts: 77
Hi @all,

Sorry to interupt here but I have written an IO driver...

The info in Codeys Forge will hopefully be very useful to me as I still need to complete some code/issue's in my driver for the Monarco Hat (see my git for the package) which is IO parameter based.

My experience in writing the IO driver is very similair in what @Viacheslav Mezentsev already mentioned, the learning curve is very steap if you do not have access to the toolkit (which I did'nt). So, it took me a great time to read up on various manuals which you can only find via google if you know what you are looking for.
Also I reversed engineered existing code examples for parameter based IO drivers, but good luck on finding them, they are rare in the wild allthough a few good examples are found within this forum. Offcourse this means that most of us enthusiasts written drivers are FB based.

If I would have had access to the Codesys developer toolkit (devkit) my expectation is that the driver was 100% working and finished by now because of the better quality in examples/documentation.
But alas, I had to do everything manualy because I do not have access to the toolkit. As earlier post explained, the toolkit purpose is to assist system integrator in creating their own runtimes (like ABB, Schneider etc) and creating their own hardware drivers and much more. As far as I know the creating of IO drivers can be achieved using embedded C or pure IEC or a mix of these.

Maybe codesys can release a smaller version of this toolkit especially for enthusiasts like me to assist in creating small but proper IO drivers without all the tedious manual labour involved. Writing the devdescr is fun but after import trying to couple it to the physical parameters is very very time consuming and error prone without proper debugging experience!


Tools/knowledge involved which I used;

- 2 * Codesys IDE simultaniously opened : 1 for Project, 1 for the Library,
- Notepad++ for editing the .devdesc.xml,
- Documentation to read up on architecture knowledge of how to setup an IO driver,
- Example code to study to understand the mechanism involved which couples the defined parameters from the xml to the codesys IO driver,
- Package manager to deploy the end result in a professional manner.

Offcourse you can download my package and study it as it 100% open source ;-)


Please visit https://github.com/Aliazzzz/Monarco-HAT-library-for-CODESYS-V3 for details on my IO driver

_________________
CfUnit, free and open-source IEC61131-3 unit-testing framework
My profile


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 29 posts ]  Go to page 1 2 Next

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited