Search talk: init function block

 
<< < 1 .. 18 19 20 21 22 .. 33 > >> (Page 20 of 33)

Post by m83coding on Raspberry Pi Codesys SPI Master CODESYS Forge talk (Post)
Hello, I am trying to control shift registers 74HC596 and 74HC165 via Raspberry PI with SPI interface. So far I did it with a Microcontroller and now I wanna upgrade my Projekt with Raspberry Pi and Codesys Software to be more flexible. I tried to adapt PiFace Function Block to just send or recive a 8 bit via SPI interface of the my Raspberry Pi. With following code (see attached screenshots) * PLC_PRG * PiFaceDigital * PiFaceDigital.write8 * PiFaceDigital.read8 I have a signal at SCK and MOSI pin of the PI, so far so good. But I really struggle with the unterstanding of the code. Is there some detailed description of each line of code? Or is there somebody in the community who can explain each line of code? Or is there a more simple way to send / recive 8 bit via SPI? Manuel
Last updated: 2024-04-23

Post by alexgooi on Init Array input on a method CODESYS Forge talk (Post)
Dear Forum, I would like to initialize an array input on a method. When I do this, I get the following error: "The type of ARRAY [1..2] OF BOOL cannot have a default value in this context." I attached a picture for more clarity. Is this simply not possible or is there a different way of tackling this problem? Thank you in advance
Last updated: 2024-02-26

Post by matteodigani on Error using function block "Write alias address" CODESYS Forge talk (Post)
Hi, I've got a problem using the function block "Write alias address" (ETCStack library 4.9.0.0). this is the code: EtherCAT_1(); IF EtherCAT_1.ConfigRead AND enable THEN CASE seq OF 0: exec := FALSE; T.IN := TRUE; T.PT := T#10S; T(); IF T.Q THEN seq := 1; T.IN := FALSE; END_IF ; 1: T.IN := FALSE; T(); //THIS ONE WORK CORRECTLY! WrAliasAdd.xAbort := FALSE; WrAliasAdd.usiCom := DWORD_TO_USINT(EtherCAT_1.InstanceNumber); WrAliasAdd.wSlaveAddress := 1002; WrAliasAdd.xAutoIncAdr := FALSE; WrAliasAdd.uiAliasAddress := 19; WrAliasAdd.udiTimeOut := 3000; IF start THEN exec := TRUE; ELSE IF NOT error THEN start := TRUE; END_IF END_IF IF WrAliasAdd.xDone THEN start := FALSE; done := TRUE; error := FALSE; exec := FALSE; seq := 5; END_IF IF WrAliasAdd.xError THEN start := FALSE; done := FALSE; error := TRUE; exec := FALSE; END_IF ; 5: exec := FALSE; T.IN := TRUE; T.PT := T#1S; T(); IF T.Q THEN seq := 10; END_IF ; 10: T.IN := FALSE; T(); //THIS ONE GIVES ME AN ERROR! WrAliasAdd.xAbort := FALSE; WrAliasAdd.usiCom := DWORD_TO_USINT(EtherCAT_1.InstanceNumber); WrAliasAdd.wSlaveAddress := 1006; WrAliasAdd.xAutoIncAdr := FALSE; WrAliasAdd.uiAliasAddress := 25; WrAliasAdd.udiTimeOut := 1000; IF start THEN exec := TRUE; ELSE IF NOT error THEN start := TRUE; END_IF END_IF IF WrAliasAdd.xDone THEN start := FALSE; done := TRUE; error := FALSE; exec := FALSE; seq := 99; END_IF IF WrAliasAdd.xError THEN start := FALSE; done := FALSE; error := TRUE; exec := FALSE; END_IF ; ELSE ; END_CASE WrAliasAdd(xExecute := exec); END_IF The first one slave ethercat works correctly, but the other one gives me an error. Attached the ethercat configuration of the devices. All the devices are set "Optional". So my idea is to enable only the first one (1002) and the fifth one (1006).
Last updated: 2025-10-01

