Search talk: Creating Python Scripts

 
<< < 1 .. 11 12 13 14 > >> (Page 13 of 14)

Post by siscu on Raspberry i2c master device CODESYS Forge talk (Post)
I want to implement an extended I2C master for Raspberry Pi Control. I was hoping for it to be as easy as creating a library with a FB that extends i2cMaster and associating it with a device following the forge drivers documentation, but I haven't managed to make it work as the driver behaves only as an i2c slave. I'm thinking this is because the forge forum only talks about extending i2c, and the master portion is omitted since most users won't want to add a custom one. I'd like to know if I'm doing something wrong. Is it really possible to make an I2C master extension device? If so, are there public examples we can check out? Any info on this topic will be appreciated.
Last updated: 2024-10-16

Post by mondinmr on Why SysPipeWindows is not implemented in RTE? CODESYS Forge talk (Post)
This library would be very useful for IPC communications. Using a UDP socket on localhost is unpredictable, as with slightly loaded machines it does not even guarantee packet delivery locally. Using TCP creates a lot of overhead. Message named pipes would be an excellent solution for Windows RTE. On Linux, since the release of the extension package, there is no issue, as it is sufficient to develop a component. However, although now 90% of our clients understand that Linux runtimes are better in every way compared to Windows RTE, especially from the security aspect (Not in kernel space) and the issues with Windows updates, 10% stubbornly insist (sometimes for trivial commercial reasons) on using Windows. Managing IPC with circular buffers in shared memory is quite ugly, or rather really ugly and unaesthetic. In the manuals, I saw the SysPipeWindows libraries, so I decided to test them, but unfortunately, I noticed that they are not implemented for RTE devices. Technically, I could try to open them as regular files, but SysFileOpen returns 16#27 or 16#39 depending on how I set the name (direction of the slashes). Here is the code to create shared memory and named pipes. Shared memory work great, named pipes no! #ifdef Q_OS_WIN32 SECURITY_ATTRIBUTES sa; SECURITY_DESCRIPTOR sd; InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE); sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.lpSecurityDescriptor = &sd; sa.bInheritHandle = FALSE; const wchar_t* name = L"Global\\ShmTest"; HANDLE hMapFile = CreateFileMapping( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(SharedData), name); if (hMapFile == NULL) { qCritical("Error creating shared memory"); return 1; } data = static_cast<SharedData*>(MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(SharedData))); if (data == NULL) { qCritical("Error mapping shared memory"); return 1; } HANDLE hPipe = CreateNamedPipe( TEXT("\\\\.\\pipe\\MyPipe"), PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, 1024 * 1024, 1024 * 1024, NMPWAIT_USE_DEFAULT_WAIT, &sa); if (hPipe == INVALID_HANDLE_VALUE) { qCritical("Error creating named pipe"); return -1; } if (!ConnectNamedPipe(hPipe, NULL)) { qCritical("Error connecting to named pipe"); return -1; } checkPipe(hPipe); #endif
Last updated: 2024-02-02

Post by seppi on Establishing communication between a Raspberry Pi 4 and an Arduino UNO R3 using I²C. CODESYS Forge talk (Post)
Hello everyone, I want to establish communication between my Arduino and my Raspberry Pi via I²C, but I have no idea how to make it work. However, it should work because there are many examples available, although none of them were programmed using Codesys, but rather using Python. My Raspberry Pi will be the master and is supposed to exchange measurement data such as speed and battery capacity with the slave (Arduino). I would be very grateful if someone could help me with my problem. Here is another link that could be helpful. However, I can't find the mentioned libraries
Last updated: 2023-12-03

