Creating an I/O Driver for custom hardware.

Runtime
2018-09-10
2019-01-23
1 2 > >> (Page 1 of 2)
  • KKempeneers

    KKempeneers - 2018-09-10

    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:

    Zitat:
    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:

    Zitat:
    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

     
  • Anonymous - 2018-09-10

    Originally created by: Viacheslav Mezentsev

    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.

     
  • Ingo

    Ingo - 2018-09-10

    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

     
  • Anonymous - 2018-09-11

    Originally created by: Viacheslav Mezentsev

    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?

    Zitat:
    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?

    Zitat:
    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?

     
  • Ingo

    Ingo - 2018-09-11

    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

     
  • Stefan2

    Stefan2 - 2018-09-11

    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

    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

     
  • Ingo

    Ingo - 2018-09-12

    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

     
  • Stefan2

    Stefan2 - 2018-09-13

    Hi Ingo,

    do i need a SVN Licenzen to use cforge?

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

    BR

    Stefan

     
  • eschwellinger

    eschwellinger - 2018-09-13

    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

    IMG: license_and_dongle.png

    IMG: SVN_.png

     
  • Ingo

    Ingo - 2018-09-13

    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

     
  • KKempeneers

    KKempeneers - 2018-09-13

    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

     
  • Stefan2

    Stefan2 - 2018-09-13

    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

     
  • KKempeneers

    KKempeneers - 2018-09-13

    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?

    One of the upside ... Our principal will be honoured to see our school in de vendor list.

    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

    IMG: DevConfiguration.png

    IMG: Insert Device.png

     
  • Stefan2

    Stefan2 - 2018-09-13

    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.

    Zitat:
    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 i am using notepad++

    BR Stefan

     
  • aliazzz

    aliazzz - 2018-09-13

    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

     
  • Ingo

    Ingo - 2018-09-14

    Thanks Aliazzz for the feedback. I know that a few people, like you suffered a lot, because they had no access to proper documentation.

    The idea of Forge is, that we as CODESYS developers, have a channel, where we can easily provide documentation and examples to this community. I hope that especially you like this idea.

    Gesendet von meinem LG-H870 mit Tapatalk

     
  • aliazzz

    aliazzz - 2018-09-14

    No Problemo!

    I will sign up on Codesys-Forge because it offers everything i hope/need in a single place.
    If it's good, I'll even consider permanent migration from my Git to codesys forge.

    Some feedback remarks for succes of Codesys Forge (cForge);
    1) Provide good quality documentation & examples (both community and codesys driven content),
    2) Integrate/migrate this forum into cForge (emerged/integrated user experience),
    3) Consider a free variant of the other professional codesys tools i.e. for use with cForge like Application Composer / Static Analysis / etc, this help create qualitative good code content!

     
  • KKempeneers

    KKempeneers - 2018-09-14

    And I might add ... Maybe give the link the Forge to me too.

    Koen.

     
  • lbabycl-88

    lbabycl-88 - 2018-09-20

    Hi I'm trying to control stapper motors using the adafruit DC motor hat, I have the python code for the motor hat and would love to get some help on how to integrate it into codesys,

    Your help would be awesome, this code would make life simple for allot of plp.

    Sent from my SM-N9500 using Tapatalk

     
  • lbabycl-88

    lbabycl-88 - 2018-09-20

    I am also thinking of using an encoder to track the position

    Sent from my SM-N9500 using Tapatalk

     
  • aliazzz

    aliazzz - 2018-09-21

    You should write a proper FB to interface with, that it is your first goal

     
  • lbabycl-88

    lbabycl-88 - 2018-09-21

    Aliazzz hat geschrieben:
    You should write a proper FB to interface with, that it is your first goal
    Interface with encoder?....I am trying to convert the python into structure text but it isn't easy ....spending weeks just to try to understand how it works and lm still far from knowing

    Sent from my SM-N9500 using Tapatalk

     
  • Ingo

    Ingo - 2018-09-21

    But I fear w/o showing the code and explaining us what you already did, you can't expect much help from the community.

    Gesendet von meinem LG-H870 mit Tapatalk

     
  • lbabycl-88

    lbabycl-88 - 2018-09-21

    Ingo Hornberger hat geschrieben:
    But I fear w/o showing the code and explaining us what you already did, you can't expect much help from the community.
    Gesendet von meinem LG-H870 mit Tapatalk
    Ok I will do some more research then show you the results maybe in a few days time

    Sent from my SM-N9500 using Tapatalk

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.