Post by codesysbeginner on Eaton XC303 - USB Mounting / Trend manager
CODESYS Forge
talk
(Post)
Hi, For a project I am using the trendmanager functionality, I changed the placeholder filepath to which the SQL database is saved to: home/disk_usb, $trend$. Which only works as long as the usb was mounted to the PLC at boot. However, I'd like to be able to switch the USB's out if they break or for data analysis. However when a new (or the same) USB is plugged back in the shortcut doens't exist on the device anymore. Also in the device directory under root/mnt/ a new folder appears SDB1 in addition to SDA1 to which the Trendmanager was originally writing. The SDA1 folder is empty/unreachable while the new SDB1 folder has the contents of the USB drive. I tried disabling the trendmanger while unplugging the USB's however this doesn't work. My question, how do I make it so that when I plug a USB drive back in, it will be mounted to SDA1 instead of SDB1? Kind Regards
Last updated: 2024-10-09
Post by etienneneu on Trend x-axis description incorrect display
CODESYS Forge
talk
(Post)
Hello everyone, maybe someone can help me with the following problem. I wanted to insert a trend element in my visualization. The problem is that I have set fixed fonts with a scaling of 1.5 for the individual languages via the visualization manager. This setting means that I have this scaling in every element, which has been quite comfortable so far because I didn't have to set the individual properties in the text fields. But in the trend element, even if I select other font sizes or fonts in the element itself, this font is also overwritten and I get a label on the x-axis that is no longer displayed correctly. Is there a way to prevent the overwriting of the font properties in this element or similar behavior? I mean, I could change the font size of each element manually, but the Visu app is a bit larger and it would be easier to have another option. Best regards Etienne
Last updated: 2024-11-28
Post by mubeta on Strange problem with the ‘MC_SetPosition’ function
CODESYS Forge
talk
(Post)
Hi gseidel, before moving to HW implementation, I had created the same program in simulation mode with virtual drives and, as far as I remember, everything worked fine simulating process and the few useful inputs. So it does not seem to be a SoftMotion library problem, but rather a problem with dynamics or physical axis adjustments. What escapes me, however, is the fact that this function is supposed to perform a position shift virtually, in fact without interfering with the axis itself, thus independent of its adjustments. MC_SetPosition() is not a homing function, in fact it is clearly intended to be executed on the fly with the axis moving. Now I'll see if I can reduce the program, although I don't like it very much. In my life I have learned that problem searches should be done on the part, and not in a more or less similar way.
Last updated: 2025-01-10
Post by timvh on STRING conversions to DWORD
CODESYS Forge
talk
(Post)
I guess that the printer expects to receive an array of byte values. So where it is described that it expects to receive: Hercules String : 1B4F513030311B7532626C61636B04 it actually expects to receive an array of bytes with the values 1B,4F,51,30,30, etc. So what you can do is create an array of bytes and assign the byte value to each item in the array: VAR abyToSend : ARRAY[0..99] OF BYTE; END_VAR abyToSend[0] := 16#1B; // ASCII Escape character, hexadecimal representation uses 16# as prefix abyToSend[1] := 16#4F; // ASCII 'O' abyToSend[2] := 16#51; // ASCII 'Q' abyToSend[3] := 16#30; // ASCII '0' // you can do the rest yourself // maybe could be created a lot smarter, but gives you an indication how to handle this. Then with the serial communication (or TCP/IP?) you can send a message with the reference to the array (abyToSend) and the number of bytes to send (15 bytes for the string you gave as example).
Last updated: 2025-02-02
Post by timvh on Device diagnosis ( EtherCAT IO card )
CODESYS Forge
talk
(Post)
You can get the state by just using the name of your node (same name as in device tree): VAR etcState: IoDrvEthercatDriverLib.ETC_SLAVE_STATE; END_VAR etcState := EJ1100.wState; Alternatively, you can iterate through the device tree to get the status of all (Ethercat) nodes. See here an example (no guarantee it works, just give as suggestion): PROGRAM P_IO_State VAR CONSTANT uiMAX_NR_OF_TERMINALS : UINT := 100; END_VAR VAR // general device diagnosis // can only be used when the Device - PLC Settings - Advanced settings - enable diagnosis for devices is enabled // this will add the DED library coupler: DED.INode; terminal: DED.INode; aDeviceState: ARRAY[0..uiMAX_NR_OF_TERMINALS - 1] OF DED.DEVICE_STATE; uiTerminalCount : UINT; uiIndex : UINT; // for each terminal check if it implements device diagnostics xQueryResult: BOOL; itfDevice : DED.IDevice2; xDiagAvailable: BOOL; eError: DED.ERROR; xEverythingOK: BOOL; END_VAR uiTerminalCount := 0; // start at the top of the device tree with the first EtherCAT coupler coupler := EtherCAT_Master.FirstChildNode; WHILE coupler <> 0 DO // for each coupler that is found start at the first terminal terminal := coupler.FirstChildNode; WHILE terminal <> 0 AND uiTerminalCount < uiMAX_NR_OF_TERMINALS - 1 DO // for each terminal that is found get the status through the device diagnosis interface xQueryResult := __QUERYINTERFACE(terminal, itfDevice); IF xQueryResult THEN aDeviceState[uiTerminalCount] := itfDevice.GetDeviceState(xDiagnosisInfoAvailable => xDiagAvailable, eError => eError); uiTerminalCount := uiTerminalCount + 1; END_IF terminal := terminal.NextSiblingNode; END_WHILE coupler := coupler.NextSiblingNode; END_WHILE uiIndex := 0; xEverythingOK := TRUE; WHILE uiIndex < uiTerminalCount DO IF aDeviceState[uiIndex] <> DED.DEVICE_STATE.RUNNING THEN xEverythingOK := FALSE; EXIT; END_IF uiIndex := uiIndex + 1; END_WHILE
Last updated: 2025-02-06
Post by carl25 on Confused about stepper spec & tips on pwm-step/dir
CODESYS Forge
talk
(Post)
Hello! I have asked the few I know who have knowledge of this and now turn to this one inexhaustible source of knowledge aka. the electronics forum. I was going to buy stepper motors yesterday but got so confused about the spec that I need to get an answer to this first. 2 different stepper motors, quite close in size but with very different spec. https://www.oyostepper.de/goods-40-Nema-17-Schrittmotor-Bipolar-12V-18-Grad-40Ncm-04A-12-Volt-4-Dr%C3%A4hte-Hybrid-Schrittmotor.html https://www.oyostepper.de/goods-38-Nema-17-Schrittmotor-Bipolar-18-deg-22Ncm-133A-28V-4-Dr%C3%A4hte-Hybrid-Schrittmotor.html Both Nema17 but the first 1.33A and 22Ncm and the second only 0.4A but almost double the torque. I can see that the resistance is very much higher on the latter but what's the catch? Double the torque to 1/3 the current sounds a little too good to be true so what am I missing?
Last updated: 2025-02-21
Post by pernockham on Inheritence of struct,
CODESYS Forge
talk
(Post)
Im looking for a way to define predefined version of the same structures through "extends"/inheritance. What I want to do is best shown with an example: TYPE log_item_val_type : ( BOOL_ := 0, INT_, REAL_, STRING_ ); END_TYPE TYPE LOG_DATA_BASE STRUCT val_type : log_item_val_type; (* value, name etc *) ENDSTRUCT ENDTYPE (* this/below is not possible as I understand from the compiler?? *) TYPE LOG_DATA_BOOL extends LOG_DATA_BASE : STRUCT val_type : log_item_val_type := log_item_val_type.BOOL_; END_STRUCT END_TYPE TYPE LOG_DATA_INT extends LOG_DATA_BASE : STRUCT val_type : log_item_val_type := log_item_val_type.INT_; END_STRUCT END_TYPE etc. for LOG_DATA_REAL and ..STRING. The system will not allow me to "re-define" "val_type" however. Instead I must do the work-around of defining four different types with all fields individually defined. The benefit if I could extend the base item would be that Im (more) sure the structures are identical. In usage I can call in a specific type rather use the base type and assign which type. Usage by pointer/ref to log_data_base would also be easier.. (* Usage: *) log_data : log_data_int := (name, value etc.) (* Instead of: *) log_data : log_data_base := (name, value, val_type).. Is this possible to achieve in some way that I have missed?
Last updated: 2025-03-05
Post by imdatatas on Auto Declare window disappears by itself in the Ladder editor
CODESYS Forge
talk
(Post)
Hello Everyone, The "Auto Declare" window disappears by itself in the Ladder editor. For example, a new function block is wanted to be added to the Ladder editor. (For example; MC_Jog block and instance name will be fbMcJog). To do this, "Empty box with EN/ENO" is added to the ladder line from the Toolbox on the right and when you type MC_Jog in the empty box and press enter, normally the "Auto Declare" window appears and you are expected to be asked to write the instance name here. However, this "Auto Declare" window closes itself immediately, it does not wait for the user to enter a value or close the window. I often encounter this situation in many IDE versions. Does this seem like a bug? If anyone has encountered a similar problem while creating a new program name, function or function block instance name regarding the "Auto Declare" window and knows a solution, I would be glad if you could share it. Best wishes Imdat
Last updated: 2025-03-06
Post by ojz0r on Assignment Efficiency - Repetitive Assignment vs IF statement
CODESYS Forge
talk
(Post)
Its important that you know the difference between the two. Example 1: Coils[0] := Coils[0] OR (Buttons[0] AND Sensors[0] > 6); In this case the statements will be evaluated every scan and result in either true or false for Coils[0]. Example 2: IF NOT Coils[0] AND Buttons[0] AND (Sensors[0] > 6) THEN Coils[0] := TRUE; END_IF In this example Coils[0] will latch the result in a true evaluation, if you want it to behave the same way as example 1 then you need to do it like example 3 below: IF NOT Coils[0] AND Buttons[0] AND (Sensors[0] > 6) THEN Coils[0] := TRUE; ELSE Coils[0] := FALSE; END_IF However back to the real question. There is no problem using either example 1 or example 3, if im not requiring a latch i usually go with example 1 as it is more compact.
Last updated: 2025-03-07
Post by pikebuster on Help for a newbie
CODESYS Forge
talk
(Post)
Can somebody help me with this? I have problem with the button! This task must be solved using Sequential Function Chart (SFC), IEC 61131-3. TASK Create an SFC program to control a traffic light at an intersection. Description: You will program a traffic light that has three phases: Green, Yellow, and Red. The traffic light must follow these rules: Green light is on for 10 seconds. Yellow light is on for 3 seconds. Red light is on for 10 seconds. If the pedestrian button is pressed, the system must keep the red light on for 20 seconds during the next cycle. After the pedestrian has “crossed,” the system should return to its normal cycle. Basic Steps: Initialization: Start by setting the traffic light to Red. Green Phase: After 10 seconds, switch to Green. Yellow Phase: After 10 seconds in the Green phase, switch to Yellow. Red Phase: After 3 seconds in the Yellow phase, switch back to Red. Loop: Repeat the cycle. Use, for example, lamp symbols in the visualization module to simulate the traffic light. You may also add a simple pedestrian light if desired.
Last updated: 2025-03-11
Post by egau on Enable and Disable Project IO programmatically
CODESYS Forge
talk
(Post)
Hi @eschwellinger, I tried this with Modbus COM slaves. I was able to disable them (slave becomes greyed out in the device tree), but the DED.Reconfigure "eError" output shows "NOT_SUPPORTED". After this, when I tried to re-enable the slave, it did not work (device stayed greyed out in the device tree), and the DED.Reconfigure "eError" output also showed "NOT_SUPPORTED". Is there something to do about this, or the device just doesn't support reconfiguration? P.S: I tried this running locally on my computer (not in simulation mode). So of course I was not physically connected to the devices. I have two similar projects, but one of them doesn't have the Modbus_COM devices. I know I can "Exclude from build" the devices for that project, but I would really prefer not to do this if possible. I would prefer to dynamically toggle a configuration variable that would enable or disable the slaves.
Last updated: 2025-03-14
Post by nz-dave on MC_HOMING
CODESYS Forge
talk
(Post)
Hi Just new to motion and i am building my own 3axis cnc cutter using servo drives. i have every thing working quite well apart from mc_home. when executed (r_trig) it stops immediately and i get fb_wasnt_called_during_motion. if i execute the mc_home fb with a toggle it just runs and runs for a while then errors out. what im unsure of is the way mc_home works. from what i understand it changes the drive mode to 6 (homing) and should then run of the drive homing settings. once origin sensor is made then homing would stop and mc_home.done is true. and the position on the fb is where i what the new home position (zero) to be? or do i feed mc_readposition to that input? so i would think its the settings in the drive that aren't quite right. but i believe they are all correct. has any one got any info to steer me in the right direction? Cheers
Last updated: 2025-04-04
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 mubeta on Strange problem with the ‘MC_SetPosition’ function
CODESYS Forge
talk
(Post)
How are the servo drives controlled? EtherCAT, step/dir pulses, other? CANOpen, 1 Mb/s, bus load 35%, cycle time 2ms. Another thought is that - if it's step/dir pulse based control - the pulses from the PLC to the drive are getting missed/lost at high frequencies? If that's the case then there would be multiple troubleshooting steps/corrections that could be investigated. Here, it seems to me that we are getting completely off track with the observed problem. You could try to create a simplified program I had already written this elsewhere. The program before being brought into machines was exhaustively tested in SW emulation and the problem did not occur. However, in emulation I was interested in checking other aspects of the process, not this specific one which is for real a correction made necessary after the fact. The part of the program that does this correction with the function mentioned in the topic, came up from its origins, but I didn't know or didn't think it was really useful. A scruple that later turned out to be necessary. However, for now I do not think I will spend any more time on this verification, already lacking any to do my normal. I remain amazed, however, that a function intended to correct the axis position with the motor in motion and that it should not interfere with this, in fact instead changes behavior as the motor speed changes. Mah! When you manually control the motor directly from the servo drive software at the speeds you are calling for, does it move precisely to the target position? The drive and motor have been working fine for about 10 years. In replacing the machine control system, I opted for CoDeSys where before there was something else. But this is not the subject of the problem. What I need to resolve is the fact that a clutch specially placed at a certain point can slip and, therefore, I have the undeniable need to phase the 'prime mover' to the mechanical position of the machine, detected by a cam for each turn, in order to properly stop at its optimum point. Which for now I have ruled out doing. In fact, if I really have to say, since we have now gone brutally OT, I originally thought that this clutch should only come into action in cases of extreme necessity, as happens in most trials. But this one, the way it is made, slips more easily than I could estimate and the servo-controlled 'prime mover,' and the machine, get out of phase, maybe by a little, but frequently, and when the machine work at it's high speed, (in fact all of the time), I can't adjust properly the 'prime mover' position at fly.
Last updated: 2025-01-18
Post by ryandmg on Web Client (HMI) Disconnects from Webvisu (Weidmuller u-OS)
CODESYS Forge
talk
(Post)
Hey Everyone, I'm having a bit of a struggle finding settings that will reliably maintain a connection between the webvisu and a touchscreen client. Every so often the HMI disconnects and will perpetually display the red spinning arrow with the "Error Happened, Will resume automatically" text. Power cycling the HMI to force a reconnect will re-establish comms. It seems to happen during periods of inactivity if that's a clue. From what I've gathered so far this seems to have something to do with the webvisu update rate, buffer size as well as the visu task scan rate. We first tried the default settings as follows: Webvisu Update Rate: 200 ms Webvisu Buffer Size: 50,000 Visu Task Scan Rate: 100 ms Priority 31 Other Tasks for Reference: Main Task Scan Rate: 100 ms Priority 1 Alarm Manager Scan Rate: 50 ms Priority 31 Ethercat Task: 4 ms Priority 1 This would disconnect some what regularly. We then made the following changes to try and stabilize: Webvisu Update Rate: 150 ms Webvisu Buffer Size: 75,000 Visu Task Scan Rate: 75 ms Kept other tasks the same. This seems to disconnect even more frequently. Also for reference the network is very small and only consists of the PLC, a small switch and the HMI. We're also not controlling frames from outside the visu program itself. The frame changes are all done natively. Any suggestions to get this to stop disconnecting? Oh and whatever the issue is the log does not record it. Figured I would ask here before opening a ticket. Thanks in advance for your help!
Last updated: 2023-09-06
Post by wildcard on Modbus Client Request Not Processed
CODESYS Forge
talk
(Post)
Hi, does anyone has a solution for this issue. I've the same problem. I've implemented a very simple client based on the Modbus Examples and connected the soft PLC to a Modbus Simulator. PROGRAM ModbusClient VAR initDone : BOOL := FALSE; errorID : ModbusFB.Error; client : ModbusFB.ClientTCP; timeout : UDINT := 500000; replyTimeout : UDINT := 200000; aUINT : ARRAY [0..8] OF UINT; clientRequestReadHoldingRegisters : ModbusFB.ClientRequestReadHoldingRegisters; clientRequestsCnt : UINT := 0; clientRequestsProcessCnt : UINT := 0; ipAddress : ARRAY[0..3] OF BYTE := [10,54,0,72]; END_VAR IF NOT initDone THEN initDone := TRUE; client(aIPaddr:=ipAddress, udiLogOptions:=ModbusFB.LoggingOptions.All); client(xConnect:=TRUE, ); clientRequestReadHoldingRegisters(rClient:=client, udiTimeOut:=timeout, uiUnitId:=1, uiStartItem:=0, uiQuantity:=4, pData:=ADR(aUINT[0]), udiReplyTimeout:=replyTimeout); clientRequestReadHoldingRegisters.xExecute := TRUE; clientRequestsCnt := 0; END_IF clientRequestReadHoldingRegisters(rClient:=client, udiTimeOut:=timeout, uiUnitId:=1, uiStartItem:=0, uiQuantity:=4, pData:=ADR(aUINT[0]), udiReplyTimeout:=replyTimeout, xExecute := TRUE); IF clientRequestReadHoldingRegisters.xError THEN clientRequestsCnt := clientRequestsCnt +1 ; errorID := clientRequestReadHoldingRegisters.eErrorID; END_IF clientRequestReadHoldingRegisters(rClient:=client, udiTimeOut:=timeout, uiUnitId:=1, uiStartItem:=0, uiQuantity:=4, pData:=ADR(aUINT[0]), udiReplyTimeout:=replyTimeout, xExecute := NOT clientRequestReadHoldingRegisters.xExecute); When the system is running I do get the following on the logs: 2024-05-13T10:18:07.443Z: Cmp=MODBUS lib, Class=1, Error=0, Info=0, pszInfo= Client.RequestProcessed ClientRequest,16#0164ADC561A0 unitId=1 fc=ReadHoldingRegisters id=2070 state=Error 2024-05-13T10:18:07.443Z: Cmp=MODBUS lib, Class=1, Error=0, Info=0, pszInfo= ClientRequest,16#0164ADC561A0 unitId=1 fc=ReadHoldingRegisters id=2070 change state Error -> None timestamp=63843421226 2024-05-13T10:18:08.444Z: Cmp=MODBUS lib, Class=1, Error=0, Info=0, pszInfo= ClientRequest,16#0164ADC561A0 unitId=1 fc=ReadHoldingRegisters id=2071 change state None -> Init timestamp=63844421420 2024-05-13T10:18:09.444Z: Cmp=MODBUS lib, Class=1, Error=0, Info=0, pszInfo= ClientRequest,16#0164ADC561A0 unitId=1 fc=ReadHoldingRegisters id=2071 change state Init -> Error timestamp=63845421675 But the errorID is jumping between OK and RequestNotProcessed. Any help is very appreciated which gives me a hint what I'm doing wrong. Thanks
Last updated: 2024-05-13
Post by mubeta on Some 'pathetic' errors in SoftMotion program
CODESYS Forge
talk
(Post)
Yes, this is the error the sometimes show up. What make me crazy is the fact that it happens randomly and not each times. I know very well where the problem is, in wich one program row it's located. For each actions of the state machine I have all events recorded with log on text file. it is not problematic for me to find the application point of the fault, but I need to understand why occasionally and for no apparent reason, switching the state machine and thus changing the motion FB, sends the axis into failure (but only occasionally). For example, one case that is often problematic is the execution of the Axis Halt instruction. When, after a MoveAbosulte instruction this returns the event as 'done' and indeed the axis is in standstill, the state machine first sets the move instruction to FALSE, and the next cycle sets the Halt request to TRUE. Some of the time everything works out fine. Occasionally, however, in this exchange, the axis goes into fault, also losing the OPERATIONAL state. Meanwhile, I would like to understand why the motion FB instances must still be called even after the Execute is set to FALSE, especially in view of the fact that the next instruction is programmed to abort the previous one, with BufferMode set to 'Aborting'. All these unnecessary FB calls are an unnecessary overhead on the CPU anyway. Is there any precise rule about when to cease calling the various instances? (It should precisely be the 'done' status that says this one has finished its work).
Last updated: 2024-07-18
Post by tk096 on Some 'pathetic' errors in SoftMotion program
CODESYS Forge
talk
(Post)
Meanwhile, I would like to understand why the motion FB instances must still be called even after the Execute is set to FALSE, especially in view of the fact that the next instruction is programmed to abort the previous one, with BufferMode set to 'Aborting'. All these unnecessary FB calls are an unnecessary overhead on the CPU anyway. Is there any precise rule about when to cease calling the various instances? (It should precisely be the 'done' status that says this one has finished its work). In general: - Motion function blocks have to be called until they report 'Done', 'Error', 'CommandAborted' or a subsequent motion FB with BufferMode=Aborting is started in the current cycle. - Setting the Execute input to FALSE will not abort any ongoing motion of the motion function block. For example, one case that is often problematic is the execution of the Axis Halt instruction. When, after a MoveAbosulte instruction this returns the event as 'done' and indeed the axis is in standstill, the state machine first sets the move instruction to FALSE, and the next cycle sets the Halt request to TRUE. Some of the time everything works out fine. Occasionally, however, in this exchange, the axis goes into fault, also losing the OPERATIONAL state. I think the error SMC_FB_WASNT_CALLED_DURING_MOTION is only a follow-up (and misleading) error that results from the axis not being in operational state anymore (bus problems). Is there an error 'regulator or start not set' in the device log before the error 'motion generating FB wasn't called for at least one cycle'? Which error does the respective function block (Halt.ErrorId) report?
Last updated: 2024-07-22
Post by mubeta on Some 'pathetic' errors in SoftMotion program
CODESYS Forge
talk
(Post)
Thank you for your interest. Your answers are in line with what I knew, so at least it comforts me that I did not misinterpret the situation. However, I don't have an exact match as, for this project over the past few days I have: 1) I have gone back to leaving the various FBs of the motion always called, all of them, and in the state machine I use a boolean to activate the various useful Execute. (But in the future I want to go back and try the programming technique with which I wanted to develop this project); 2) For the occasional error: SMC_FB_WASNT_CALLED_DURING_MOTION perhaps it was due to the fact that I had set the Ethercat bus synchronism only at the CAN master level, but not at the level of individual drives. I have now also activated it for the individual drives and it does indeed seem to have been resolved, but having also adopted the programming technique mentioned in point 1), I cannot say whether this was the solution to the problem, or instead the previous point. Is there an error ‘regulator or start not set’ in the device log before the error ‘motion generating FB wasn't called for at least one cycle’? I can't answer that right now. By now the machine is running and I am no longer there, at this one. Also, I seem to remember that the 'fbeFBerror' drive structure (5-element array), does not cycle, BUT ONCE THE 5 EVENTS AFTER SWITCHING ON, IT DOES NOT UPDATE ANYMORE (but that's another issue), so diagnostics were not easy.
Last updated: 2024-07-24
Post by timo on String nach erlaubten/unerlaubten Zeichen durchsuchen
CODESYS Forge
talk
(Post)
Hallo, Ich bastele gerade an einer möglichst einfachen Möglichkeit mit der ich prüfen kann ob ein String Sonderzeichen enthält. Mein Ansatz ist ein ST FB mit einer Case Schrittkette. Ich vergleiche jedes Zeichen des Strings mit allen Zeichen eines vorher definierten Strings erlaubter Zeichen, der A-Z, a-z und 0-9 enthält und ggf angepasst werden kann, wenn ich weitere Zeichen erlaube. Leider wird meine j Zählervariable nicht richtig ausgeführt. Hat da jemand eine Idee? Oder gibt es eine einfachere Lösung/einen fertigen FB den ich mir anschauen kann? FUNCTION_BLOCK Sonderzeichen_Check VAR_INPUT inputString : STRING; // Zu prüfender String startCheck : BOOL; // Startsignal END_VAR VAR_OUTPUT ok : BOOL; // TRUE, wenn keine ungültigen Zeichen END_VAR VAR i : INT := 1; // Input-String Zähler j : INT := 1; // erlaubte Zeichen Zähler allowedChars: STRING := 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; // Erlaubte Zeichen currentChar : STRING[1]; // Aktuelles Zeichen step : INT := 0; // Schritt END_VAR CASE step OF 0: // Warten auf Start IF startCheck THEN step := 10; END_IF 10: // Initialisierungen i := 1; j := 1; ok := TRUE; // Standard: ok step := 20; 20: // Durchgehen des Eingangs-Strings IF i <= LEN(inputString) THEN currentChar := MID(inputString, i, 1); // Aktuelles Zeichen step := 30; ELSE step := 70; // Alle Zeichen ok END_IF 30: // Durchgehen der erlaubten Zeichen IF j <= LEN(allowedChars) THEN step := 40; // Zu Schritt 40 ELSE step := 60; // Ungültiges Zeichen END_IF 40: // Vergleich IF currentChar = MID(allowedChars, j, 1) THEN i := i + 1; // Nächstes Zeichen im Input step := 20; ELSE j := j + 1; // Nächstes erlaubtes Zeichen step := 30; END_IF 60: // Ungültiges Zeichen ok := FALSE; // Setze auf FALSE step := 0; 70: // Alle Zeichen ok step := 0; END_CASE
Last updated: 2025-01-20
Post by clarenced on Multiple applications on one device sharing variables.
CODESYS Forge
talk
(Post)
I am looking for an example of how to run 2 applications on 1 device that would have global variables shared between the two apps. In this case what I am trying to do is to have the main program logic run as one application and then have the visualization run as a second application. I find this https://us.store.codesys.com/media/n98_media_assets/files/000013-F/0/Multiple%20Applications_en.pdf, that talks about exactly what I want to do, but I can't find the download. The main reason I want to do this is for download speed. Right now it takes at least a minute to download our application to the PLC. A simple program downloads to the PLC in a very short time, but add visualization and the download time gets much longer. If I could download the program separately from the visualization I think that a simple program change would take very little time to download. I have tried create a GVL in the POUs view. This partly works in that both applications can see the GVL, but they each create their own instance of it and the variables are not shared between the two apps. There are ideas of using OPCUA but this raises problems with licensing and having to move any variable that needs to be shared into the Symbol Configuration. This adds a lot of management to keep this up to date. Any ideas would be appreciated thanks.
Last updated: 2025-02-20
Post by bbm1995 on Camera RTSP Feed
CODESYS Forge
talk
(Post)
Hi dgrard, I had the same issue for a long time, but on a WAGO webvisu. Now I'm glad that I can share my solution. I don't know if you are trying to use the webvisu or the target visu, but this works on webvisu: Get "go2rtc" and set it up according to the documentation. I'm running the Windows binary. Here's my example of the go2rtc.yaml config file (contains working example streams): api: listen: ":1984" # default ":1984", HTTP API port ("" - disabled) origin: "*" # default "", allow CORS requests (only * supported) static_dir: "www" # default "", folder for static files (custom web interface) tls_listen: ":443" # default "", enable HTTPS server tls_cert: "./SSL/fullchain.pem" tls_key: "./SSL/privatekey.pem" streams: # Streams with multiple links will fall back on the next link. ABUS TVIP48511: - rtsp://<username>:<password>@<hostname>:<port>/ch1/main - rtsp://<username>:<password>@<hostname>:<port>/ch1/sub # Diagnostic connections Kirchhoff Institute for Physics - Germany: http://pendelcam.kip.uni-heidelberg.de/mjpg/video.mjpg Blanton Bottling, Kentucky - USA: http://camera.buffalotrace.com/mjpg/video.mjpg Tokyo - Japan: http://61.211.241.239/nphMotionJpeg?Resolution=320x240&Quality=Standard Tampere Hacklab - Finland: http://tamperehacklab.tunk.org:38001/nphMotionJpeg?Resolution=640x480&Quality=Clarity Soltorget Pajala - Sweden: http://195.196.36.242/mjpg/video.mjpg Kaiskuru Skistadion - Norway: http://77.222.181.11:8080/mjpg/video.mjpg webrtc: listen: ":8555" #ice_servers: # - urls: [ "stun:localhost:3478" ] # username: "" # credential: "" Access the webinterface of go2rtc and get the link of your stream. Use the link as for your browser frame in the visualization. Depending on your device, you need to be able to access the file /etc/lighttpd/lighttpd.conf or /etc/lighttpd/webvisu.conf and change the contents similar to this one, otherwise you'll get CORS and CSP errors in the browser and you won't be able to view the stream on the webvisu: # Webvisu specific settings $SERVER["socket"] =~ port_webvisu_used_any { url.redirect += ( "^/webvisu/?$" => "/webvisu/webvisu.htm" ) $HTTP["url"] =~ "^/webvisu/?" { var.response_header_policy_webvisu = ( # CSP for WebVisu, allowing inline sources. "Content-Security-Policy" => "default-src 'self' 'unsafe-inline'; media-src *; frame-src *", # CORS for WebVisu, allowing any origin to access. "Access-Control-Allow-Origin" => "*", # Tell older browsers that this page can only be displayed if all ancestor # frames are same origin to the page itself. "X-Frame-Options" => "SAMEORIGIN" ) # Response header policy for WebVisu setenv.set-response-header = var.response_header_policy_webvisu setenv.set-response-header += var.response_header_policy_common }
Last updated: 2023-11-14
Post by george32 on Readable IO names
CODESYS Forge
talk
(Post)
Hello Folks, I have a quite basic understanding of how PLC programming works. However I keep getting stuck on 1 problem I could not get my head around. The problem is as follow: I have a PLC with 60 IO (20 inputs, 40 outputs). Each IO is defined as a function block. Furthermore I have an external IO card connected trough a CanBus connection. This IO card has 4 analog input channels (USINT), 4 digital inputs (Bool) and 4, digital outputs (Bool) Because I have 2 different components which both has data have I made 4 arrays to store the data off every component in one variable. PLC_Input: Array [1..20] of BOOL; PLC_Output: Array [1..40] of BOOL IOCard_Input: Array [1..8] of BOOL IOCard_Output: Array [1..4] of BOOL Because the control and reading of the different in and outputs is done by a TCP connection I want to use some kind of enumeration or struct to give each index a name so that my main would be a little bit more readable instead of all the magic numbers. Also this would make my program more dynamic for the furter in case I need to changes some in the IO nummers. For example: pump is placed on the fysical terminal strip number place 54, which is the 3th output of the IO card in the program: if I am sending a message with value 54 I would like to control IOCard_Output[3]. If there is a solution or methode to get this done, I can eventually do the following in my main program: IOCard_Output[Pump]. I have tried the following: IOCard_Output[Pump - 51] with an enumration but this keeps raising an error I hope some of you could help me further with this problem. In gross lines: I want to couple all the different IO to a more readable name and this readable name should control the right Array index Thanks in advance, George
Last updated: 2024-09-26
Post by jari-koivuluoma on Problem trying Net Base Services 3.5.15.0 TCP connection
CODESYS Forge
talk
(Post)
I have a need to send messages between 2 PLCs and I cant use network variables (because of size limit) so I tried writing this simple test program. This seems to work fine. I can send messages back and forth when a first "Start server" and then "Connect client". See the attached image. However, if I disconnect the client by setting ClientConnect to false and try to re-connect then the TCP_Client just gives me TIMEOUT error. When I stop and start the server again, then Im able to reconnect. How is this supposed to work? Why reconnecting wont work. There is not other way of disconnecting the client than setting xEnable of the TCP_Client to false. This is just a testing program and I will try it on 2 seperate devices once this works. PROGRAM PLC_PRG VAR CONSTANT mySize : UDINT := 255; END_VAR VAR Server: NBS.TCP_Server; ServerIpStr: STRING := '127.0.0.1'; ServerIP: NBS.IP_ADDR; ServerPort: UINT := 50000; ServerConnection: NBS.TCP_Connection; Client: NBS.TCP_Client; ServerRead: NBS.TCP_Read; ServerWrite: NBS.TCP_Write; ServerSend: STRING(mySize); ServerReceive: STRING(mySize); ServerConnect: BOOL; bServerSend: BOOL; IP: NBS.INADDR; ConnectedClientIP: STRING; ClientPort: UINT := 50000; ClientIpStr: STRING := '192.168.1.49'; ClientIP: NBS.IP_ADDR; ClientRead: NBS.TCP_Read; ClientWrite: NBS.TCP_Write; ClientSend: STRING(mySize); ClientReceive: STRING(mySize); ClientConnect: BOOL; bClientSend: BOOL; Error: BOOL; Message: BOOL; END_VAR // Server ServerIP.sAddr := ServerIpStr; Server( ipAddr := ServerIP, uiPort := ServerPort ); ServerConnection( xEnable := Server.xEnable, hServer := Server.hServer, ); IP := ServerConnection.IPAddress; ConnectedClientIP := F_Concat7( BYTE_TO_STRING(IP.S_un_b.s_b1),'.', BYTE_TO_STRING(IP.S_un_b.s_b2),'.', BYTE_TO_STRING(IP.S_un_b.s_b3),'.', BYTE_TO_STRING(IP.S_un_b.s_b4)); ServerRead( xEnable := ServerConnection.xActive, hConnection := ServerConnection.hConnection, szSize := SIZEOF(ServerReceive), pData := ADR(ServerReceive) ); IF ServerRead.xReady AND ServerRead.szCount > 0 THEN Message := TRUE; END_IF IF ServerRead.eError > 0 THEN Error := TRUE; END_IF ServerWrite( xExecute := ServerConnection.xActive AND bServerSend, hConnection := ServerConnection.hConnection, szSize := LEN(ServerSend)+1, pData := ADR(ServerSend) ); IF ServerWrite.xDone THEN bServerSend := FALSE; END_IF IF ServerWrite.eError > 0 THEN Error := TRUE; END_IF // Client ClientIP.sAddr := ClientIpStr; Client( xEnable := ClientConnect, ipAddr := ClientIP, uiPort := ServerPort, udiTimeOut := 10000000 ); ClientRead( xEnable := Client.xActive, hConnection := Client.hConnection, szSize := SIZEOF(ClientReceive), pData := ADR(ClientReceive) ); IF ClientRead.xReady AND ClientRead.szCount > 0 THEN Message := TRUE; END_IF IF ClientRead.eError > 0 THEN Error := TRUE; END_IF ClientWrite( xExecute := Client.xActive AND bClientSend, hConnection := Client.hConnection, szSize := LEN(ClientSend)+1, pData := ADR(ClientSend) ); IF ClientWrite.xDone THEN bClientSend := FALSE; END_IF IF ClientWrite.eError > 0 THEN Error := TRUE; END_IF
Last updated: 2024-10-03
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
.