Post by seppi on Raspberry 4 I²C with Arduino UNO R3 CODESYS Forge talk (Post)
Hallo zusammen Ich möchte meinen Arduino und meinen PI miteinander kommunizieren lassen via I²C doch ich habe keine Ahnung wie das funktionieren soll. Aber es müsste funktionieren da es viele Beispiele dazu gibt jedoch wurde keines der Beispiele mit Codesys programmiert sondern über Python. Mein PI wird der Master sein und soll mit dem Slave (Arduino) Messdaten wie Geschwindigkeit und Akkukapazität und so weiter austauschen. Wenn mir bei meinen Problem jemand weiterhelfen könnte währe ich sehr Dankbar. Hier noch ein Link der Hilfreich sein könnte. Ich finde aber die angegeben Bibliotheken nicht. https://forge.codesys.com/forum/en/773/genmed-documentation.pdf
Last updated: 2023-12-03

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 francesco86 on Script python for write in a file Project information CODESYS Forge talk (Post)
Dear all, My python script can read a Codesys project and save in file the different POU, but the problem is that I don't able to read the project info from the obj list. Following of this message there is my python script. Can you help my? Best regards Francesco # encoding:utf-8 # We enable the new python 3 print syntax from __future__ import print_function import os import shutil import time import sys from datetime import datetime print("--- Saving files in the project: ---") print("sys.argv: ", len(sys.argv), " elements:") for arg in sys.argv: print(" - ", arg) if (len(sys.argv)>1): folderExportName = sys.argv[1] print(" folderExportName: ", folderExportName) exportPath = sys.argv[2]+ sys.argv[3]+ "\\"+ sys.argv[1] print(" File path: ", exportPath) # git has_repo=False #save_folder=r'E:\Tmp\ControlPlugins\ControlPlugins\Export' save_folder = exportPath if not os.path.exists(save_folder): os.makedirs(save_folder) else: a=os.listdir(save_folder) for f in a: if not f.startswith("."): sub_path= os.path.join(save_folder,f) if os.path.isdir(sub_path): shutil.rmtree(sub_path) else: os.remove(sub_path) elif f==".git": has_repo=True info={} type_dist={ '792f2eb6-721e-4e64-ba20-bc98351056db':'pm', #property method '2db5746d-d284-4425-9f7f-2663a34b0ebc':'dut', #dut 'adb5cb65-8e1d-4a00-b70a-375ea27582f3':'lib', #lib manager 'f89f7675-27f1-46b3-8abb-b7da8e774ffd':'m', #method no ret '8ac092e5-3128-4e26-9e7e-11016c6684f2':'act', #action '6f9dac99-8de1-4efc-8465-68ac443b7d08':'pou', #pou '6654496c-404d-479a-aad2-8551054e5f1e':'itf', #interface '738bea1e-99bb-4f04-90bb-a7a567e74e3a':'', #folder 'ffbfa93a-b94d-45fc-a329-229860183b1d':'gvl', #global var '5a3b8626-d3e9-4f37-98b5-66420063d91e':'prop', #property '2bef0454-1bd3-412a-ac2c-af0f31dbc40f':'tl', #textlist '63784cbb-9ba0-45e6-9d69-babf3f040511':'gtl', #global textlist '225bfe47-7336-4dbc-9419-4105a7c831fa':'dev', #device 'ae1de277-a207-4a28-9efb-456c06bd52f3':'tc', #task configuration 'f8a58466-d7f6-439f-bbb8-d4600e41d099':'m', #method with ret '261bd6e6-249c-4232-bb6f-84c2fbeef430':'gvl', #gvl_Persistent '98a2708a-9b18-4f31-82ed-a1465b24fa2d':'task', #task '085afe48-c5d8-4ea5-ab0d-b35701fa6009':'progInfo'#project information }; def save(text,path,name,tp): if not tp: tp='' else: tp='.'+tp+'.txt' with open(os.path.join(path,name+tp),'w') as f: f.write(text.encode('utf-8')) def print_tree(treeobj, depth, path): global info #record current Path curpath=path isfolder=False t='' #text tp='' #type # get object name name = treeobj.get_name(False) id = treeobj.type.ToString() if id in type_dist: tp = type_dist[treeobj.type.ToString()] #Print all type of objects #print("--Name: ", tp) else: info[id]=name if treeobj.is_device: deviceid = treeobj.get_device_identification() t = 'type='+str(deviceid.type) +'\nid=' +str(deviceid.id) + '\nver='+ str(deviceid.version) if tp == "progInfo": print("-- There is prog info, ", tp) print("-- It has textual declaration: , ", treeobj.has_textual_declaration) print("-- It has textual implementation: , ", treeobj.has_textual_implementation) print("-- It is folder: , ", treeobj.is_folder) print("-- It is children: , ", treeobj.get_children(False)) print("-- It is children len: , ", len(treeobj.get_children(False))) print("-- It is progInfo type: , ", type(treeobj.ScriptProject)) #for child in treeobj.get_children(False): # print_tree(child, depth+1,curpath) try: if treeobj.is_folder : #system.ui.prompt('folder:'+u, PromptChoice.YesNo, PromptResult.Yes) isfolder=true pass except: pass if treeobj.has_textual_declaration : t=t+'(*#-#-#-#-#-#-#-#-#-#---Declaration---#-#-#-#-#-#-#-#-#-#-#-#-#*)\r\n' a=treeobj.textual_declaration t=t+a.text if treeobj.has_textual_implementation: t=t+'(*#-#-#-#-#-#-#-#-#-#---Implementation---#-#-#-#-#-#-#-#-#-#-#-#-#*)\r\n' a=treeobj.textual_implementation t=t+a.text if treeobj.has_textual_declaration and not treeobj.has_textual_implementation: t=t+'(*#-#-#-#-#-#-#-#-#-#---NOT Implementation visible---#-#-#-#-#-#-#-#-#-#-#-#-#*)\r\n' if treeobj.is_task : exports=[treeobj] projects.primary.export_native(exports,os.path.join(curpath,name+'.task')) if treeobj.is_libman: exports=[treeobj] projects.primary.export_native(exports,os.path.join(curpath,name+'.lib')) if treeobj.is_textlist: treeobj.export(os.path.join(curpath,name+'.tl')) children = treeobj.get_children(False) if children or isfolder: if tp: curpath=os.path.join(curpath,name+'.'+tp) else: curpath=os.path.join(curpath,name) if not os.path.exists(curpath): os.makedirs(curpath) if t: save(t,curpath,name,tp) for child in treeobj.get_children(False): print_tree(child, depth+1,curpath) for obj in projects.primary.get_children(): print_tree(obj,0,save_folder) with open(os.path.join(save_folder,'ExportInfo.txt'),'w') as f: now = datetime.now() infTimeExecution = now.strftime("%Y-%m-%d %H:%M:%S") f.write("Export date and time: "+infTimeExecution + "\r\n" + str(info)) print("--- Script finished. ---") #system.ui.info('save ok') projects.primary.close()
Last updated: 2024-04-30

Post by francesco86 on Script python for write in a file Project information CODESYS Forge talk (Post)
Dear all, My python script can read a Codesys project and save in file the different POU, but the problem is that I don't able to read the project info from the obj list. Following of this message there is my python script. Can you help my? Best regards Francesco # encoding:utf-8 # We enable the new python 3 print syntax from __future__ import print_function import os import shutil import time import sys from datetime import datetime print("--- Saving files in the project: ---") print("sys.argv: ", len(sys.argv), " elements:") for arg in sys.argv: print(" - ", arg) if (len(sys.argv)>1): folderExportName = sys.argv[1] print(" folderExportName: ", folderExportName) exportPath = sys.argv[2]+ sys.argv[3]+ "\\"+ sys.argv[1] print(" File path: ", exportPath) # git has_repo=False #save_folder=r'E:\Tmp\ControlPlugins\ControlPlugins\Export' save_folder = exportPath if not os.path.exists(save_folder): os.makedirs(save_folder) else: a=os.listdir(save_folder) for f in a: if not f.startswith("."): sub_path= os.path.join(save_folder,f) if os.path.isdir(sub_path): shutil.rmtree(sub_path) else: os.remove(sub_path) elif f==".git": has_repo=True info={} type_dist={ '792f2eb6-721e-4e64-ba20-bc98351056db':'pm', #property method '2db5746d-d284-4425-9f7f-2663a34b0ebc':'dut', #dut 'adb5cb65-8e1d-4a00-b70a-375ea27582f3':'lib', #lib manager 'f89f7675-27f1-46b3-8abb-b7da8e774ffd':'m', #method no ret '8ac092e5-3128-4e26-9e7e-11016c6684f2':'act', #action '6f9dac99-8de1-4efc-8465-68ac443b7d08':'pou', #pou '6654496c-404d-479a-aad2-8551054e5f1e':'itf', #interface '738bea1e-99bb-4f04-90bb-a7a567e74e3a':'', #folder 'ffbfa93a-b94d-45fc-a329-229860183b1d':'gvl', #global var '5a3b8626-d3e9-4f37-98b5-66420063d91e':'prop', #property '2bef0454-1bd3-412a-ac2c-af0f31dbc40f':'tl', #textlist '63784cbb-9ba0-45e6-9d69-babf3f040511':'gtl', #global textlist '225bfe47-7336-4dbc-9419-4105a7c831fa':'dev', #device 'ae1de277-a207-4a28-9efb-456c06bd52f3':'tc', #task configuration 'f8a58466-d7f6-439f-bbb8-d4600e41d099':'m', #method with ret '261bd6e6-249c-4232-bb6f-84c2fbeef430':'gvl', #gvl_Persistent '98a2708a-9b18-4f31-82ed-a1465b24fa2d':'task', #task '085afe48-c5d8-4ea5-ab0d-b35701fa6009':'progInfo'#project information }; def save(text,path,name,tp): if not tp: tp='' else: tp='.'+tp+'.txt' with open(os.path.join(path,name+tp),'w') as f: f.write(text.encode('utf-8')) def print_tree(treeobj, depth, path): global info #record current Path curpath=path isfolder=False t='' #text tp='' #type # get object name name = treeobj.get_name(False) id = treeobj.type.ToString() if id in type_dist: tp = type_dist[treeobj.type.ToString()] #Print all type of objects #print("--Name: ", tp) else: info[id]=name if treeobj.is_device: deviceid = treeobj.get_device_identification() t = 'type='+str(deviceid.type) +'\nid=' +str(deviceid.id) + '\nver='+ str(deviceid.version) if tp == "progInfo": print("-- There is prog info, ", tp) print("-- It has textual declaration: , ", treeobj.has_textual_declaration) print("-- It has textual implementation: , ", treeobj.has_textual_implementation) print("-- It is folder: , ", treeobj.is_folder) print("-- It is children: , ", treeobj.get_children(False)) print("-- It is children len: , ", len(treeobj.get_children(False))) print("-- It is progInfo type: , ", type(treeobj.ScriptProject)) #for child in treeobj.get_children(False): # print_tree(child, depth+1,curpath) try: if treeobj.is_folder : #system.ui.prompt('folder:'+u, PromptChoice.YesNo, PromptResult.Yes) isfolder=true pass except: pass if treeobj.has_textual_declaration : t=t+'(*#-#-#-#-#-#-#-#-#-#---Declaration---#-#-#-#-#-#-#-#-#-#-#-#-#*)\r\n' a=treeobj.textual_declaration t=t+a.text if treeobj.has_textual_implementation: t=t+'(*#-#-#-#-#-#-#-#-#-#---Implementation---#-#-#-#-#-#-#-#-#-#-#-#-#*)\r\n' a=treeobj.textual_implementation t=t+a.text if treeobj.has_textual_declaration and not treeobj.has_textual_implementation: t=t+'(*#-#-#-#-#-#-#-#-#-#---NOT Implementation visible---#-#-#-#-#-#-#-#-#-#-#-#-#*)\r\n' if treeobj.is_task : exports=[treeobj] projects.primary.export_native(exports,os.path.join(curpath,name+'.task')) if treeobj.is_libman: exports=[treeobj] projects.primary.export_native(exports,os.path.join(curpath,name+'.lib')) if treeobj.is_textlist: treeobj.export(os.path.join(curpath,name+'.tl')) children = treeobj.get_children(False) if children or isfolder: if tp: curpath=os.path.join(curpath,name+'.'+tp) else: curpath=os.path.join(curpath,name) if not os.path.exists(curpath): os.makedirs(curpath) if t: save(t,curpath,name,tp) for child in treeobj.get_children(False): print_tree(child, depth+1,curpath) for obj in projects.primary.get_children(): print_tree(obj,0,save_folder) with open(os.path.join(save_folder,'ExportInfo.txt'),'w') as f: now = datetime.now() infTimeExecution = now.strftime("%Y-%m-%d %H:%M:%S") f.write("Export date and time: "+infTimeExecution + "\r\n" + str(info)) print("--- Script finished. ---") #system.ui.info('save ok') projects.primary.close()
Last updated: 2024-04-30

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 micik on Start Codesys project and then execute python script from command line CODESYS Forge talk (Post)
Hello, by searching the forum, I have found an example of batch script that can be used to start codesys projct by temporarily setting env variables. However, I'm not sure how to modify this to start Codesys 3.5.20 and whether or not I need to specify "profile" with Codesys version at all. @echo off SET PROJECT=D:\TestScripts\Data\OnlineTest.project SET VARIABLES=POU.testint,POU.testoutput start /wait CoDeSys.exe --profile="CoDeSys V3.4 SP3" --noUI --runscript="D:\TestScripts\Forum_Environment.py" I have tried the following just to open the test project: SET PROJECT=C:\TEST\Example.project start CODESYS.exe --profile="CODESYS V3.5 SP20 Patch 2" But I'm not sure how to specify this project to be open after py script is executed. The py script should first add required library to the project and then project should be open.
Last updated: 2024-09-30

Post by cdutz on Problems connecting to Codesys 4.9.0.0 runtime on my Wago PFC200 CODESYS Forge talk (Post)
Turns out I managed to get a connection to my PLC. It seems that a few weeks ago Wago released something with version 4.3.3(25). So I reset my PLC to Factory-Reset, set it to the 192.168.1.17 IP and changed the IP to the one I wanted with the Wago EthernetSettings tool. Then updated the latest firmware using the WAGOupload tool. Now the PLC came back up without a PLC runtime running, so in the Web-tool I wen't to the "Configuration"/"PLC Runtime" and selected the runtime version "CODESYS V3". I uninstalled all Codesys versions and installed the version from the download package of Wago together with all the packages the bundle provided. After creating a new project I didn't select the old PFC200 runtime, but one of the dozens of new device profiles, that it now listed. With these settings I was then able to connect to my PLC. Now I hope I'll get the existing project that I had ported to this new structure. Sorry for the noise. Chris
Last updated: 2023-08-26

Post by sturmghost on Visualization using methods and cyclic ST-calls CODESYS Forge talk (Post)
Im looking for a way to implement ST-code into the visualization element without creating a helper POU or method in my device/application tree. Like visualization properties are evaluated at each VISU_TASK cycle I want to be able to create own ST code which interacts with the visualization interface variables. To be more specific I want to have a property which executes user defined ST-code at each VISU_TASK cycle exactly like its already possible for Input Configuration on various mouse and dialog events. Also a property for initialization (so only executed once) and a timed property would be nice. With the situation right now I'll have to create a POU function which handles the ST-code and misuse a property, like the text variable, to execute this POU function at each VISU_TASK cycle. Or does it exist and I don't know it?
Last updated: 2023-10-02

Post by martinlithlith on Mux I2C CODESYS Forge talk (Post)
Hi! I´ll try to get this thread going again as i´m having simliar problems. Right now i get a red triangle on my connected devices (i´m testing with a BME280 sensor and a PCA9685 resvo driver). The TCA9548 have the green symbol beside it. On the "red" devices i get that the bus is not running. I have tried to either run it using the parent bus cycle setting or creating a new freewheeling task prio 1 but nothing helps. I have compared my settings to the settings from the example from the MUX package and i have read (i think) every thread in forge that could be of interest. EDIT: The ic2detect only shows the mux (70-70) and the servo drive (70-76) so i´ll look in to if i managed to burn the 280-sensor while soldering). Another question regarding the 280 sensor. I have a sensor GY-BM E/P 280 that should record humidity and temperatur. Could this be a problem with the library? Does anyone have an idea of what i might be doing wrong? I have some experience from Codesys but not much so this could be an easy one. All suggestions are welcome. I tried to upload the project archive but it did not work. Should i upload the export or how could i show you my horrible project? Best, Martin
Last updated: 2023-10-22

Post by riccardo on VisuElems.CurrentUserGroupId is not stable CODESYS Forge talk (Post)
GoodMorning everyone. I have a system that, in case of alarm, have to block. When the operator logs in must have to acknoledge the alarm and should operate in the system freely. To perform this I detect the logged User by (VisuElems.CurrentUserGroupID <> 0) with a similar code to the the following: PROGRAM AlarmMngt VAR alarm : BOOL:= FALSE; Ack : BOOL:= TRUE; PushBottonOpening : BOOL:= FALSE; Valve : BOOL := FALSE; Flag: BOOL := FALSE; END_VAR IF alarm AND Ack AND (NOT Flag) THEN valve := FALSE; PushBottonOpening := FALSE; Ack := FALSE flag := TRUE; ELSIF (NOT alarm) AND Ack THEN flag := FALSE; END_IF (* if the system is in alarm but there is a logged operator that acknowledge the alarm the system allows the valve opening.*) IF (VisuElems.CurrentUserGroupID <> 0) AND Ack AND Alarm AND PushBottonOpening THEN Valve := TRUE; ELSIF (VisuElems.CurrentUserGroupID = 0) AND Alarm THEN valve := FALSE; END_IF The problem I have is in the last 5 lines of the code: Even if there is a logged in user, the GroupID variable is subjected to a refresh that cyclically set for an instant it to 0 and this close the valve making difficult to the user to work Now I solved it creating a time hysteresys cycle but it is not a good solution. Someone is able to explane me why the GroupID variable is sobjected to this refresh and how to stabilize to avoiding it? Thank you in advance, Riccardo
Last updated: 2023-11-10

Post by manuknecht on High Cycle Times for SoftMotion_PlanningTask when using AxisGroup CODESYS Forge talk (Post)
Hello all I am using an AxisGroup with the Gantry2 Kinematics to move a 2D-Gantry system. When creating the AxisGroup, the SoftMotion_PlanningTask is created automatically with a cycle time of 2 ms in my case. I realized that the maximum cycle time of this task can spike to very high values (up to 60 ms) at lower speeds of the motion, leading to synchronization issues and errors on the axes. The same behaviour - though not as drastic - can be observed with virtual axes too. Is this behaviour intended or to be expected? Can the cycle time or type of the SoftMotion_PlanningTask be changed to prevent these errors? Or is there another fix for this issue? I tried changing the cycle type to Freewheeling, which solved the synchronization issues, but caused an error on the AxisGroup after a while, reading SMC_CP_QUEUE_UNDERRUN. Thanks in advance and best regards Manuel
Last updated: 2024-03-07

Post by fajean on CODESYS control on RPi starts, shortly runs, then exits CODESYS Forge talk (Post)
I have a Raspberry Pi 4 we have been using for years to run CODESYS for development purposes. I recently have had to re-install the OS (Raspberry OS lite). The only change to the default configuration is not creating the "pi" user during install. I (apparently successfully) installed the 4.10.0.0 control on the Raspberry Pi. We have licences on a dongle. I am able to start the control. systemctl status shows it as running for a little while (exactly, precisely 30 seconds as per my tests, every time), then it becomes exited. I can restart the control, and the same thing happens again. Every time. In the brief moments it is running, I can log in to the PLC. Working fast and restarting the control many times, I have been able to configure users. I have been able to download my application. I have been able to run the application, and stop on a breakpoint. I have been able to connect with the licence manager and confirm the dongle is detected and licences are listed as OK. I see nothing wrong until the service just exits. I have found nothing in the logs. It is like the runtime just terminates with no error code or message after exactly 30 seconds. Any help would be appreciated.
Last updated: 2024-06-13

Post by mainak on Opaque NodeId in the OPC UA server CODESYS Forge talk (Post)
Hello all, I am using the OPC UA server with my custom information model. I have used the communication manager to add my information model under my application and created instances from OPC UA types. I see that the created instances in the OPC UA server has some opaque nodeid (attached screenshot) and I want to change that. Therefore I have the following questions: 1. Is there a way to configure the NodeIds of instances in the OPC UA server? I tried to edit it using the UaExpert client but got error "BadNotWriteable". is it possible to configure it somewhere so that the nodeids can be changed using an external client? 2. Is there a way to define the rule for creating instance nodeids within the codesys IDE? 3. Is it possible to create the instances before e.g. using a modelling tool like UaModeler and import them as part of the information model and use them later? Using the communication manager, I can only create instances from types. I couldn't find a way to map my existing instances to plc tags from my application. It would be nice if someone could help me with these issues. Thanks in advance. :)
Last updated: 2024-10-19

Post by lsislsis on SIGABRT Error CODESYS Forge talk (Post)
Please help us. Why we take this errors. We try different versions like 4.12.0 and 4.13.0 with same results. ;*********;<loggername>codesyscontrol.log</loggername>;<logoptions>; <enable>1</enable>; <type>normal</type>; <timestamp>rtc high resolution</timestamp>; <deactivatable>0</deactivatable>; <dump>always</dump>; <filter>0x0000000f<filter>; <maxentries>100000</maxentries>; <maxfiles>1</maxfiles>; <maxfilesize>1000000</maxfilesize>;</filter></filter></logoptions>;<entries>;Timestamp, CmpId, ClassId, ErrorId, InfoId, InfoText;ClassId: LOG_INFO =1;ClassId: LOG_WARNING =2;ClassId: LOG_ERROR =4;ClassId: LOG_EXCEPTION =8;ClassId: LOG_DEBUG =16;ClassId: LOG_PRINTF =32;ClassId: LOG_COM =64;</entries>;*********2024-11-05T08:23:59.728Z, 0x0000100c, 1, 0, 0, VisuFctCheckForUnusedClients: Removing Client with IEC-ID: 1 Time delta: T#33s1ms Locks: Paintbuffer: TRUE 2024-11-05T08:23:59.728Z, 0x0000100c, 1, 0, 0, VisuFctCheckForUnusedClients: Successfully Removed Client at Address: 547195449944, IEC-ID was: 1, EXT-ID: 431000373 2024-11-05T08:28:57.913Z, 0x0000100c, 1, 0, 0, Visu_PRG: Creating Client for Extern-ID: 347055752 2024-11-05T08:28:57.926Z, 0x0000100c, 1, 0, 0, Visu_PRG: Creating Client successful for Extern-ID: 347055752 Returned IEC-ID: 1 2024-11-05T08:30:51.103Z, 0x0000100c, 1, 0, 0, Visu_PRG: Successfully Removed Client with IEC-ID: 1, Extern-ID: 347055752 2024-11-05T08:37:36.517Z, 0x00000103, 65544, 1, 0, runtime received SIGABRT - system may be in an inconsistent state* We recommend a reboot of the controller now! 2024-11-05T08:37:36.517Z, 0x00000111, 8, 260, 3, #### Exception: HANDLED EXCPT <excpt>NonContinuable</excpt> in CH_COMM_CYCLE 2024-11-05T08:47:42.117Z, 0x00000103, 65544, 1, 0, runtime received SIGABRT - system may be in an inconsistent state We recommend a reboot of the controller now! 2024-11-05T08:47:42.117Z, 0x00000111, 8, 260, 3, #### Exception: HANDLED EXCPT <excpt>NonContinuable</excpt> in CH_COMM_CYCLE 2024-11-05T09:14:41.316Z, 0x00000071, 1, 0, 13, Webserver stopped 2024-11-05T09:14:44.485Z, 0x0000013d, 1, 0, 4, Number of licensed cores for IEC-tasks: 1 from 4 2024-11-05T09:14:44.487Z, 0x0000013d, 1, 0, 4, Number of licensed cores for IEC-tasks: 4 from 4 2024-11-05T09:14:44.540Z, 0x00000002, 1, 0, 2, Application [<app>Application</app>] loaded via [Download] 2024-11-05T09:14:55.894Z, 0x00001012, 1, 0, 0, Opened alarm storage file, version: 6 2024-11-05T09:14:55.951Z, 0x0000100c, 1, 0, 0, Visuinitialization starting. 2024-11-05T09:14:55.983Z, 0x0000100c, 1, 0, 0, Visuinitialization done. 2024-11-05T09:14:55.995Z, 0x00000071, 1, 0, 12, Webserver started 2024-11-05T09:15:01.753Z, 0x0000100c, 1, 0, 0, Visu_PRG: Creating Client for Extern-ID: 2279884529 2024-11-05T09:15:01.753Z, 0x0000100c, 1, 0, 0, Visu_PRG: Creating Client successful for Extern-ID: 2279884529 Returned IEC-ID: 0 2024-11-05T09:34:44.667Z, 0x00000103, 65544, 1, 0, runtime received SIGABRT - system may be in an inconsistent state We recommend a reboot of the controller now! 2024-11-05T09:34:44.667Z, 0x00000111, 8, 260, 3, #### Exception: More than 2 exceptions in CH_COMM_CYCLE: Stop logging 2024-11-05T10:13:26.867Z, 0x00000103, 65544, 1, 0, runtime received SIGABRT - system may be in an inconsistent state We recommend a reboot of the controller now! 2024-11-05T10:15:21.966Z, 0x00000103, 65544, 1, 0, runtime received SIGABRT - system may be in an inconsistent state We recommend a reboot of the controller now! 2024-11-05T10:19:12.167Z, 0x00000103, 65544, 1, 0, runtime received SIGABRT - system may be in an inconsistent state We recommend a reboot of the controller now! 2024-11-05T10:26:02.566Z, 0x00000103, 65544, 1, 0, runtime received SIGABRT - system may be in an inconsistent state We recommend a reboot of the controller now! 2024-11-05T10:31:42.866Z, 0x00000103, 65544, 1, 0, runtime received SIGABRT - system may be in an inconsistent state We recommend a reboot of the controller now! 2024-11-05T11:01:54.468Z, 0x00000103, 65544, 1, 0, runtime received SIGABRT - system may be in an inconsistent state We recommend a reboot of the controller now! 2024-11-05T11:09:29.868Z, 0x00000103, 65544, 1, 0, runtime received SIGABRT - system may be in an inconsistent state We recommend a reboot of the controller now! 2024-11-05T11:14:44.540Z, 0x0000100d, 1, 0, 0, Demo mode expired. 2024-11-05T11:27:20.868Z, 0x00000103, 65544, 1, 0, runtime received SIGABRT - system may be in an inconsistent state We recommend a reboot of the controller now! * Regards
Last updated: 2024-11-05

Post by dantheman on Connecting to SoftPLC Only Works By Turning Off Modbus Ethernet Port CODESYS Forge talk (Post)
I have an IPC with 2 ethernet ports and 1 Wi-Fi. I'm using ModbusTCP with the ethernet port named "enp2s0" connected to my remote I/O. This works fine when testing with Python and also works with CODESYS, but CODESYS is only able to scan for the Linux SoftPLC when I turn off the "enp2s0" interface. In other words, I can't get online with the IDE if I want my ModbusTCP comms to run with CODESYS. I'm using a Linux SoftPLC that has the following entry in CODESYSControl.cfg, hoping that this will allow me to connect with "enp1s0" or "wlp3s0", and leave "enp2s0" for field comms, but this seems to only make the source IP of the ModbusTCP comms to be bound to "enp2s0". That last point is the case only if I don't restart the service, but if I do restart the service after changing the config file, the source IP for the ModbusTCP comms then becomes the one for "enp1s0", which is very confusing to me: [SysSocket] Adapter.0.Name="enp2s0" Adapter.0.EnableSetIpAndMask=1 On the device list, I only have "enp2s0" given as the ethernet device that has the ModbusTCP master & slave beneath it, shown in Screenshot 1. On the IPC, I can ping the ModbusTCP client (remote I/O) from "enp2s0", and I've attached a Wireshark capture of running ModbusTCP from the CODESYS runtime as Screenshot 2, 3 & 4 (again, I can't get online when this is running, I have to turn off "enp2s0" to connect even when it's idle and I don't have an active TCP session with my Python tests). Like I explained above, the source IP is "enp1s0", even though the ethernet device on the project is "enp2s0". I was lucky to catch the red message that showed the source IP that makes sense to me (the one for "enp2s0"), but for some reason that connection was reset and I never saw that packet again. I've also tried this with Auto-reconnect both enabled & disabled, for the ModbusTCP Master device. I also have to turn off "enp1s0" and then turn it on, just so that I can have the ModbusTCP comms running from "enp2s0" (which is not intuitive in any way to me, I'd love some help understanding that phenomenon as well) in the weird manner that I've described above. I would be very appreciative if someone can help me figure out this pickle. I'd love to just connect to CODESYS through my Wi-Fi interface and leave my ethernet ports for field comms.
Last updated: 2024-08-01