Post by sturmghost on Initialization of visualization variables and cyclic code execution CODESYS Forge talk (Post)
I'm looking for a smart and short way to implement initialization of visualization variables depending on the visualization input. For an easy example consider a rectangle which rests at XPos := 0 when the input state is false and at XPos := 50 when the input state is true. My visualization variables look like this: VAR_IN_OUT State : BOOL; END_VAR VAR XPos : INT; END_VAR I put this rectangle via a visualization frame element into another visualization and link a frame reference variable with the state to it. If the variable is true, the rectangle should rest at XPos := 50 and false at XPos := 0 at visualization init but how should I assign the 50 or 0 to the internal visualization variable XPos? I would need some init-methode for the visualization but I dont want a global init-method for such tasks. I want to do it inside of the visualization element but I can't see any solution for this? It would be good to be able to define ST-code within the visualization element which runs cyclic at each VISU_TASK task-cycle then I could just check the input state and change the XPos accordingly. Does someone have a solution?
Last updated: 2023-10-01

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 xcqt on Oop best practice CODESYS Forge talk (Post)
Hi all, I’m currently trying to improve my OOP structure in CODESYS and I’m looking for some input on how others approach this. I understand the basics like inheritance, interfaces, abstract FBs, methods, and properties, but I still struggle a bit with the overall architecture and what’s considered clean or scalable in bigger projects. As an example, I’m working on two different energy meter function blocks: FB_EnergyMeter_MQTT reads data from MQTT (strings) FB_EnergyMeter_Modbus reads data from Modbus (words) Both have their own Update() method and implement the same interface (something like IF_EnergyMeter). Later on, I’ll probably add more meter types, but they should all behave the same from the controller’s point of view. Now, there’s a FB_GridControl block that needs power data from these meters. I see two options here: Define the meter blocks inside FB_GridControl and call them directly (for example fbModbusMeter.UpdateModbus()). Keep the meter blocks outside and pass them into FB_GridControl as interface references, so the control block doesn’t know which specific type of meter it’s dealing with. Option 2 feels cleaner and more flexible to me, but I’m not entirely sure how to handle the data flow in that case. Should I pass the meter instance through an interface reference (REFERENCE TO IF_EnergyMeter)? Or is there a better way to link the external FBs to the control block? I’d like to hear how you structure this kind of setup or see an example from someone who has done something similar. EDIT: I think i need to do something like this fbModbusUpdateInput(wInput:= wWordValue); fbMqttUpdateInput(strInput:= strStringValue); IF bUseMqtt THEN Meter REF = fbMqttUpdateInput; ELSE Meter REF = fbModbusUpdateInput; END_IF fbControl.SetMeter(UsedMeter := Meter); Or am i thinking wrong? Thanks, Thomas
Last updated: 2025-10-16

Post by jbu0105 on Dynamic limits invaild CODESYS Forge talk (Post)
Hello, For my delta robot i wil use the MC_MoveCirvularAbslolute function. Every time that i set the execute of this function has my Axis group a error. Thats is: The dynamic limits for the movement are invalid. What can i do that this error go away? I saw a view funcitons with limit dymanics but i don't now how they work. If i use the function MC_MoveLinearAbsolute than i have no error. Does anyone know how i fix this?
Last updated: 2025-04-04

Post by jbu0105 on Dynamic limits invaild CODESYS Forge talk (Post)
Hello, For my delta robot i wil use the MC_MoveCirvularAbslolute function. Every time that i set the execute of this function has my Axis group a error. Thats is: The dynamic limits for the movement are invalid. What can i do that this error go away? I saw a view funcitons with limit dymanics but i don't now how they work. If i use the function MC_MoveLinearAbsolute than i have no error. Does anyone know how i fix this?
Last updated: 2025-04-04

Post by apurv on Cannot pass array of constant size to a function as a reference CODESYS Forge talk (Post)
I have a Array of constant size defined like this Var Constant MAX_SIZE :UINT := 10; End_var VAR array : ARRAY[0..MAX_SIZE] OF INT; END_VAR Now I want to pass this array to a function by reference, Function fun : INT VAR_IN_OUT CONSTANT MAX_SIZE : UINT; END_VAR VAR_INPUT array : REFERENCE TO ARRAY[0..MAX_SIZE] OF INT; END_VAR but when I run this it gives strange Errors Error : Cannot Convert type 'ARRAY [0..MAX_SIZE] OF INT' to type 'ARRAY[0..MAX_SIZE] OF INT'
Last updated: 2024-01-07

