Execut Python Script in CoDeSys POU

Mark0ne
2019-03-26
2019-07-03
  • Mark0ne - 2019-03-26

    Good day All,

    I am currently busy with a project where I need to run a python script from a condition/trigger in my SoMachine (CoDeSys) project.

    I was wondering if anyone could maybe inform me on a way to execute the file in Structured Text. Also I added the python file in my program (see attached). Keep in mind that it needs to execute while running on the PLC and the script might be executed multiple times in the program.

    I would appreciate any help or advice.

    Kind regards
    Markus Oosthuizen

    IMG: SOM1.PNG

    IMG: SOM2.PNG

     
  • Ioannis - 2019-03-26

    I am also trying to run a python script inside a schneider m251 plc but haven't figured how yet. The script runs perfectly on my pc.
    Can anyone give a tip?
    The python script is the following:
    from twilio.rest import Client
    account_sid = 'xxxxxxxxx'
    auth_token = 'xxxxxxx'
    client = Client(account_sid, auth_token)

    message = client.messages \
    .create(
    body='Alarm',
    from_='xxx',
    to='xxxx'
    )

     
  • agrobot - 2019-04-17

    Did he do it?

    I want to do the same, and I can not find the solution

     
  • mkeller - 2019-04-18

    Hi agrobot.

    agrobot hat geschrieben:
    Did he do it?
    I want to do the same, and I can not find the solution

    Take a look at the example for the Raspberry Pi and SenseHAT:

    https://forum.codesys.com/viewtopic.php?f=23&t=6247&p=19932#p19941

    This works because the Raspberry Pi has the python interpreter installed. If the PLC has not python interpreter it does not work.

    BR
    Martin

     
  • agrobot - 2019-04-22

    I have doubts about how to call my python pwm script in the program, I did not have to do it, think you could help me

     
  • chris.beard - 2019-07-03

    you could try building the script as a .exe using pyinstaller and calling this as a process using the PLC?

     

Log in to post a comment.