Post by oi18ct on ARM SL Development Board Recommendation CODESYS Forge talk (Post)
Hello codesys forum, My company is looking at developing a solution with Codesys ARM SL. The requirements will not tax the capabilities of Codesys. I would like to buy an AMR 7 or 8 Dev Board for experimenting. I am looking for a recommendation as I have minimal experience with Linux. Any input from the forum would be most appreciated as the hardware requirements as provided by Codesys for ARM SL seem pretty minimal (basically a arm7 or 8 with Debian is all). Our needs are small in scale- something like 8 digital inputs, 6 digital outputs, 2 analog inputs and 1 analog output. A small gui will be published via web visualization for external display (no local display). Communications with ModbusTCP and uart/RS485. It may be necessary to access i2c and make c or python calls to some existing code that is pretty small. Something like the EMCraft STM32MP1 SOM Starter Kit or Octavo Systems OSD32MP1-RED development board? Ideally something that has a path to a SoM for production. Kontron appears to have some interesting options too. Just having a hard time deciding where to start. Thanks in advance... LC
Last updated: 2023-11-11

Post by brell on Automatic xExecute NBS.TCP_write CODESYS Forge talk (Post)
I've recently started experimenting with CODESYS for a project and am fairly new to it. I'm currently working with Function Block Diagrams (FBD) to set up TCP communication between a server and a client, where the client is implemented as a Python script. Once the communication is established, my connection status changes to True, which is the expected behavior. My challenge arises with the TCP write module, which requires the xEnable_write flag to toggle between True and False. If xEnable_write remains True, the module only performs a single write operation. To address this, I introduced a falling edge trigger (F_TRIG), expecting it to help in toggling xEnable_write and it does, However, I've encountered an issue where in the beginning after connxion established I need to manually set xEnable_write to True for the system to work as intended. I'm looking for a way to automate this process so that xEnable_write becomes True automatically upon establishing a connection . Initially, I tried setting xEnable_write to True from the start, but this approach didn't work well since it left the flag permanently True, preventing further toggling. I also experimented with using a TON timer, but I faced similar issues. I am seeking a solution that automatically toggles xEnable_write between True and False after a connection is established, ensuring continuous write operations without manual intervention. Any advice or guidance on how to achieve this would be greatly appreciated."
Last updated: 2024-03-05