Post by sturmghost on Visualization using methods and cyclic ST-calls CODESYS Forge talk (Post)
I found a way to do it: You can use, for example, the text variable property of any visualization element and call a function in it. Example: Write a test POU as a function (FUN), like MyTestFun which need a boolean Variable as an input value. Now write into the text variable property: MyTestFun(bBooleanValue) Thats it. The function is called at each visu_task cycle.
Last updated: 2024-01-22

Post by micik on CAA File, how to check whether file exists or not CODESYS Forge talk (Post)
Hello, what would be the most efficient way to check whether the file exists or not. I don't want to use file.Open function, it seems like rather inefficiet operaton. I considered GetAttribute function, but this function doesn't accept filename (with path) as an input. Basically I need to check first time when program is loaded to the runtime i.e. when application is started for the first time, whether a file exists on the specific location or not.
Last updated: 2024-05-16

Post by shaunvdm on OSCAT Scale_r function not working in LD 4.60 works in LAD2 on 3.5.21sp3 CODESYS Forge talk (Post)
Hi We have picked up an issue OSCAT_BASIC.Scale_r function call not working in the old lad and FBD version 4.60. Gives no output on the function call. When we convert this to LAD2 it works. As can be see by the two screenshot in normal LD not working in LAD2 it works. Please confirm if this is an issue with Oscat or with LAD in 3.5.21sp3, is there an workaround. Regards Shaun
Last updated: 2025-10-23

Post by shaunvdm on OSCAT Scale_r function not working in LD 4.60 works in LAD2 on 3.5.21sp3 CODESYS Forge talk (Post)
Hi We have picked up an issue OSCAT_BASIC.Scale_r function call not working in the old lad and FBD version 4.60. Gives no output on the function call. When we convert this to LAD2 it works. As can be see by the two screenshot in normal LD not working in LAD2 it works. Please confirm if this is an issue with Oscat or with LAD in 3.5.21sp3, is there an workaround. Regards Shaun
Last updated: 2025-10-23

Post by kishan on OSCAT Scale_r function not working in LD 4.60 works in LAD2 on 3.5.21sp3 CODESYS Forge talk (Post)
here is formula for scale function you can impliment your own scale function Output=OutMin+(Input−InMin)×(InMax−InMin)(OutMax−OutMin) FUNCTION_BLOCK FB_Scale VAR_INPUT xIn : REAL; // Input value (e.g., raw sensor) xInMin : REAL; // Input range minimum xInMax : REAL; // Input range maximum xOutMin : REAL; // Output range minimum xOutMax : REAL; // Output range maximum END_VAR VAR_OUTPUT xOut : REAL; // Scaled output END_VAR VAR xGain : REAL; xOffset : REAL; END_VAR // Implementation xGain := (xOutMax - xOutMin) / (xInMax - xInMin); xOffset := xOutMin - xGain * xInMin; xOut := xGain * xIn + xOffset;
Last updated: 5 days ago

Post by hyys12 on Help understanding analog in-/outputs CODESYS Forge talk (Post)
Hello. I am currently working on a WAGO PLC, where I am trying to wrap my head around how the analog inputs and outputs work in codesys. I have looked far and wide on the internet, for a general introduction to the whole concept, but I have not had any luck with finding anything that helped me understand it better. The whole goal is for me to be able to read an analog input from a temperature sensor, as well as using an analog output, to control a frequency inverter. I know these have nothing to do with each other, but that is all I have on hand right now. I am trying to program this using Ladder Diagram. The only thing is, that every video/guide I have seen/read using LD, just adds a whole lot of function blocks, to do all kinds of stuff they don't explain. My general question is, how would one go ahead and read the analog input, as well as transmit an analog output? Is there some kind of specific function block I would have to use for this, or some great video I can watch, to understand the inner workings. Is it somehow possible to see the values the PLC recieved/sends? Regards.
Last updated: 2024-12-11

Post by leafy on Use third party actuator with IO-Link Master (IFM) CODESYS Forge talk (Post)
Hey there! I am currently doing a little automation project for uni. I am trying to integrate a control-valve-system (Buerkert AirLINE Field) in my IO-Link environment. With IFM sensors, I used their pre-built function blocks, but with this third-party device, i need to write my own function block. Thankfully, IFM provides a generic sensor-fb so I can write my own FB with "extends" and "super". So far, so good. I found the IODD and some other documentation and I thought I get how it works, but somehow can't really get it to work at all. From my understanding, i need to write data into the PDO-Array. But i get confused with the indices and subindices of IO-Link. I'll append the IODD and some screenshots of my project. There is an AOI for LogicXDesigner, but I can't use that in Codesys. I hope someone has integrated a IOL-device in Codesys before and can help me with this. Cheers leafy
Last updated: 2024-04-16

