Post by serwis on Dynamic target position tracking
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      Hello, I am trying to control a servo drive and dynamically set its position. I control the drive via EtherCAT with a cycle time of 500us. I use the MC_MoveAbsolute block for this. The problem is that when using a PID controller, I generate the positions I want the drive to move to on an ongoing basis, and I would like the position to be set immediately. The MC_MoveAbsolute block must receive a rising edge to execute, and I would like the movement to be performed without waiting for this edge. I have created a function that generates a rising edge every 1 ms, but I am unable to change this time to 500 µs because the TON function does not support times shorter than 1 ms. Below is the code to call the rising edge: IF Exe = TRUE THEN delay1(IN:=TRUE, PT:=T#1MS); IF delay1.Q = TRUE THEN Exe := FALSE; delay1(IN:=FALSE); END_IF END_IF IF Exe = FALSE THEN delay(IN:=TRUE, PT:=T#1MS); IF delay.Q = TRUE THEN Exe := TRUE; delay(IN:=FALSE); END_IF END_IF END_IF Here is the code for calling the MC_MoveAbsolute function: MoveDegree( Axis:= Tilt, Execute:= Exe, Position:= position_target - (base_angle_real * feedforward_turn), Velocity:= vel, Acceleration:= acc, Deceleration:= dec, Jerk:= jerk, Direction:= MC_DIRECTION.shortest, BufferMode:= MC_BUFFER_MODE.Aborting, Done=> , Busy=> , Active=> , CommandAborted=> , Error=> , ErrorID=> ); I realize that there are probably better methods for performing this type of task. How can I implement motion with a dynamically changing setpoint? THANKS
    
    Last updated: 2025-09-05
    
    
      
        Post by e13740e on Parameterized Property syntax for array element processing
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      Since parameterized (indexed) properties are not possible, I decided to use architectural approach "Indexing Property Adapter" to achieve the intended goal — avoiding code duplication for validated access to array elements. Essence: Create a Function Block Adapter (FB_PropertyAdapter) that encapsulates the logic for working with a single element of the target array (e.g., with one settings structure). Declare Properties inside the adapter block for accessing each individual field of the data structure. All validation logic is implemented within the Set accessors of these properties. Data Binding via VAR_IN_OUT: The adapter block receives a reference to a specific data element from the global array through its VAR_IN_OUT section, which ensures direct work with the original data without copying. Create an Array of Adapters: In the parent POU (e.g., FB_SettingsManager), an array of these adapter blocks is created — one for each element of the global array that needs to be managed. Initialize Bindings: In a FOR loop, each adapter instance from the array is given a reference to the corresponding data element. Result: This approach allows accessing the data via the index of the adapter array, and then through the property name, which simulates the behavior of an indexed property: MyAdapterArray[Index].MyProperty Thus, the validation and data access logic is written only once inside the adapter block and is then reused multiple times by creating instances of it in an array. This completely solves the problem of code duplication while providing a clean, scalable, and object-oriented architecture compatible with standard CODESYS features. Question closed.
    
    Last updated: 2025-10-19
    
    
      
        Post by bertoldo on Robo Scara3 
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      the interpolation block does not start from the absolute value. It returns to zero even when writing to dLastWayPosX , Y , Z.
    
    Last updated: 2024-10-15
    
    
      
        Post by ojz0r on Leitungsverzweigung mit einem existierenden Block (z.B. AND-Glied) zu verbinden
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      What you want is to use the CFC language instead of FB.
    
    Last updated: 2024-11-11
    
    
      
        Post by enricoghisla on Functional block
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      How can i access to the variable in the FB from outside without put them in the in/out?
    
    Last updated: 2024-04-16
    
    
      
        Post by enricoghisla on Functional block
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      How can i access to the variable in the FB from outside without put them in the in/out?
    
    Last updated: 2024-04-16
    
    
      
        Post by snhatton on How to write a for loop in ladder?
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      Hi there, little late to the party, but you could also use the ST block for in-line ST code and implement a for loop as you normally would. ST Block is super handy if you just need a small amount of in-line structured text code without creating a new POU. Hope this helps!
    
    Last updated: 2025-10-06
    
    
      
        After un upgrade of "CODESYS Control for Raspberry Pi MC SL" from v4.7 to v4.9 SysFileOpen function stopped working
    
    
       CODESYS Forge
    
    
      talk
    
    (Thread)
    
    
      After un upgrade of "CODESYS Control for Raspberry Pi MC SL" from v4.7 to v4.9 SysFileOpen function stopped working
    
    Last updated: 2023-08-22
    
    
      
        Post by sedoerr on Check For Open Dialogs On Client
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      You need to create a function around this function to check the dialogs you use in your program. That's the way i have done it.
    
    Last updated: 2023-09-26
    
    
      
        Post by atone on System Date and Time Function
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      SysTimeRtcConvertUtcToLocal is marked as obsolete, but there's not hint on the actual implementation. Which function should I use instead? Edit: even the new online help is still using SysTimeRtcConvertUtcToLocal as example...
    
    Last updated: 2024-01-05
    
    
      
        Post by smartcoco on Bit / Bool data types in function parameters
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      Memory addressing is measured in bytes, with BOOL occupying one byte. BIT is quite unique as it occupies one bit. So, try not to use BIT in the program. You can use the Unpack function to solve your problem.
    
    Last updated: 2024-01-18
    
    
      
        Post by ragarcia on Error while using UpdateConfiguredIPSettings to change IP address
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      I did check I cannot see any error log. It is when executing the Reconfigure function that I get an error as return from that function.
    
    Last updated: 2024-02-19
    
    
      
        Post by aniket-b on EtherCAT drive not moving
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      I have EtherCAT drive communicating properly without an error but when I use MC_JOG function, it is not moving at all, I can use MC_Power function and drive does respond to that but other functions are not working,. Please suggest what is wrong here.
    
    Last updated: 2024-03-04
    
    
      
        Post by acc00 on Variable Sync Issue In Soft Plc Redundancy
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      Hi arundara, I'm also experimenting with Redundandcy. Is the sync variable function the following: "RedundancySynchronizeData()" ? Does the Task time increase a lot when you activate the sync function?
    
    Last updated: 2024-03-11
    
    
      
        Post by mmpl on CAA Library Function
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      I want to change date and time format. I am using CAA storage library function. I am not receiving any value in to output.
    
    Last updated: 2024-04-16
    
    
      
        Post by derpaul on PFC200 Update to 4.9.0.0 - No Connection
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      Hallo Today I decided to perform an Update on my PFC200 but after the Update the Device was not reachable anymore. I tried reseting to factory reset. Software reset and so on, but nothing helps... In my Router I can see it, I cann SSH into the PFC200 but it is not reachable. Then I try to go back to 4.8.0.0 But now I get this error: [INFORMATION] Befehl SSH auf root@192.168.1.17 ausführen: Laufzeitsystem stoppen [FEHLER] Fehlerausgabe: /etc/init.d/codesyscontrol: line 34: /opt/codesys/scripts/init-functions: No such file or directory [INFORMATION] Standardausgabe: /etc/init.d/codesyscontrol: line 34: /opt/codesys/scripts/init-functions: No such file or directory Please help, I can't get this thing working... Regards
    
    Last updated: 2023-09-27
    
    
      
        Post by derpaul on PFC200 Update to 4.9.0.0 - No Connection
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      Hallo Today I decided to perform an Update on my PFC200 but after the Update the Device was not reachable anymore. I tried reseting to factory reset. Software reset and so on, but nothing helps... In my Router I can see it, I cann SSH into the PFC200 but it is not reachable. Then I try to go back to 4.8.0.0 But now I get this error: [INFORMATION] Befehl SSH auf root@192.168.1.17 ausführen: Laufzeitsystem stoppen [FEHLER] Fehlerausgabe: /etc/init.d/codesyscontrol: line 34: /opt/codesys/scripts/init-functions: No such file or directory [INFORMATION] Standardausgabe: /etc/init.d/codesyscontrol: line 34: /opt/codesys/scripts/init-functions: No such file or directory Please help, I can't get this thing working... Regards
    
    Last updated: 2023-09-27
    
    
      
        Post by askic on Generate FBs from source
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      Hello, I'm coming from Siemens (TIA) world and currently learning Codesys. I'd like to know if there is an option to add external txt file with ST code for creation of a function block and then use this file as a source file from which FB will be generated? For example, in TIA, there is an option add external source file to the project structure and then use option "Generate blocks from source". This would create a FB. Does Codesys have something similar? This external source file would look like this: FUNCTION_BLOCK Scaling VAR_INPUT x, k, n : REAL; END_VAR VAR_OUTPUT y : REAL; END_VAR VAR END_VAR y := k*x+n; END_FUNCTION_BLOCK
    
    Last updated: 2024-07-31
    
    
      
        Post by trusty-squire on parker servo and position
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      @gepert, When you say "I do not turn off power", are you saying you don't power off the drive, or you don't turn of the MC_POWER function block? I read your statement as you don't kill actual electrical power. MC_POWER should stay enabled. @Gustavo, not related to problem at all, but when you say 1.6 Nm is only enough torque to unscrew a loose bottle cap, I think that's a bit low. A quick mental math I use is 1 Nm is almost the same force as 1kG applied to a 10cm wrench. So 1.6kG applied to a 10cm wrench is still not a huge force, but more than enough to be felt if trying to turn the shaft by hand.
    
    Last updated: 2024-08-06
    
    
      
        Post by micik on False Notification Application Error with raspberry pi 4
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      Hello, I have just went through all steps shown on Codesys YT channel https://www.youtube.com/watch?v=RPoPscbo3Kc And it works, I have installed PI OS 32 bit and choose Single Core. However, immediattely when I create standard project with Raspberrz pi device, "Application" is underlined, like there is an error, but in reality there are no errors, and I cannot see what are these 3 messages like shown in attachment. Aside for this red underline, everything seems to work fine. How to correct this? Thank you! Update: I have found what errors are, but not sure how to correct them: Identifier 'IoDrvGPIO' not defined Function block 'IoDrvGPIO' must be instantiated to be accessed 'IoDrvGPIO' is no component of 'IoDrvGPIO'
    
    Last updated: 2024-09-03
    
    
      
        Post by timvh on FB string and naming
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      I see, you want to initialize the FB. To be able to initialise it like you described, you need to add the FB_Init method to your FB. (right click on the FB, select add object --> method). Then press the arrow down, to select the FB_Init (overwrite default implementation). In the VAR_INPUT section of this method, add the variable --> Tag : STRING; Then in the code section of this method add: THIS^.Tag := Tag; // copy initial value to local variable in FB Search Google if you want to know more about FB_Init. PS, reflection + instance path, is also an option if you want to get the full name of the instance (path) of the Function Block. See: https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_pragma_attribute_instance_path.html
    
    Last updated: 2024-09-30
    
    
      
        Post by dsa28 on OPC UA subscriber not operational
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      Hello All, Hopefully I can get some help configuring an OPC UA subscriber in a CODESYS runtime in a Raspberry Pi 5 that tries to retrieve data from an OPC UA publisher (in this case running in a TwinCAT system). I tried to follow the steps described in the page to implement the OPC UA subscriber: https://content.helpme-codesys.com/en/CODESYS%20Examples/_ex_opcua_pubsub.html Seems that the example provided was created with version 3.5.16.0. Now with version 3.5.20.20 is not possible to open the complete project neither convert it. Anyway, after configuring all IPs and ports used in the OPC UA connection function block but the connection state always shows DISABLED. Can someone help me to do the proper configuration of the OPC UA subscriber? Many thanks in advance.
    
    Last updated: 2024-10-22
    
    
      
        Post by george32 on TCP Server
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      Dear people, I would like to create a TCP server in my PLC program. The TCP server needs to communicate with an external device. I have been searching the internet and found that the libraries Syssocket or CAA NetBaseSrv are two possible solutions to create a TCP server. From what I have read, CAA NetBaseSrv is more user-friendly to implement than the Syssocket variant. However, I am still struggling to actually implement this library. Foremost is my little knowledge about creating a TCP server and how to read/understand each function block, especially the outputs of some blocks and the types, e.g. server has an output CAA.Handle, but I cannot find the explanation of CAA.Handle. I tried to find a good document that can help me understand how to implement a TCP server, but I could not find it. Thank you in advance, George
    
    Last updated: 2025-02-20
    
    
      
        Post by manuknecht on Using SMC_MOVTYP.INITPOS without specifying the start position
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      I am using the object SMC_GEOINFO to generate a trajectory and move a system accordingly using the SMC_INTERPOLATOR function block similar to the sample project CNC10_DynamicPath.project. According to the documentation, the movement type INITPOS does not require a start position in the SMC_GEOINFO object, which is confirmed in the documentation of the SMC_GEOINFO object. When using the movement type INITPOS however, the motion will still start from the starting point defined in the SMC_GEOINFO object (0,0,0 if not specified otherwise). Does someone know how to resolve this or is there an example project that makes use of the INITPOS movement type without specifying the starting point? Thanks in advance!
    
    Last updated: 2023-12-15
    
    
      
        Post by esave on Stepper Drive with Ethercat
    
    
       CODESYS Forge
    
    
      talk
    
    (Post)
    
    
      Hello everybody I am new into Codesys. I have a stepper driver (EM3E-556E) from Leadshine. I want to controll the stepper driver via EtherCat to a ST programm but I dont have any function block or anything that i can use. I only have the XML-File wich I loaded. With it I implemented the drive as a Ethercat slave and now I see these variables. (See picture) I dont know how to controll the stepper drive. And the manufacturer doesnt provide support for me. Can anybody help me or atleast tell me how they would do it?
    
    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.