Post by thewizard8 on Raspberry PI4 Serial Port CODESYS Forge talk (Post)
Hi Dear All, I'm using my raspberry PI4 as a CoDeSyS PLC (Build from scratch with custom electronics). I was able to implement all fieldbuses with the exception of Modbus Serial. I'm using the internal Port (GPIO) and I configured it in /etc/Codesyscontrol_user.cfg the following away: [SysCom] Linux.Devicefile.1=/dev/ttyUSB0 Linux.Devicefile.2=/dev/ttyS0 I'm using COM2 on Master configuration. I'm using a interface board from TTL/RS485 (bidirectional board), and it's works perfectly with other devices but not in CoDeSyS. I'm able to send data with python script and read it on my pc using putty, but when I use a modbus slave simulator to interface with codesys I always get red icons on master and slave. (Please find image attached). I'm pretty shure that this might be a bad parameter on my CoDeSyS runtime configurstion file. Can someone help me? I'm stuck and this is for my master degree certification.
Last updated: 2024-03-18

Post by ahuckphin on Issues with Modbus Slave with Raspberry Pi CODESYS Forge talk (Post)
I have a DFRobot RS485 temperature & humidity sensor (SEN0438) connected to my Raspberry Pi via a USB to RS485 adapter. I am able to connect and read the sensor data when running a python code locally. However in Codesys, I encounter this error "A bus error has occurred." and "There was no response in time". Could this be because of Modbus Server Channel and Modbus Server Init configuration on my part? Admittedly I am new to Codesys. To get to this stage, I: 1. added some lines to CODESYSControl_User.cfg 2. added "Modbus_COM" in Codesys and set "Serial Port Configuration" under "General" 3. added "Modbus_Master_COM_Port" in Codesys and checked transmission mode is set to "RTU" 4. added "Modbus_Slave_COM_Port" in Codesys and checked server address is set to 1 (also set 1 in my sensor) 5. added 1 channel and 1 init for "Modbus_Slave_COM_Port" under "Modbus Server Channel" and "Modbus Server Init"
Last updated: 2024-07-10

