Post by alexgooi on Function Blocks and arrays of function blocks
CODESYS Forge
talk
(Post)
Hi Jack, I think you have to look at a FB in a different way. A Function block (Class) can contain its own data. In other words don't define loose data in your GVL, but define a instance of a FB (Object) in your GVL: Example: Function_Block Basic_Class VAR_INPUT Open_Command: BOOL; END_VAR VAR_OUTPUT Opened: BOOL; END_VAR if Open_Command then Opened := TRUE; ELSE Opened := FALSE; END_IF Global Variables Objects: ARRAY[1..100] OF Basic_Class; //Here you ar defining you objects END_VAR In your code you can directly acces the data and couple it to the IO: GVL.Objects[1].Open_Command := %IX0.0; %QX0.0 := GVL.Objects[1].Opened; //To call the code itself use: GVL.Objects[1](); If you want to take this a step further you are also able to add methods and properties to the FB/Class end thereby creating a OOIP program
Last updated: 2024-02-15
Post by ewi04 on How to upload application file to remote controller (offline) ?
CODESYS Forge
talk
(Post)
Thank you very much for your time and replay! Sounds like a good idea. Unfortunately, I have no other option to run the code from the running plc. So, I canβt stop any services. If anyone has the same problem, I've gotten a little closer to understanding it: Sometimes the copied files are empty after the restart. The update code checks if there are any empty files. Before I turn off the device, everything is okay. But after starting, some files are suddenly empty and that cause the problems. I don't know why this happens.
Last updated: 2024-02-16
Post by i-campbell on build (F11) / generate code using a python script file
CODESYS Forge
talk
(Post)
hello, please enjoy. # i-campbell 2024 import subprocess from scriptengine import * # with a project already open # save if not yet saved # check pool objects if it is a library # generate code only for the active application if it is a project # beep thanks to https://devblogs.microsoft.com/scripting/powertip-use-powershell-to-send-beep-to-console/ if projects.primary: # check project is open if projects.primary.dirty: # save projects.primary.save() if projects.primary.path.lower().endswith('.library'): projects.primary.check_all_pool_objects() # check all pool objects for lib else: projects.primary.active_application.generate_code() # generate if not lib # note, there could be more applications than the active application, # this script does not generate those else: system.write_message(Severity.Error,'no project open') ps_output = subprocess.check_output(["powershell", "-Command", "[console]::beep(500,300)"]) # beep
Last updated: 2024-04-10
Post by dkugler on build (F11) / generate code using a python script file
CODESYS Forge
talk
(Post)
thank you very much! I found the generate_code methode, but struggled with the primary and active_application. With this expample I will be able to play around. If the code generation takes a minute or more I often switch to other programs and don't notify the process is finished. So now I'll get an alert and will switch back immediately. My next little project will be, to beep different if there are errors and a seperate script to do the download incl. the user management data base without stopping at the dialogs asking for onlinechange/complete download and overwriting an existing database and as goody, play a beep/sound again.
Last updated: 2024-04-11
Post by rafael on Wbm/runtime and visualization login
CODESYS Forge
talk
(Post)
Hello everyone, Iβm trying to understand if it is this way or I can change it. Iβm making a PLC code and visualization screens, the ideia is to operate via webvisu some controls. So i made a code, made some screens and when i try it in my web browser, first it asks me to insert te user and password of the wbm/runtime of the plc (user: admin, password: wago by default), then i can acess my screens but I have to login again with the user and password that i created in the visualization user managment. My question is: is there a way to disable this first login to the visualization screens (webvisu)? Or create another user/password for this first screen? I have a PFC200 and a Edge Controller, both are working the same way. Thanks in advance Thanks
Last updated: 2024-06-25
Post by naks on Change IP address from IEC code
CODESYS Forge
talk
(Post)
Hi, I'm working with wago 750-8212 controller. I want to change the IP address of the Ethernet adapter from webvisu. I have read some other threads in this forum and I have tried the following: Added the following text to the config file CODESYSControl.cfg: [SysSocket] Adapter.0.Name="br1" Adapter.0.EnableSetIpAndMask=1 Used the below code : IF xUpdateEthernet THEN Ethernet.Enable := FALSE; Reconfig ( xExecute := TRUE, itfNode := Ethernet, eError => ErrorReconfig, xBusy => xBusy, xDone => xDone, xError => xErrorReconfigure); IF Reconfig.xDone THEN ErrorCode := Ethernet.UpdateConfiguredIPSettings(IpAddress := NewIp, gateway := newGateway, subnetmask := newSubnetmask); END_IF IF Reconfig.xDone OR Reconfig.xError THEN reconfig(xExecute := FALSE); END_IF Ethernet.Enable := TRUE; Reconfig(xExecute := TRUE, itfNode := Ethernet ); END_IF I could change the IP address but when i restart my Controller then the IP address resets to the original, Is there anything I have missed, what else can i try ? Thank you in advance.
Last updated: 2024-07-08
Post by alimans on OPC-UA Server, Symbol Set: Raise an error: Object reference not set to an instance of an object.
CODESYS Forge
talk
(Post)
Hi everyone, I just created a very simple library without any code and, added it to my very simple project. after adding this library, I get an error when I try to open "Symbol Set" in "OPC UA Server" in "Communication Manager". Here is the code of my POU in the library: FUNCTION_BLOCK POU VAR eCommand : (CMD_NONE:=0, CMD_RESET:=-1) INT := CMD_NONE; END_VAR Attached is the error that I get. I also noticed that by removing the enumeration variable above (eCommand), I can open the "Symbol Set" again. Anybody has any idea why this error is raised and how could I use enumeration variables without error in "OPC UA Symbol Set"?
Last updated: 2024-08-08
Post by micik on Python scripting - print whole project tree
CODESYS Forge
talk
(Post)
Hello, I have found a script for printing device tree in Codesys project. This script is available as code snippet as an exmaple for using Python in Codesys. However I feel main documentation is lacking. For example, where can I find that object has "is_device" attribute? Code examples are given here: https://content.helpme-codesys.com/en/CODESYS%20Scripting/_cds_access_cds_func_in_python_scripts.html However, I have a question how to print the whole Project tree and not just devices? Of course I need to remove check: if treeobj.is_device: But simply removing this test condition will not produce what I want. I need to print PLC Logic, Application, ad other nodes in the Project tree. Where to find this documentation?
Last updated: 2024-08-12
Post by pierre on difference between stub file and source file in scriptengine
CODESYS Forge
talk
(Post)
I included the stub files of scriptengine (codesys python api) in a directory scriptengine of a project. I tried to include librarymanager like that: from scriptengine import librarymanager visual studio code detected an error. It said librarmanager could not be found. Indeed in the stub file, this was library_manager. But if I change it in my code, the plugin doesn t work anymore. I found an easy solution to this problem. I ve just changed the copied stub files.(library_manager -> librarymanager) But I think it would be better if you update it yourself in the future.
Last updated: 2024-09-20
Post by pierre on difference between stub file and source file in scriptengine
CODESYS Forge
talk
(Post)
I included the stub files of scriptengine (codesys python api) in a directory scriptengine of a project. I tried to include librarymanager like that: from scriptengine import librarymanager visual studio code detected an error. It said librarmanager could not be found. Indeed in the stub file, this was library_manager. But if I change it in my code, the plugin doesn t work anymore. I found an easy solution to this problem. I ve just changed the copied stub files.(library_manager -> librarymanager) But I think it would be better if you update it yourself in the future.
Last updated: 2024-09-20
Post by opineiro on How to manage variable types larger than 64 bits - Ethernet/IP
CODESYS Forge
talk
(Post)
Hi there, I have a Keyence bar code reader connected to my plc through Ethernet/IP. The Bar code is 20 digits long (like 30100790020493036016), the scanner reads it correctly (I can verify that through the keyence software) but when it sends it through ETH/IP, it doesn't fit into a 64 bit variable and it trunks the data.(I've tried ULINT and LWord without success). When I loaded the EDS file, the read variable was defined as a byte with 128 bits length, which is quite strange for me. (see attached picture) How do I manage this variable? Thanks!
Last updated: 2024-09-23
Post by vformanek on No source code available for profinet library
CODESYS Forge
talk
(Post)
I have tried downgrading and it seems fine now. I am now on version 4.3.0.0 for the library. Mainly the PN controller caused the issue for me. Funny weird is that even the PN controller versions 4.3.1.0 and 4.3.0.0 cause the error. Version 4.2.0.0 works fine.
Last updated: 2023-08-23
Post by fefefede on Error C0521 - unknow compiler
CODESYS Forge
talk
(Post)
Hello, i'm a new user of Codesys and student of ST program for PLC. Since today for a few new projects i have two error code C0521 and i can't solve. I also just try to update device and search library but nothign resolve. How can i fix this? Thanks
Last updated: 2023-09-02
Post by sean-barton on FILE_OPERATION_DENIED
CODESYS Forge
talk
(Post)
I have code written since version 3.5.16 to access the USB drive, how can I do that now the file access has been taken away? I have tried adding a sybolic link to the usb drive in the following directories: /var/opt/codesys/PlcLogic/ /var/opt/CODESYS/PlcLogic/ /opt/CODESYS/PlcLogic/ I still recieve a "FILE_OPERATION_DENIED" response when accessing the USB drive.
Last updated: 2023-10-13
Post by fazlinda on AWS IoT core CODESYS
CODESYS Forge
talk
(Post)
Hi, Im having a problem sending a data from my structure text code from codesys to aws. Instead of receiving {state {reported {data: 123}}} It display {state {reported {data: 123}}}\x00 \x00 \x00 \x00 \x00 \x00 \x00 Please help me solve this issues. how to remove \x00 ?
Last updated: 2023-12-06
Post by fazlinda on AWS IoT core CODESYS
CODESYS Forge
talk
(Post)
Hi, Im having a problem sending a data from my structure text code from codesys to aws. Instead of receiving {state {reported {data: 123}}} It display {state {reported {data: 123}}}\x00 \x00 \x00 \x00 \x00 \x00 \x00 Please help me solve this issues. how to remove \x00 ?
Last updated: 2023-12-06
Post by fazlinda on AWS IoT core CODESYS
CODESYS Forge
talk
(Post)
Hi, Im having a problem sending a data from my structure text code from codesys to aws. Instead of receiving {state {reported {data: 123}}} It display {state {reported {data: 123}}}\x00 \x00 \x00 \x00 \x00 \x00 \x00 Please help me solve this issues. how to remove \x00 ?
Last updated: 2023-12-06
Post by fazlinda on AWS IoT core CODESYS
CODESYS Forge
talk
(Post)
Hi, Im having a problem sending a data from my structure text code from codesys to aws. Instead of receiving {state {reported {data: 123}}} It display {state {reported {data: 123}}}\x00 \x00 \x00 \x00 \x00 \x00 \x00 Please help me solve this issues. how to remove \x00 ?
Last updated: 2023-12-06
Post by fazlinda on AWS IoT core CODESYS
CODESYS Forge
talk
(Post)
Hi, Im having a problem sending a data from my structure text code from codesys to aws. Instead of receiving {state {reported {data: 123}}} It display {state {reported {data: 123}}}\x00 \x00 \x00 \x00 \x00 \x00 \x00 Please help me solve this issues. how to remove \x00 ?
Last updated: 2023-12-06
Post by fazlinda on AWS IoT core CODESYS
CODESYS Forge
talk
(Post)
Hi, Im having a problem sending a data from my structure text code from codesys to aws. Instead of receiving {state {reported {data: 123}}} It display {state {reported {data: 123}}}\x00 \x00 \x00 \x00 \x00 \x00 \x00 Please help me solve this issues. how to remove \x00 ?
Last updated: 2023-12-06
Post by talhaali on Adding a variable from text list into ST code
CODESYS Forge
talk
(Post)
Hi, can I use a entry of a text list as variable in structured text? for example in attach picture, if i use want to use data of first row. I am trying to write: A : STRING := TextList.Default.0; but it is not workings
Last updated: 2023-12-07
Post by talhaali on Adding a variable from text list into ST code
CODESYS Forge
talk
(Post)
Hi, can I use a entry of a text list as variable in structured text? for example in attach picture, if i want to use data of first row. I am trying to write: A : STRING := TextList.Default.0; but it is not workings
Last updated: 2023-12-07
Post by aniket-b on How to protect library project?
CODESYS Forge
talk
(Post)
I have library projects which has few function blocks. I have assigned security to each FB. I want to protect them and user can only be able to use it without viewing the code inside. What kind of file I should send to user? Is it compiled library file?
Last updated: 2024-01-22
Post by dav3 on Exception auf Raspberry, CMCommCycleTask Tainted
CODESYS Forge
talk
(Post)
Hello, I don't really know what my problem was, but it's working for me at the moment. All i did was to change my code because of some REAL_TO_INT conversions, like i wrote above. And later a complete new Pi setup (because of 64x support with 4.10.0.0 now).
Last updated: 2024-02-16
Post by xabier on See only variable
CODESYS Forge
talk
(Post)
I have declarated this variable...When i use the variable I see all...I wan see only the variable not all. For example I declarated in GVL_GLOBAL ==> Torque_Mode When I push enter insert in code all rute..GVL_GLOBAL.Torque_MOde...I want see only torque mode...How is possible resolved this problem?? Thanks XABI
Last updated: 2024-03-14
To search for an exact phrase, put it in quotes. Example: "getting started docs"
To exclude a word or phrase, put a dash in front of it. Example: docs -help
To search on specific fields, use these field names instead of a general text search. You can group with AND
or OR
.