Use Python instead of ST?

Russell
2011-07-27
2012-01-10
  • Russell

    Russell - 2011-07-27

    Hi all,

    I am a little confused about what the actual place of python is. Is it anohter language that we can write control programs in? And will we be able to use it to make GUI for machine control?

    Thanks,

     
  • RolandWagner

    RolandWagner - 2011-07-27

    As you can read under http://forum-en.3s-software.com/viewtopic.php?f=18&t=1889not be used as another language for the programming of the control applications.

    Typical applications for the use of Python in connection with CoDeSys are

     
  • Russell

    Russell - 2011-07-27

    Thanks Roland,
    I work with several devices that use the CoDeSys enviroment. For example Bosch Rexroth PLC, ABB PLC, SEW PLC, Festo PLC. I develop programs for machines using these platforms. Is python going to help me? Or is it more aimed at the developers who are developing for platforms loke those above?
    And if it can help me what are some practical examples of what it can do?

    Regards,

     
  • Anonymous - 2011-07-27

    Originally created by: M.Schaber

    Hi, Russel,

    Python scripting won't help you with the writing of code itsself. But it can help to automate several steps during deployment. Some examples of what can be done can be found in this forum: http://forum-en.3s-software.com/viewtopic.php?f=18&t=1890

    Another example was a script which connected to a device, read some variables, and then sent those values via email.

    You can also call CoDeSys from a windows batch file and command it to execute a script (with the parameters --runscript and --noUI), so you can automate some tasks (e. G. via the windows task scheduler or on a continous integration server).

    One use case is for an OEM which uses the scripts to create tailored codesys projects out of machine configurations.

     
  • RolandWagner

    RolandWagner - 2011-07-27

    Hi,

    at first you have to be aware that Python is only available in CoDeSys V3. Probably most of the devices you have mentioned still work with CoDeSys V2.3. CoDeSys V3 is not downward compatible, thus you will not be able to benefit from Python inside CoDeSys.

    In order to get an idea how Python can help you could check the examples under http://forum-en.3s-software.com/viewtopic.php?f=18&t=1906 and http://forum-en.3s-software.com/viewtopic.php?f=18&t=1890.

    In general as already mentioned Python is useful for automatically executing commands of the development environment, such as

    open project
    import POU xxx
    set communication to device xxx
    login
    download the application
    write certain values to certain variables
    logout
    save project

    (of course this is a rough abstraction of the code )

    Imagine you have to do that exactly in the same way for several time, e.g. at a series of machines with the same application and PLC (which are not connected in one single network) - with a Python script you could execute the whole batch of commands with one click (and without becoming crazy after the 10th repetition... ).

    I hope this will help you to have an idea how Python can accelerate your work.

     
  • Russell

    Russell - 2011-07-27

    Thanks Gents,

    I will see when somthing arises I have some further questions re V3 and V2 comaptibility. I will post these on the V3 Forum

     
  • daflodedeing

    daflodedeing - 2012-01-09

    Zitat:
    Typical applications for the use of Python in connection with CoDeSys are

    Hello,

    you listed above that it´s possible to use Python for automation of test? How did you mean that? I ´m interested in how Python could be used as a test tool. Did you mean that through a Python Script I´m able to write variables in the debug - mode and doing so I´m able to test for example a certain Function_Block?

    Greetings.

     
  • Anonymous - 2012-01-10

    Originally created by: M.Schaber

    Hi, daflodedeing,

    daflodedeing hat geschrieben:
    you listed above that it´s possible to use Python for automation of test? How did you mean that? I ´m interested in how Python could be used as a test tool. Did you mean that through a Python Script I´m able to write variables in the debug - mode and doing so I´m able to test for example a certain Function_Block?

    Yes, you can read, write and force variables using python scripts. Under the hoods, this uses the same CoDeSys monitoring mechanism which is also used in the online POU editors and the Watch window. So, for example, you can write python scripts which download and start an application, and then sets some input variables, waits, and verifies the output variables.

    We're also currently working on a CoDeSys-Add-On called "Testmanager" which specifically supports test automation, but there's no official release date yet.

    HTH,
    Markus

     

Log in to post a comment.