Post by macros8 on Translation - How to get text as reference in Frames translated?
CODESYS Forge
talk
(Post)
Hi, one more point. I have been able to create Property of Text which is added to Global text list so itΒ΄s fine. But as soon as I use Frame configuration I lose all other properties but some very basics. I need to have still possibility to set Input configuration because my element is Button. Do you know how to make visible all standard properties + my own properties created in Frame configuration? Thanks a lot. M.
Last updated: 2024-01-03
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 sturmghost on Find visualization elements that require a lot of computing time
CODESYS Forge
talk
(Post)
I found out that the Codesys simulation mode is not good to measure performance. As soon as I upload the code onto the hardware PLC I can see that my visu-task needs around 60 ms to complete. I'm wondering if there is a possibility to find out which visualization/visualization element takes a lot of computing time? Then I would look for ways to decrease the long computing time.
Last updated: 2024-01-22
Post by tvm on VisuFbFrameBase.SetInputPositionData: The element id for the input position cannot be determined
CODESYS Forge
talk
(Post)
I'm getting this error on one of my projects. Searching for it I came across this https://www.codesys.com/fileadmin/data/Images/System/Releaseinformation/Patch-Note-CODESYS-Visualization-4300.html which says it was a bug VIS-1394, fixed in Visualization 4.3.0.0. I'm using a previous visu version, what is the cause of this error, and what can be done to work around it?
Last updated: 2024-02-08
Post by arcadium on TargetVisu element stacking on top of each other
CODESYS Forge
talk
(Post)
Hello, I'm new here so if I do something wrong please bare with me. I am using raspberry pi touchscreen made by comfile (CPi-C070WR4C). I also have a window 11 pc where I would like to have a second visualisation, but when I run a TargetVisu with it, all elements of the visualisation end up in the top left corner stacked on top of each other. I have same results running targetVisu on my laptop. Maybe someone had same issues and know the solution? Simas
Last updated: 2024-06-17
Post by balazska2 on Position values with integer variables
CODESYS Forge
talk
(Post)
Hello guys! https://content.helpme-codesys.com/en/CODESYS%20Visualization/_visu_elem_label.html My question: Could I give an integer variable to the Position records (in the Element list => Position => width / height)? If yes, how? I defined a TEST integer variable with 300 value. I tried to add this variable to the width record (.TEST or only TEST), but if I saved, the value jumps back to 0. Thanks for your help! :)
Last updated: 2024-10-03
Post by durallymax on Access Variable Visu Dialog
CODESYS Forge
talk
(Post)
Is there a way to access the variable in the called dialog? Example: Text Field element with PLC_PRG.myVar as Text variable. OnMouseClick configured to write variable with keypad pop-up. OnValueChanged configured to Execute ST RND(PLC_PRG.myVar,2); Rather than change myVar with each copy of this Text Field, is there a way to access whatever the configured text variable is? Generally try to stay away from ST in visu, but was curious regardless.
Last updated: 1 day ago
Post by john-robinson on Limiting Memory Access of an Array to Within its Bounds
CODESYS Forge
talk
(Post)
Recently we had an issue regarding some simple code to calculate a rolling average. The code indexes from zero to 199 to properly store the current input into a circular buffer which then allows us to calculate a rolling average: VAR input_5s : REAL; outs_arr : ARRAY[0..199] OF REAL; i : USINT := 0; END_VAR ___ //this code runs every five seconds, calculating a rolling average outs_arr[i] := input_5s; i := i + 1; output := OSCAT_BASIC.ARRAY_AVG(ADR(outs_arr), SIZEOF(outs_arr)); IF i >= SIZEOF(outs_arr) THEN i := 0; END_IF There is a simple bug in this code where the index will be set to 0 when it has surpassed the length of the array in bytes (800 in this case) rather than larger than the number of reals in the array (200). The solution here is simple, replacing i >= SIZEOF(outs_arr) with i >= SIZEOF(outs_arr)/SIZEOF(outs_arr[0]). In this example when the index increased to 201 and the line outs_arr[201] := input_5s was called, codesys arbitrarily wrote to the address in memory that is where outs_arr[201] would be if the array was that long. I would like to find a way to wrap the codesys array inside of a wrapper class that checks if an input is within the bounds of an array before writing to that value. I know how I would implement that for a specific array, I could create a method or class that takes an input of an array of variable length, ie. ARRAY[*] OF REAL, but I don't know how to make this for any data type. I am wondering if anyone has ever done anything similar to this, or has any better suggestions to ensure that none of the programmers on this application accidentally create code that can arbitrarily write to other locations in memory.
Last updated: 2024-03-05
Post by hoatran on Use third party actuator with IO-Link Master (IFM)
CODESYS Forge
talk
(Post)
The generic sensor FB is for controlling the sensor via its cyclic input (PDI) and output (PDO). In this case, ifm raw cyclic input and output data are WORDs (16 bits total) The PDO data from the Buerkert unit are SINT (8 bits) In this case, I would use the unpackword fb from the CAA memory library to unpack the valve feed back value into the appropriate location.
Last updated: 2024-04-23
Post by mubeta on STRUCT AT %MW1000
CODESYS Forge
talk
(Post)
This is normal and correct since in CoDeSys static addressing of variables uses the IEC method. A LONG tag has the size of 8 bytes, so %ML0 coincides with %MB0 ... %MB7; %ML1000 with %MB8000 ... %MB8007. (Similar reason for word and other formats). Also the reason the compiler won't let you map the structure to a %MW depends on the fact that the individual base elements are manipulated to 64 bits regardless of the smaller size. That said, it makes me strange that you cannot write a parser without making use of static memory allocation.
Last updated: 2024-08-13
Post by mxj262 on FB having single input but initialized with Array
CODESYS Forge
talk
(Post)
I am adding elements of an ARRAY using pointer to access each element inside a FOR loop and the FOR loop does not stop! What is the right way to use pointers in such case?? I have another loop that is not using pointer and it stops but the loop using pointer keep on adding. METHOD FB_Init: BOOL VAR_INPUT bInitRetains: BOOL; // TRUE: the retain variables are initialized (reset warm / reset cold) bInCopyCode: BOOL; // TRUE: the instance will be copied to the copy code afterward (online change) END_VAR VAR_IN_OUT // basically REFERENCE TO window_buffer: ARRAY [*] OF INT; // array of any size END_VAR THIS^.windowPtr := ADR(window_buffer[0]); THIS^.windowSize := UPPER_BOUND(window_buffer, 1) - LOWER_BOUND(window_buffer, 1) + 1; FUNCTION_BLOCK FB500 VAR_INPUT END_VAR VAR_OUTPUT END_VAR VAR windowPtr: POINTER TO INT; windowSize: DINT; currentIndex: UINT; element1:INT; element2:INT; i:INT; j:INT; sum:DINT:=0; END_VAR element1:=windowPtr[0]; // read the first element of the Array dynamic memorry element2:=windowPtr[1]; FOR i:=0 TO (TO_INT(windowSize-1)) BY 1 DO // this loop does not stop Sum:=sum + windowPtr[i]; END_FOR FOR j:=0 TO 5 BY 1 DO // this loop stops j:=j+1; END_FOR https://ibb.co/k3DhkZT
Last updated: 2024-05-06
Post by caprez95 on Trace Restart Visuelement
CODESYS Forge
talk
(Post)
Hello everyone. I've been struggling with the problem for a long time that I can't reset (restart) a trend (visual element). With the example I have now managed to control the trace recording via the CmpTraceMgr library. But how do I get this trace recording into a visual element? The code looks like this: // Configure trace IF xInit THEN // Create a trace packet PacketConfig.pszName := ADR('IECTraceConfiguration.Trace1'); // Name of trace PacketConfig.pszApplicationName := ADR('IECTraceConfiguration'); // Name of the application PacketConfig.pszIecTaskName := ADR('Task'); // Name of the task PacketConfig.pszComment := ADR('Demo packet'); PacketConfig.ulEveryNCycles := 1; PacketConfig.ulBufferEntries := 1000; PacketConfig.ulFlags := TRACE_PACKET_FLAGS.TRACE_PACKET_FLAGS_TIMESTAMP_MS AND TRACE_PACKET_FLAGS.TRACE_PACKET_FLAGS_AUTOSTART; IF (NOT fbTraceManager.CreatePacket(PacketConfig := PacketConfig, hPacket=>hPacket1)) THEN xError := TRUE; END_IF // Create a trace record RecordConfig.pszVariable := ADR('iSignal'); // This is the name of variable to record RecordConfig.tcClass := INT_TO_UDINT(TypeClass.TYPE_INT); // Type of the recording variable RecordConfig.ulSize := SIZEOF(iSignal); // Size of the recording variable pApp := AppFindApplicationByName('IECTraceConfiguration', 0); AppGetAreaOffsetByAddress(pApp, ADR(iSignal), ADR(RecordConfig.tvaAddress.taAddress.Area.usArea), ADR(RecordConfig.tvaAddress.taAddress.Area.ulOffset)); // Get and set area offsets RecordConfig.tvaAddress.ulAddressFlags := TRACE_VAR_ADDRESS_FLAGS_IEC OR TRACE_VAR_ADDRESS_FLAGS_AREA_OFFSET; RecordConfig.ulGraphColor := 16#FF00FF00; // green RecordConfig.ulGraphType := 1; // Line with points IF (NOT fbTraceManager.AddRecord(RecordConfig := RecordConfig, hPacket := hPacket1, hRecord => hRecord1)) THEN xError := TRUE; END_IF xInit := FALSE; END_IF // Starts the recording IF xStart THEN IF (NOT fbTraceManager.StartPacket(hPacket := hPacket1)) THEN xError := TRUE; END_IF xStart := FALSE; END_IF // Stop the recording IF xStop THEN IF (NOT fbTraceManager.StopPacket(hPacket := hPacket1)) THEN xError := TRUE; END_IF xStop := FALSE; END_IF // Reset the recording IF xReset THEN IF (NOT fbTraceManager.ResetPacket(hPacket := hPacket1)) THEN xError := TRUE; END_IF xReset := FALSE; END_IF
Last updated: 2024-06-04
Post by alexgooi on Modbus writing on value change
CODESYS Forge
talk
(Post)
Hi Duvan, You could make this in 1 single object (FB), Indeed don't use a function for this beacuse you need some memory to keep the old value. For i := 0 TO 200 BY 1 DO //Check if the value has been changed IF Old_Value[i] <> Value[i] THEN //Set the trigger to TRUE Trigger[i] := TRUE; Old_Value[i] := Value[i]; END_IF END_FOR If you define the Value array as an In_Out and the Trigger as an In_Out you arn't claiming any aditional memory to your system. You ofcourse then need to add some code arround it that does something with the trigger and writes it back to FALSE again. If you want more flexability you also could use pointers instead of using the IN_OUT FOR i := 0 TO 200 BY 1 DO address := address_Input + i * SIZEOF(*Put type here); IF Address^ <> Old_Value[i] THEN Trigger[i] := TRUE; Old_Value[i] := Address^; END_IF END_FOR
Last updated: 2024-04-02
Post by janderson on OPC UA Server limitations, large array crashes runtime
CODESYS Forge
talk
(Post)
What are the limitations of the OPC UA Server? I am trying to get data off my PLC that is acquired at high rates (~50k samples/s) so I am storing them in arrays and trying to get the arrays off the PLC. When I attempt to read a ~200k element array through OPC UA the server and runtime crashes (requiring tools -> update linux arm64 -> start runtime). Is there a better way to get highspeed data off? The ACDatalog library seems a bit irritating to use so I would prefer to go through OPC UA.
Last updated: 2023-08-23
Post by dkugler on Management of a PLC network from a remote station
CODESYS Forge
talk
(Post)
I would figure out, how to create a simple html webpage with 2 frames. One frame with buttons to select the plc. A second frame with hyperlink to the webvisu of the plc ("XXX.XXX.XXX.XXX:8080/webvisu.htm"). Selecting other PLC Button has to change the hyperlink in 2. frame. Costs only some time to figure out :-) Or setup a raspberry Pi with small visualization. Set up a button for each plc and add one browser element. Each button writes the URL of the depending plc to the URL setting of the browserelement. Costs 55β¬ for runtime licence and a Raspberry Pi.
Last updated: 2023-12-04
Post by dkugler on Toggling Visualizations using HMI Physical Buttons
CODESYS Forge
talk
(Post)
the magic option is named "Use CurrentVisu variable" activate this option in the Visualization Manager an have a look: https://help.codesys.com/webapp/_visu_obj_manager;product=core_visualization;version=3.5.14.0 if your button is pressed, "feed" the string varable VisuElems.CurrentVisu := 'visu1'; with the correct name of the depending visu. alternative: place a frame element at a empty main visu, konfigure all visus to be shown by this frame. With setting the switching variable of the frame to the index value of the depending visu, it will switch to it. Advantage: the visu names are not hardcoded as string in the ladder lodgic. Good luck! Hint: If you have multiple VisuClients(Target, WebVisu,...) all will show the same visu. Independent switching is much more difficult, but there is a example from codesys.
Last updated: 2024-02-13
Post by phoward131 on Text List Fallback Value
CODESYS Forge
talk
(Post)
I am relatively new to Codesys and I'm trying to develop an HMI that displays what mode a particular device is in based on an integer value. I am currently using dynamic texts with a text list which works fine but I am looking for a way to display a particular string (ie 'Unknown') when the index doesn't match any of of the indices in the text list. I can enter 'Unknown' in the text property of the text field element which works as expected but it displays the single quotes on the visualization. How can I escape these quotes to simply display the word Unknown? Thanks!
Last updated: 2024-03-22
Post by david24 on Map in Codesys
CODESYS Forge
talk
(Post)
Hello everyone, I have the task of programming a map. With the help of the visualization element "Table", I have managed to accomplish this. In the Input Configuration, I activated the option: "Write Variables", so that the user can change the values in the map. To test the program, I select the Online Mode (Simulation).There I change the values in the map. When restarting the program in CODESYS, the changes in the map are no longer there. Does anyone know an approach how to save the changes in the map? Thank you for your support Best regards David
Last updated: 2024-04-02
Post by jari-koivuluoma on Newly created texlists wont appear in the selection dropdown
CODESYS Forge
talk
(Post)
When I create a new textlist in Codesys 3.5 SP19 Patch 5, it wont appear in the dropdown menu at Rectangle element > Dynamic texts > Text list. If I just type the name of the textlist to the field (in quotes), I get an error saying that some file is missing. Any good ideas what to do and what is going on. I recently updated to that version and I only now noticed this when I needed to add a new textlist so Im quite screwed with this not being able to add text lists. While im typing this, I tried copying an existing list and modifying it and it seems to show. Any ideas?
Last updated: 2024-09-19
Post by gustavocsw on MQTT memory leak problem
CODESYS Forge
talk
(Post)
Hello everyone, I'm using the IoT Library to implement the MQTT communication with my local broker server in order to publish and subscribe at specifics topics to share and consume information about my application. But, it seems that are occurring some memory leak problem in a "high" frequency (more than 10 Hz) subscribe process. I follow the same method as in IoT Lib exemples, and at first looks perfect but my PLC was rebooting frequently and when I check its memory usage that was increasing as fast as the subscribe massage was sent. I'm using a WEG PLC410 and a WEG PLC500, and this error occurred in both of them (including in CODESYS Control Win x64). The application sends to the system a message JSON with the float payload Ex. {"data" : 0.8500}, but this happens with a INT, or BOL as well. I use the follow code in my application to find the value: //FindFirstValueByKey VARs PROGRAM JSON_VELO VAR //------Setting the JSON Subscriber to Set the Relay Value jsonDataVelo : JSON.JSONData; jsonByteArrayReaderVelo : JSON.JSONByteArrayReader; xST1okVelo : BOOL; FindFirstValueByKeyVelo : JSON.FindFirstValueByKey; jsonElementVelo : JSON.JSONElement; xDoneReaderVelo : BOOL; xDoneFindVelo : BOOL; //STRING and WSTRING for Subscribe the massage sPayloadJsonVelo : STRING := 'opa'; psPayloadJsonVelo : POINTER TO BYTE := ADR(sPayloadJsonVelo); //wsPayloadJsonRelaySet : WSTRING := "opa"; wsPayloadJsonVelo : WSTRING := STRING_TO_WSTRING('opa'); pwsPayloadJsonVelo : POINTER TO WORD := ADR(wsPayloadJsonVelo); lrVelo : LREAL; xKeepAliveVelo : BOOL; xSetVelo : BOOL; RSSet : RS; LIMPAR : STRING; //Find the msg end sFindVelo : STRING := '}'; psFindVelo : POINTER TO STRING := ADR(sFindVelo); iLenVelo : INT; iSizeVelo : INT := 12; udiContMsg : UDINT; END_VAR // FindFirstValueByKey CODE // Relay Set configuration xSetVelo := MQTT_SUBSCRIBER.RSVelo.Q1; IF xSetVelo THEN xKeepAliveVelo := TRUE; END_IF IF xKeepAliveVelo THEN udiContMsg := udiContMsg + 1; iLenVelo := TO_INT(StrLenA(psPayloadJsonVelo)); iSizeVelo := iLenVelo - TO_INT(MQTT_SUBSCRIBER.udiPayloadSizeVelo); StrDeleteA(psPayloadJsonVelo,iSizeVelo,iLenVelo); wsPayloadJsonVelo := STRING_TO_WSTRING(sPayloadJsonVelo); pwsPayloadJsonVelo := ADR(wsPayloadJsonVelo); //MQTT.ConvertUTF8toUTF16(sourceStart:= ADR(sPayloadJsonVelo), targetStart:= ADR(wsPayloadJsonVelo), dwTargetBufferSize:= TAM, bStrictConversion:= 1); //Reset jsonByteArrayReader jsonByteArrayReaderVelo ( xExecute := TRUE, pwData := pwsPayloadJsonVelo, jsonData := jsonDataVelo, xDone => xDoneReaderVelo ); FindFirstValueByKeyVelo( xExecute := xDoneReaderVelo, wsKey := "data", diStartIndex:= 0, jsonData := jsonDataVelo, jsonElement => jsonElementVelo, xDone => xDoneFindVelo ); IF xDoneFindVelo THEN lrVelo := jsonElementVelo.value.lrValue; //Reset jsonByteArrayReader jsonByteArrayReaderVelo ( xExecute := FALSE, pwData := pwsPayloadJsonVelo, jsonData := jsonDataVelo, xDone => xDoneReaderVelo ); FindFirstValueByKeyVelo( xExecute := FALSE, wsKey := "data", diStartIndex:= 1, jsonData := jsonDataVelo, jsonElement => jsonElementVelo, xDone => xDoneFindVelo ); xKeepAliveVelo := FALSE; GVL.xSetVeloRead := TRUE; END_IF END_IF And this to subscribe at the topic: //SUBSCRIBE VAR: //----------------- Subscribe Velocity ----------------------- MQTTSubscribeVelo : MQTT.MQTTSubscribe;//Variable MQTTSubscriber block -X - function-X wsTopicSubscribeVelo : WSTRING(1024) := "CORE/odometry/GET/data/simp"; // Topic to publish a message sSubscribeMassageVelo : STRING; udiPayloadSizeVelo : UDINT; xSDoneVelo : BOOL; xSErrorVelo : BOOL; xReceiveVelo : BOOL; eSTypeVelo : MQTT.MQTT_ERROR; eSMQTTErrorVelo : MQTT.MQTT_ERROR; RSVelo : RS; udiCont : UDINT; //SUBSCRIBE CODE: MQTTSubscribeVelo( xEnable:= MQTT_CLIENT.xConnection_Broker AND NOT xSErrorVelo AND NOT JSON_VELO.xKeepAliveVelo, pbPayload:= JSON_VELO.psPayloadJsonVelo, udiMaxPayloadSize:= SIZEOF(JSON_VELO.sPayloadJsonVelo), udiPayloadSize => udiPayloadSizeVelo, mqttClient:= MQTT_CLIENT.ClientMQTT, wsTopicFilter:=wsTopicSubscribeVelo, xDone => xSDoneVelo, xError=> xSErrorVelo, xReceived => xReceiveVelo, eMQTTError=> eSMQTTErrorVelo ); RSVelo(SET := xReceiveVelo, RESET1 := JSON_VELO.xKeepAliveVelo);
Last updated: 2024-09-09
Post by ewi04 on Recipe Manager - RecipeManCommands, load & write wrong values, Bug?
CODESYS Forge
talk
(Post)
Hallo, I have a strange problem with the recipe manager. ISSUE: When using RecipeManCommands not all values are loaded correctly. Saving a recipe with CreateRecipe(), ReadAndSaveRecipe() or ReadAndSaveRecipeAs() works without any problems. BUT: LoadRecipe(), WriteRecipe() or LoadFromAndWriteRecipe() do not load the data correctly. It is Interesting that we have a different error pattern with LoadRecipe() than with WriteRecipe() or LoadFromAndWriteRecipe(). LoadRecipe() does not load all data and WriteRecipe() or LoadFromAndWriteRecipe() overwrites some data or assigns it incorrectly. And it is also strange that LoadRecipe() writes the values to the PLC. Normally it doesnβt do it. It makes no difference whether the memory type is textual or binary. I have an object consisting of STRUCTs which is inserted in the recipe definition. Environment: Codesys V3.5 SP19 Patch 4 (64Bit), Recipe Management 4.2.0.0 *Add a project (reduced to the problem)
Last updated: 2023-11-15
Post by comingback4u on Memory Address Overlap
CODESYS Forge
talk
(Post)
Hello, We use a controller that comes with a bunch of predefined faults. These faults are considered active and historic. They are a 32 byte array but only take up 26 bytes of data. Because of this the historic faults start at address 26 instead of 31. Active faults variable take up address location 0 to 31. Historic faults variable take up address location 26 to 57. Because of this overlap I get an error that these overlap and it wont allow me to download to my controller. This isn't an issue in 3.5.5.4 but becomes an issue in newer version. Is there a way to turn this off? If I change the address location, the historic faults then become broken without doing some manipulation in the code. The software will build just fine. Thank you for your time.
Last updated: 2024-03-07
Post by r-niedermayer on Issue with WebVisu on Raspberry PI
CODESYS Forge
talk
(Post)
Regarding to your application: When clicking in the web visualization, the boolean variable will be tapped for both buttons. The LED in the web visualization lights up as long as the variable is true The used variables should come from the GVL, ad/or thePLC_Prg. We see no difference or problem in both projects: You have created a visuelement Push button a a tapper, that is supposed to control the variable in this way as expected. This is also reflected (switching Bool from false to true) in the program code, as well as in the (GVL declared) variables. Wherever the misunderstanding comes from: no, this is not memory or license related. Our best guess: it is probably more of an applicative/conceptual implementation.
Last updated: 2024-04-11
Post by micik on Reverse bytes in an array
CODESYS Forge
talk
(Post)
Hello, I'm getting the data in Codesys that is an array of 8 bytes. From this array, I need to foram LREAL number, however, because of different endiannes I need to reverse bytes in this array and then copy to a LREAL variable. For this I'm using a loop and it works OK. I wonder if there is a built in function to do this. I have found CAA Memory library but it has functions like reverse bytes in DWORD. But it seems it doesn't have what I need. https://content.helpme-codesys.com/en/libs/CAA%20Memory/Current/CAA_Memory/Reverse-Bit-Swap-ByteWord-order/ReverseBYTEsInDWORD.html What I need is a function to reverse bytes in an 8 byte array, or something similar.
Last updated: 2024-08-22
Post by micik on Reverse bytes in an array
CODESYS Forge
talk
(Post)
Hello, I'm getting the data in Codesys that is an array of 8 bytes. From this array, I need to foram LREAL number, however, because of different endiannes I need to reverse bytes in this array and then copy to a LREAL variable. For this I'm using a loop and it works OK. I wonder if there is a built in function to do this. I have found CAA Memory library but it has functions like reverse bytes in DWORD. But it seems it doesn't have what I need. https://content.helpme-codesys.com/en/libs/CAA%20Memory/Current/CAA_Memory/Reverse-Bit-Swap-ByteWord-order/ReverseBYTEsInDWORD.html What I need is a function to reverse bytes in an 8 byte array, or something similar.
Last updated: 2024-08-22
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
.