Post by manuknecht on Opening a Dialog on a specific Client from ST CODESYS Forge talk (Post)
I managed to find a solution that seems to work reliably. As the VU.Globals.CurrentClient-filter accesses the CURRENTCLIENTID or at least a similar, internal variable it can only be used if called from a certain client (e.g. from a button in a visualization). My solution works by implementing a new client filter that compares the client ID of all clients to the ID of the last client that was used. The variable containing the data of the last client is defined as: G_LastClient : VU.IVisualizationClient; // Copy of last client that detected click This last client is then updated every time a button is pressed using the Execute ST-Code input configuration of the button: G_LastClient := VU.PublicVariables.Clients.Current; Next, I created a function block that implements the client filter interface as so: FUNCTION_BLOCK FB_LastClientFilter IMPLEMENTS VU.IVisualizationClientFilter VAR_INPUT END_VAR VAR_OUTPUT END_VAR VAR END_VAR Then i added a method to the FB called IsAccepted which is used to filter out the client. When creating the method, it should automatically be filled with the according variable declaration, as it is defined in the interface: (* For every client can be desided, if it is accepted. ``TRUE``: Client is accepted*) METHOD IsAccepted : BOOL VAR_INPUT (* The client, to check*) itfClient : VU.IVisualizationClient; END_VAR Now the client can be compared to the last used client as such: // check if clientID corresponds to clientID of last recorderd client IF itfCLient.ClientId = G_LastClient.ClientId THEN IsAccepted := TRUE; ELSE IsAccepted := FALSE; END_IF To make use of this custom client filter, initialize a variable with the client filter: LastClient : FB_LastClientFilter; // Client filter to find last used client Then use this client filter when opening or closing a dialog from ST: fbOpenMyDialog(itfClientFilter:=LastClient,xExecute:=TRUE,sDialogName:='VIS_MyDialog_DLG');
Last updated: 2023-09-27

<< < 1 .. 11 12 13 14 > >> (Page 13 of 14)

Showing results of 341

Sort by relevance or date