Hi,
this sms you want to send on an alarm or IO triggered by the plc and send by the plc
not in the CODESYS developmentsystem?
Because this python scription here is all in the CODESYS developmentsystem not in the plc.
If you need this for the plc side,
this example here should show how this could work:
(But this works only if the plc side could execute python...)
l viewtopic.php?f=23&t=6247&p=19932#p19941 l
BR
Edwin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am using the PLC to run the python code. It can run the code on it's own.
I cant seem to get my code to run. I don't have the hardware to test yours but I used your example to make my code.
It seems to run the code but it does not do anything. I have tested my python code on its own and it does work.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am running it on a raspberry pi 3 model B.
I am trying to have the single file run when a bool value = true.
I can't seem to get it to work through Codesys though.
Edit:
Never mind I got it to work.
Thanks for all the help though.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Could you specify how you made it work? I am trying to run a Python Script on a Raspberry 3 B with the _ and it does not do anything. Running the script via the command line works fine.
I would appreciate any help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I tried to use your examples to run my python script. But there is no /var/opt/codesys directory. I can find my PlcLogic/Application directory only directly in root directory. Where is a problem. Is it possible to set it somewhere in development system?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would like to use this feature in Codesys (script lang) to transfer variable values between the PLC and a python script.
First, I am trying to execute a simple python script using codesys with a RPI 3 B+ as PLC. I followed the example posted for the unicorn hat as reference. However, I do not have the hardware to test it so I developed a simple code "print()" to verify the code is running.
Below the steps I have followed:
1. Add my script as external file in my CODESYS program.
Manually copy to the RPI my python script to the directory /var/opt/codesys/. I have also included [SysProcess]Command=AllowAll **
in both files /etc/CODESYSControl.cfg:/etc/CODESYSControl_User.cfg:**
Download the Codesys Program to the RPI and run the program from CODESYS.
Although I do not receive any error nor compilation or execution, I can not observe my code running. Is there any step I am missing or I should skip?
Thanks in advance
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi guys, I've followed all your instructions but I can't visualize anything on my Adafruit dipsplay (ILI9341 driver).
My python script is copied correctly from /var/opt/codesys/PlcLogic/Applicarion to /var/opt/codesys so I don't know what I'm doing wrong. Advices?
P.S. obviously if I load my program from Python idle in my RPi, it works properly.
EDIT: resolved. I tried to change "python" to "python3" in the code and it works!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi guys,
I followed all the instructions in this thread about executing external python scripts from Codesys. I was successful in running a blink LED script. However, I am unable to run a script containing just a simple print('Hello World'). Any ideas?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Did anyone get to the bottom of this problem? The Python scripts only execute certain commands within them when executed from Codesys. Direct from a the LXTerminal everything work fine.
[SysProcess] AllowAll in both file positions and python scrips in the /var/opt/codesys file
Thanks in advance
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Did anyone get to the bottom of this problem? The Python scripts only execute certain commands within them when executed from Codesys. Direct from a the LXTerminal everything work fine.
[SysProcess] AllowAll in both file positions and python scrips in the /var/opt/codesys file
Thanks in advance
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I have a python script that sends a sms message to my phone when its run.
I want this code to run when a led in codesys turns on.
I can't figure out how to do this. I know that codesys can run python by using tools, scripting, execute script.
I just want the code to run automatically to alert me of an alarm.
Thanks for the help.
Hi,
this sms you want to send on an alarm or IO triggered by the plc and send by the plc
not in the CODESYS developmentsystem?
Because this python scription here is all in the CODESYS developmentsystem not in the plc.
If you need this for the plc side,
this example here should show how this could work:
(But this works only if the plc side could execute python...)
l viewtopic.php?f=23&t=6247&p=19932#p19941 l
BR
Edwin
Thanks for the help.
I am using the PLC to run the python code. It can run the code on it's own.
I cant seem to get my code to run. I don't have the hardware to test yours but I used your example to make my code.
It seems to run the code but it does not do anything. I have tested my python code on its own and it does work.
Hi,
so on which plc do you execute this?
BR
Edwin
I am running it on a raspberry pi 3 model B.
I am trying to have the single file run when a bool value = true.
I can't seem to get it to work through Codesys though.
Edit:
Never mind I got it to work.
Thanks for all the help though.
Could you specify how you made it work? I am trying to run a Python Script on a Raspberry 3 B with the _ and it does not do anything. Running the script via the command line works fine.
I would appreciate any help.
Hi,
did you check this?
l viewtopic.php?f=23&t=6247&p=19932#p19941 l
BR
Edwin
Here is the code that made it work.
This runs my python file sms_warning on the raspberry pi.
Make sure you do this
/etc/CODESYSControl.cfg:
[SysProcess]
Command=AllowAll
This can be done on the pi by using the command: sudo nano /etc/CODESYSControl.cfg
hope this helps.
Hi,
one small remark:
I would recommend to move from /etc/CODESYSControl.cfg to /etc/CODESYSControl_User.cfg:
[SysProcess] Command=AllowAll
This has the advanatage that on an runtime update ( for example from 3.5SP12 to 3.5SP13) this setting
will be retained.
BR
Edwin
Hello,
I tried to use your examples to run my python script. But there is no /var/opt/codesys directory. I can find my PlcLogic/Application directory only directly in root directory. Where is a problem. Is it possible to set it somewhere in development system?
Hi,
you need to update the Pi runtime Version to have it in
/var/opt/codesys...
BR
Edwin
Hi all,
I would like to use this feature in Codesys (script lang) to transfer variable values between the PLC and a python script.
First, I am trying to execute a simple python script using codesys with a RPI 3 B+ as PLC. I followed the example posted for the unicorn hat as reference. However, I do not have the hardware to test it so I developed a simple code "print()" to verify the code is running.
Below the steps I have followed:
1. Add my script as external file in my CODESYS program.
Manually copy to the RPI my python script to the directory /var/opt/codesys/. I have also included
[SysProcess]Command=AllowAll **
in both files
/etc/CODESYSControl.cfg:/etc/CODESYSControl_User.cfg:**
Download the Codesys Program to the RPI and run the program from CODESYS.
Although I do not receive any error nor compilation or execution, I can not observe my code running. Is there any step I am missing or I should skip?
Thanks in advance
I have the same problem, load the program well without errors, but do nothing, could someone solve this problem?
Hi gueys ,
im still heaving problems with executing scripts.
I did all the stuffs like .
Im able only run commands like Echo xxx >>log.txt or reboot etc.
If i run python command i get reply 01 , some general error.
Can anyone help ? I looks like im in deadend . Last idea is reinstal RPI image.
and that is what i dont wanna do now
Thx lot for reply
Hi guys, I've followed all your instructions but I can't visualize anything on my Adafruit dipsplay (ILI9341 driver).
My python script is copied correctly from /var/opt/codesys/PlcLogic/Applicarion to /var/opt/codesys so I don't know what I'm doing wrong. Advices?
P.S. obviously if I load my program from Python idle in my RPi, it works properly.
EDIT: resolved. I tried to change "python" to "python3" in the code and it works!
Hi guys,
I followed all the instructions in this thread about executing external python scripts from Codesys. I was successful in running a blink LED script. However, I am unable to run a script containing just a simple print('Hello World'). Any ideas?
Last edit: alien 2021-05-19
Did anyone get to the bottom of this problem? The Python scripts only execute certain commands within them when executed from Codesys. Direct from a the LXTerminal everything work fine.
[SysProcess] AllowAll in both file positions and python scrips in the /var/opt/codesys file
Thanks in advance
Did anyone get to the bottom of this problem? The Python scripts only execute certain commands within them when executed from Codesys. Direct from a the LXTerminal everything work fine.
[SysProcess] AllowAll in both file positions and python scrips in the /var/opt/codesys file
Thanks in advance