Post by leafy on Use third party actuator with IO-Link Master (IFM) CODESYS Forge talk (Post)
Hey there! I am currently doing a little automation project for uni. I am trying to integrate a control-valve-system (Buerkert AirLINE Field) in my IO-Link environment. With IFM sensors, I used their pre-built function blocks, but with this third-party device, i need to write my own function block. Thankfully, IFM provides a generic sensor-fb so I can write my own FB with "extends" and "super". So far, so good. I found the IODD and some other documentation and I thought I get how it works, but somehow can't really get it to work at all. From my understanding, i need to write data into the PDO-Array. But i get confused with the indices and subindices of IO-Link. I'll append the IODD and some screenshots of my project. There is an AOI for LogicXDesigner, but I can't use that in Codesys. I hope someone has integrated a IOL-device in Codesys before and can help me with this. Cheers leafy
Last updated: 2024-04-16

Post by i-campbell on Ping By Name CODESYS Forge talk (Post)
https://content.helpme-codesys.com/en/libs/Net%20Base%20Services/3.5.19.20/NetBaseServices/Function-Blocks/IP/fld-IP.html resolve hostname and ping?
Last updated: 2023-08-24

Post by smartcoco on Visualization using methods and cyclic ST-calls CODESYS Forge talk (Post)
I think what you want is a declaration period function for the page, but unfortunately CODESYS does not have it.
Last updated: 2023-10-17

Post by jerry-sorrells on Find Function: Object reference not set to an instance of an object. CODESYS Forge talk (Post)
Build: CODESYS 3.5 SP19 Patch 1 (64-bit) Host OS: Windows 10 Target: Linux SL I have a project with programs in Structured Text and Ladder Diagram. When I try to use the Find function, it works for the Active Editor; however, when I try to use Find for the Entire Project, I get the error "Object reference not set to the instance of an object." I know what this error means in the context of the program, but I have no idea why the find function is returning this error. The variable I am searching does not matter: it happens with all variables. Any help with this will be greatly appreciated. I generally use the Find function quite often as I am developing and not having it is really slowing me down.
Last updated: 2023-10-23

Post by tk096 on Axis_Ref_SM3.perfTimers CODESYS Forge talk (Post)
Hi, these variables are internal members of the axis. They measure the duration of some internal function calls.
Last updated: 2023-11-23

Post by eguerra on Error in ScriptingEngine Docs - create_pou() CODESYS Forge talk (Post)
In the ScriptingEngine documentation there seems to be an error (or missing information) in the ScriptIecLanguageObjectContainer part ( https://content.helpme-codesys.com/en/ScriptingEngine/ScriptIecLanguageObjectContainer.html#ScriptIecLanguageObjectContainer.ScriptIecLanguageObjectContainer ). The description of the function create_pou() doesn't specify the correct arguments requested, it only says create_pou(type: SpecialPouType) and a script using the documentation definition of the function will raise an error. I tried passing the function arguments similar to the ones specified for the create_dut() function and it seems to work fine: create_pou(name, PouType) , name : str UPDATE: The offline help has the correct definition IExtendedObject<IScriptObject> create_pou( string name, PouType type = PouType.FunctionBlock, Nullable<Guid> language = null, string return_type = null, string base_type = null, string interfaces = null )
Last updated: 2024-08-05

Post by opineiro on Stack overflow with really simple function CODESYS Forge talk (Post)
Thanks, I'm going to rework everything with this in mind.
Last updated: 2024-09-23

Post by mubeta on Strange problem with the ‘MC_SetPosition’ function CODESYS Forge talk (Post)
Here is the archive of the simulation project: https://drive.google.com/file/d/1n74Qy-1yLPpI2OK4FaZO5q50y2uTa0Wr/view?usp=drive_link
Last updated: 2025-01-12

Post by eschwellinger on Creating, using an external Function. CODESYS Forge talk (Post)
you need the check the plclog if the the component have been loaded on startup of th plc.
Last updated: 2025-04-19

<< < 1 .. 18 19 20 21 22 .. 33 > >> (Page 20 of 33)

Showing results of 814

Sort by relevance or date