Search talk: code compile

 
<< < 1 .. 51 52 53 54 > >> (Page 53 of 54)

Post by alex00 on DCS / Central Engineering with Codesys support CODESYS Forge talk (Post)
Hello together I'm currently investing in possibilities to have a central engineering software / system for Codesys based controllers. Something like a DCS / SCADA depending on where you see the functionality. We plan to use more or less vanilla codesys. The tool should support the following: - Connect to multiple PLC's in a project to see its variables and debug it. - Central Engineering capabilities (for example shared libraries in a project). - Download the new code / binaries to the plc. - Maybe have functionality to combine visualization elements and logic together. - See the live status variables on all the systems (crosscommunication). I see that codesys theoretically supports engineering of multiple PLC's, but I couldnt find to much functionality for a DCS type of operation, but that could be lack of knowledge. Any tips from you? Is Codesys good enough for this and maybe there are some manufacturers which build around it? Or are there good tools on the market with Codesys support (and the engineering is separate, but download to codesys possible). The use case is distributed energy installations like Heating pumps, Photovoltaics, etc. All these installations should have a PLC with codesys installed and run in one larger network, the PLC's are connected via VPN. Thanks for your inputs Greetings
Last updated: 2024-02-19

Post by alex00 on DCS / Central Engineering for Codesys CODESYS Forge talk (Post)
Hello together I'm currently investing in possibilities to have a central engineering software / system for Codesys based controllers. Something like a DCS / SCADA depending on where you see the functionality. We plan to use more or less vanilla codesys. The tool should support the following: - Connect to multiple PLC's in a project to see its variables and debug it. - Central Engineering capabilities (for example shared libraries in a project). - Download the new code / binaries to the plc. - Maybe have functionality to combine visualization elements and logic together. - See the live status variables on all the systems (crosscommunication). I see that codesys theoretically supports engineering of multiple PLC's, but I couldnt find to much functionality for a DCS type of operation, but that could be lack of knowledge. Any tips from you? Is Codesys good enough for this and maybe there are some manufacturers which build around it? Or are there good tools on the market with Codesys support (and the engineering is separate, but download to codesys possible). The use case is distributed energy installations like Heating pumps, Photovoltaics, etc. All these installations should have a PLC with codesys installed and run in one larger network, the PLC's are connected via VPN. Thanks for your inputs Greetings
Last updated: 2024-02-19

Post by francescoc on Custom log CmpLog CODESYS Forge talk (Post)
Hi, I am trying to create a log in my application. Since I cannot find any documentation regarding modifying the codesys configuration file to be able to log in ms, i tried to create a new log via CmpLog.LogCreate. Below is the part of the code where I create the logger and write a test string. In the log tab of codesys I actually see the new log that was created, but it is empty, and in the folder I cannot find any files. I can't find any detailed documentation. Can you guys give me support? Are there any examples? Thank you IF NOT FirstCycle THEN LogName:= 'LOGS/TestLog'; LogOptions.bEnable:= 1; LogOptions.iMaxEntries:= 5000; LogOptions.iMaxFiles:= 100; LogOptions.iMaxFileSize:= 5000; LogOptions.szName:= LogName; LogOptions.uiType:= CmpLog.LogTypes.LT_TIMESTAMP_RTC_HIGHRES; LogOptions.uiFilter:= CmpLog.LogClass.LOG_ALL; LogHandle:= CmpLog.LogCreate(pOptions := ADR(LogOptions), pResult:= ADR(Result)); LogHandle:= CmpLog.LogOpen(pszName:= LogName, pResult:= Result); Component_Manager.CMAddComponent2('TestLogNEW', 16#00000001, ADR(udiCmpIdNEW), 0); CmpLog.LogAdd2(LogHandle, udiCmpIdNEW, CmpLog.LogClass.LOG_INFO, 1, 1, 'Logger started...'); END_IF IF TestWrite THEN TestWrite:= FALSE; CmpLog.LogAdd2(LogHandle, udiCmpIdNEW, CmpLog.LogClass.LOG_INFO, 1, 1, 'Write test'); END_IF
Last updated: 2024-03-16

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 salvadegianluca on How to use TON inside an FB that is instanced within a Visu page CODESYS Forge talk (Post)
Hi everyone; I'm building a project in which the drag of the mouse over some controls (or the click event) changes the background color of the control items; this change of color is made with an FB that assignes a color code to the background with MUX command based on the value of an enumerator, this part is perfectly working but, when I'm using a touchpanel instead of a web visu (controlled by a mouse) I get into some issues as it seems that the touch operations are not triggering the MouseEnter and MouseLeave properties as it's done with the mouse.... For this reason I'm trying to add a TON to my FB and, if the enum that changes color remains at the same state for more then 3s I'm automatically resetting it to it's "0" so the item gets back the not selected color. Anyhow it looks like the TON function from library is not working in these FB that are instanced in the various visualizations, as instead they do if I create some instances within the POUS. Anyone has ideas of how to make them work?
Last updated: 2024-04-15

Post by salvadegianluca on How to use TON inside an FB that is instanced within a Visu page CODESYS Forge talk (Post)
Hi everyone; I'm building a project in which the drag of the mouse over some controls (or the click event) changes the background color of the control items; this change of color is made with an FB that assignes a color code to the background with MUX command based on the value of an enumerator, this part is perfectly working but, when I'm using a touchpanel instead of a web visu (controlled by a mouse) I get into some issues as it seems that the touch operations are not triggering the MouseEnter and MouseLeave properties as it's done with the mouse.... For this reason I'm trying to add a TON to my FB and, if the enum that changes color remains at the same state for more then 3s I'm automatically resetting it to it's "0" so the item gets back the not selected color. Anyhow it looks like the TON function from library is not working in these FB that are instanced in the various visualizations, as instead they do if I create some instances within the POUS. Anyone has ideas of how to make them work?
Last updated: 2024-04-15

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 hanoues on setting date and time on CPX-E CODESYS Forge talk (Post)
Hello, Can anybody here tell me how to modify the time and date on my CPX-E? I used the code I found on CODESYS online help, but it doesn't work. What am I missing? FUNCTION current_date_time : STRING VAR stUTC_Timestamp : SysTime; //utc time // ULINT#1528280694913 stLocal_TimeStamp : SysTime; //local time but is in general equal // ULINT#1528280694913 stdNow : SysTimeDate; //local time in an object to access each number (day, month...) dtNow : DATE_AND_TIME;//DT#2018-6-6-10:24:54 todNow : TIME_OF_DAY; // TOD#10:24:54.913 datNow : DATE; // D#2018-6-6 END_VAR SysTimeRtcHighResGet(stUTC_Timestamp); // ULINT#1528273494913 SysTimeRtcConvertHighResToLocal(stUTC_Timestamp, stdNow); //convert UTC ULINT to Local SysTime // stdNow.wYear = UINT#2018 // stdNow.wMonth = UINT#6 // stdNowy.wDay = UINT#6 // stdNow.wHour = UINT#10 // stdNow.wMinute = UINT#24 // stdNow.wSecond = UINT#54 // stdNow.wMilliseconds = UINT#913 // stdNow.wDayOfWeek = UINT#3 // stdNow.wYday = UINT#157 SysTimeRtcConvertDateToHighRes(stdNow, stLocal_TimeStamp); // ULINT#1528280694913 dtNow := TO_DT(stLocal_TimeStamp / 1000 ( ms )); // DT#2018-6-6-10:24:54 todNow := TO_TOD(stLocal_TimeStamp MOD TO_ULINT(T#1D)); // TOD#10:24:54.913 datNow := TO_DATE(dtNow); // D#2018-6-6 (convert to appropriate string) current_date_time := concat('$N[', TO_STRING(dtNow)); current_date_time:= concat(current_date_time,'.'); current_date_time:= concat(current_date_time, TO_STRING(stdNow.wMilliseconds)); current_date_time:= concat(current_date_time,'] - '); RETURN;
Last updated: 2024-05-21

Post by tortilla on J1939 connection between two devices CODESYS Forge talk (Post)
Hey, I'm pretty new to CoDeSys so I don't know a lot of things yet. I have to create a connection between two devices (CANbus - J1939 connection). The idea for now is to send a message from one to another (one operates on 3.5 SP11 the other one on 2.3) I watched a few videos, worked with the documentation and worked with chatGPT 4o and was able to build the attached file. This part is about the device on 3.5.11: I'm using the J1939LocalECUDiag, TransmitParameterGroup, TransmissionTrigger Function blocks to send the message but my TransmitPG.xBusy / .xDone never turns to True and therefore my message is not sent while TransmitPG.xExcecute is True. I added the two devices in the CANbus in the J1939Manager and addapted the options like I've seen in the documentation. Can anyone explain what's wrong with my code in this casse or give me advices how to properly create a connection between my two devices? Thanks in advance!
Last updated: 2024-05-23

Post by wollvieh on Display minutes as hours & minutes CODESYS Forge talk (Post)
Here a code for an Operation Counter with : days,hours,minutes,seconds as an example, maybe it points you the right direction ? FUNCTION_BLOCK OperationDayHour VAR_INPUT IN : BOOL; // Betrieb Takt : BOOL; // 1Hz Systemtakt END_VAR VAR_OUTPUT BetrTag : UDINT; // Ausgabe Betriebstage Betrstd : UDINT; // Ausgabe Betriebsstunden Betrmin : UDINT; // Ausgabe Betriebsminuten Betrsec : UDINT; // Ausgabe Betriebsekunden BetrString : STRING; // Ausgabe als String END_VAR VAR ///Erkennung Taktflanke Flanke: R_TRIG; END_VAR VAR_IN_OUT BetrsecAbsolut: UDINT; //Ein/Ausgangsvariable Betriebssekunden RETAIN !!! END_VAR Flanke(CLK:= Takt, Q=> ); (*Erkennung Taktflanke*) IF (IN AND Flanke.Q) THEN (*Sekunden hochzählen*) BetrsecAbsolut := BetrsecAbsolut + 1; END_IF Betrsec := BetrsecAbsolut MOD 60; Betrmin := ( BetrsecAbsolut / 60) MOD 60; Betrstd := ( BetrsecAbsolut / 60 / 60 ) MOD 24; BetrTag := ( BetrsecAbsolut / 60 / 60 /24 ); BetrString := RIGHT ( UDINT_TO_STRING( BetrTag + 100000),5); BetrString := CONCAT (BetrString, 'd_'); BetrString := CONCAT (BetrString,RIGHT ( UDINT_TO_STRING( Betrstd + 100000),5)); BetrString := CONCAT (BetrString, 'h_'); BetrString := CONCAT (BetrString, RIGHT ( UDINT_TO_STRING( Betrmin + 100),2)); BetrString := CONCAT (BetrString, 'm_'); BetrString := CONCAT (BetrString, RIGHT ( UDINT_TO_STRING( Betrsec + 100),2)); BetrString := CONCAT (BetrString, 's');
Last updated: 2024-05-27

Post by caprez95 on Trace Restart Visuelement CODESYS Forge talk (Post)
Hallo zusammen. Ich habe schon länger mit dem Problem zu kämpfen, dass ich einen Trend (Visuelement) nicht resetten (neustarten) kann. Ich habe es jetzt mit dem Beispiel hinbekommen, die Trace-Aufzeichnung über die CmpTraceMgr Bibliothek zu steuern. Aber wie bekomme ich diese Trace-Aufzeichnung in ein Visuelement? Der Code sieht wie folgt aus: // 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 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 fajean on CODESYS control on RPi starts, shortly runs, then exits CODESYS Forge talk (Post)
I have a Raspberry Pi 4 we have been using for years to run CODESYS for development purposes. I recently have had to re-install the OS (Raspberry OS lite). The only change to the default configuration is not creating the "pi" user during install. I (apparently successfully) installed the 4.10.0.0 control on the Raspberry Pi. We have licences on a dongle. I am able to start the control. systemctl status shows it as running for a little while (exactly, precisely 30 seconds as per my tests, every time), then it becomes exited. I can restart the control, and the same thing happens again. Every time. In the brief moments it is running, I can log in to the PLC. Working fast and restarting the control many times, I have been able to configure users. I have been able to download my application. I have been able to run the application, and stop on a breakpoint. I have been able to connect with the licence manager and confirm the dongle is detected and licences are listed as OK. I see nothing wrong until the service just exits. I have found nothing in the logs. It is like the runtime just terminates with no error code or message after exactly 30 seconds. Any help would be appreciated.
Last updated: 2024-06-13

Post by 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 tyronnosaurus on ReceiveWatchdog FB not working on J1939 P2P PGNs CODESYS Forge talk (Post)
Hi guys. I've got a device that sends a status message over J1939 and a PLC running Codesys to receive it. This message uses a P2P PGN (as opposed to a broadcast PGN). Codesys can only read it if I mark the J1939_ECU as "Local" (see screenshot 1). The message is received correctly, that is not the problem. The problem is detecting if the message stops being received. Local ECUs have no Watchdog checkbox to detect if the message has been received in the last X seconds. In order to implement a watchdog, I've used a ReceiveWatchdog FB. The same code works well for any non-P2P message, but doesn't work for this particular P2P message I'm trying to monitor. Even if I physically disconnect the device, ReceiveWatchdog.xBusy stays True, and ReceiveWatchdog.xError never triggers due to a timeout error. Is there any caveat in the ReceiveWatchdog FB that makes it unable to monitor P2P PGNs in Local J1939_ECUs?
Last updated: 2024-07-11

Post by berto on Opening PDF in Web Browser in Target Visu HMI CODESYS Forge talk (Post)
Hi everybody, I've been facing problems with the PDF visualization in Web Browser. I am trying to open a pdf file called 'sample.pdf' which I manually saved inside PlcLogic/visu folder. I am setting the web browser URL as: 'http://127.0.0.1:8080/sample.pdf' but I get 'refused connection'. I got a similar error trying to open https sites and I discovered that I can only open http websites. Opening 'http://de.wikipedia.org' everything works fine. I also tried to check using code whether the sample.pdf is present in the directory. Unfortunately, when I try to read directories of 'PlcLogic' I get file FILE_OPERATION_DENIED (I am using File.DirList). I would like to be able to open PDF files in web browser. Possibly to move new PDF files in the folder as my customer wants to display different pdf manuals on the hmi. Here you find some screenshots and my .project. I am using Codesys 3.5.19.70. Best regards, Berto
Last updated: 2024-07-11

Post by otbeka on CmpCrypto CryptoGenerateHash Not Outputting CODESYS Forge talk (Post)
Hi, I have been trying to use CryptoGenerateHash from the CmpCrypto Implementation library. My code is taken almost directly from the CryptoDemo.project example provided on Codesys Forge, yet the CryptoGenerateHash function does not write to the address listed in pHash. RTS_IEC_RESULT is OK, but I am getting nothing out of the function. No errors either, all my libraries are up to date. Any help would be appreicated! PROGRAM PLC_PRG VAR sMessage : MESSAGE := 'The red fox runs across the ice'; abyHashCode : HASH_CODE := [ 16#52, 16#ED, 16#87, 16#9E, 16#70, 16#F7, 16#1D, 16#92, 16#6E, 16#B6, 16#95, 16#70, 16#08, 16#E0, 16#3C, 16#E4, 16#CA, 16#69, 16#45, 16#D3 ]; xMessageOK : BOOL; END_VAR xMessageOK := CheckMessage(sMessage, abyHashCode); FUNCTION CheckMessage : BOOL VAR_INPUT sMessage : REFERENCE TO MESSAGE; abyHashCode : REFERENCE TO HASH_CODE; END_VAR VAR _hHASH : RTS_IEC_HANDLE := CryptoGetAlgorithmById(ui32CryptoID:=RtsCryptoID.HASH_SHA1, pResult:=0); Result : RTS_IEC_RESULT; bsMessage : RtsByteString := (ui32MaxLen:=SIZEOF(sMessage), pByData:=ADR(sMessage), ui32Len:=TO_UDINT(LEN(sMessage))); abyNewHashCode : HASH_CODE; bsNewHashCode : RtsByteString := (ui32MaxLen:=SIZEOF(abyNewHashCode), pByData:=ADR(abyNewHashCode)); diCmpResult : DINT; END_VAR Result := CryptoGenerateHash(hAlgo:=_hHASH, pData:=ADR(bsMessage), pHash:=ADR(bsNewHashCode)); diCmpResult := SysMemCmp(pBuffer1:=ADR(abyHashCode), pBuffer2:=ADR(abyNewHashCode), udiCount:=SIZEOF(HASH_CODE)); CheckMessage := diCmpResult = 0;
Last updated: 2024-09-06

Post by karel-bas on Loosing connection to emulation running on Linux CODESYS Forge talk (Post)
Hello, I am trying to emulate my code but for some reason my Codesys IDE keeps loosing connection to the emulator. I am constantly pinging virtual machine on which its running and its running fine, but codesys refuses to reconect to it, and is not able to rediscover it. Codesys 3.5 SP20 Patch 1 I have linux installed like image in attachment.(using version 4.12) Linux VM is set up to use up to 4 cores and 8gb of ram, with nothing else runing on it. I dont have a license so I am aware that the emulation shouldnt run for more then 120 minutes I am able to, login, get sysinfo, reboot etc from codesys IDE for certain period of time (5minutes) then my connection gets lost, sometimes I can login again, but sometimes i have to reboot the VM. Any suggestions what might be the issue ?
Last updated: 2024-09-19

Post by hwillems on Ranges, Lambdas, on Fixed arrays of structs CODESYS Forge talk (Post)
I do datastructures and algorithms in Codesys. For example a Struct of Person with thing's like IdNumber, Name, Age etc. as example. Now i do all kind of calculations, filters. So i have this pretty big Fixed Array with Structs. On this struct i want to do simple stuff you can do easily in C++/Python/Rust etc. For example i want to do this: AvererageAge := Average(Peoples.Age); Then it will return the average of all members ages. Or Sort struct on age etc. Or sort on alphabetical Name. Or use Lambda functions to filter/mutate out things like, filter out everybody above 18 years old. Or remove people who it's name start with "A". Currently i have to write my own custom function for example sorting on Age. And make a super specific function based on that particulare datastructure. Here an Example: (*Before calling this FIlter method, set the mNodeFilterSwitch to the desired filter.*) CASE mNodeFilterSelect OF (********************************[ Status Filters ]***********************************) NodeID: FOR x := ACS_OUT_BEGIN TO ACS_OUT_END BY 1 DO FOR y := ACS_IN_BEGIN TO ACS_IN_END BY 1 DO IF marrNode[y].Status.oiNodeID > marrNode[y + 1].Status.oiNodeID THEN mNodeTemp := marrNode[y + 1]; marrNode[y + 1] := marrNode[y]; marrNode[y] := mNodeTemp; END_IF; END_FOR; END_FOR; Started: FOR x := DES_OUT_BEGIN TO DES_OUT_END BY -1 DO FOR y := DES_IN_BEGIN TO DES_IN_END BY -1 DO IF marrNode[y].Status.oxStarted > marrNode[y - 1].Status.oxStarted THEN mNodeTemp := marrNode[y - 1]; marrNode[y - 1] := marrNode[y]; marrNode[y] := mNodeTemp; END_IF; END_FOR; END_FOR; Starting: FOR x := DES_OUT_BEGIN TO DES_OUT_END BY -1 DO FOR y := DES_IN_BEGIN TO DES_IN_END BY -1 DO IF marrNode[y].Status.oxStarting > marrNode[y - 1].Status.oxStarting THEN mNodeTemp := marrNode[y - 1]; marrNode[y - 1] := marrNode[y]; marrNode[y] := mNodeTemp; END_IF; END_FOR; END_FOR; END_CASE; I have like 30+ of these in the enum. Not really DRY code right? These are custom made bubble sort filters in a function. You pass in the Datastructure, and say what function you want. (This is an enum collection of sorting functions) And then the Array with Nodes of Structs gets ordered. Why can't we have Iterators and Lambda's and build in standard functions like regular languages? Also i use bubble sort because it's the easiest to implement because i can't get this to code DRY. Problem with ST (Even the new one with classes) that it's very limited for programming datastructures and algorithms. Yes you still not want dynamic memory and you need to choose the correct algorithm so you know the most extreme edge cases regarding the time it takes to execute the algorithms.(Real-time execution) How are other people dealing with this? Here for example saw some software using an adjusted ST language and having FOR EACH possibility: https://www.fernhillsoftware.com/help/iec-61131/structured-text/st-for-each.html You can then build your own custom Iterator functions. I wish the IEC 61131-3 standard would be more expressive and having more standard modern features, but still keep close to the fact of no dynamics memory and real-time systems.
Last updated: 2023-08-31

Post by bschraud on Speicherbegrenzung für lokale Variablen CODESYS Forge talk (Post)
Aufgrund einer Schnittstellenänderung muss ich meine Messagebuffer erheblich vergrößern. U.g. Konstante bestimmt die Größe einer Byte-Array-Definition, die in einer Struktur für 9 Botschaften verwendet wird. Ich benötige also 177372byte zusätzlichen Speicher in dem Modul in dem die Struktur als lokale Variable angelegt wird. Dynamisches Allokieren zur Laufzeit möchte ich vermeiden, damit ich nicht während des Betriebes Fehler aus dem Allokieren behandeln muss. Für ein Reservieren des Speicherbereiches habe ich in Codesys keine Einstellmöglichkeiten gefunden. Die Applikation läßt sich ohne weitere Modifikation kopilieren, scheitert aber bei der Ausführung. Welche Lösungs- oder Einstellmöglichkeiten gibt es? Bei c_w_process_result_content_len_max: WORD := 292; [INFORMATION] Größe des lizenzierten Benutzercodes: 363304 Bytes [INFORMATION] Speicherverbrauch auf dem Gerät, nicht für Lizenzierung verwendet: [INFORMATION] Speicherbereich 0 enthält Daten, Eingang, Ausgang, Speicher und Nicht-sichere Daten: Größe: 2807632 Bytes , höchste verwendete Adresse: 2159712, größte zusammenhängende Speicherlücke: 647920 Bytes (23 %) [INFORMATION] Speicherbereich 3 enthält Code: Größe: 7267784 Bytes , höchste verwendete Adresse: 5590600, größte zusammenhängende Speicherlücke: 1677184 Bytes (23 %) Übersetzung abgeschlossen -- 0 Fehler, 10 Warnungen : Bereit für Download Speicherprüfung: [WARNUNG] PAC: MC0006: Pointeradresse außerhalb des verwalteten Speichers für Eintrag GVL.htFactory._itfInstList.__Interface in Area 0, Offset 0x000033BC (0x71C15414) [WARNUNG] PAC: MC0006: Pointeradresse außerhalb des verwalteten Speichers für Eintrag __datasourcesInstancesGVL.__datasourcesInstances.dsInst._allItemsHashtable._ht.__Interface in Area 0, Offset 0x00128904 (0x71D3A95C) [WARNUNG] PAC: MC0009: Pointer to Interface zeigt nicht auf die erwartete Schnittstelle in einer FB-Instanz für Eintrag IoConfig_Globals.PiXtend_V2_L_Instance._IIoDrv.__Interface in Area 0, Offset 0x0018EC00 (0x71DA0C58) [WARNUNG] PAC: MC0009: Pointer to Interface zeigt nicht auf die erwartete Schnittstelle in einer FB-Instanz für Eintrag IoConfig_Globals.PiXtend_V2_S_DAC_Instance._IIoDrv.__Interface in Area 0, Offset 0x0018F090 (0x71DA10E8) [INFORMATION] PAC: Überprüfter Speicher für 21336 Objekte. 4 Prüfung(en) fehlgeschlagen. [INFORMATION] PAC: Check took 00:00:13.9743220. Applikation lässt sich downloaden und funktioniert auf dem Gerät. Nach der Vergrößerung: c_w_process_result_content_len_max: WORD := 20000; [INFORMATION] Größe des lizenzierten Benutzercodes: 363304 Bytes [INFORMATION] Speicherverbrauch auf dem Gerät, nicht für Lizenzierung verwendet: [INFORMATION] Speicherbereich 0 enthält Daten, Eingang, Ausgang, Speicher und Nicht-sichere Daten: Größe: 4114264 Bytes , höchste verwendete Adresse: 3164816, größte zusammenhängende Speicherlücke: 949448 Bytes (23 %) [INFORMATION] Speicherbereich 3 enthält Code: Größe: 7267832 Bytes , höchste verwendete Adresse: 5590640, größte zusammenhängende Speicherlücke: 1677192 Bytes (23 %) Übersetzung abgeschlossen -- 0 Fehler, 10 Warnungen : Bereit für Download Speicherprüfung: (gleiches Ergebnis wie vorher) [WARNUNG] PAC: MC0006: Pointeradresse außerhalb des verwalteten Speichers für Eintrag GVL.htFactory._itfInstList.__Interface in Area 0, Offset 0x000033BC (0x71C15414) [WARNUNG] PAC: MC0006: Pointeradresse außerhalb des verwalteten Speichers für Eintrag __datasourcesInstancesGVL.__datasourcesInstances.dsInst._allItemsHashtable._ht.__Interface in Area 0, Offset 0x0021DF38 (0x71E2FF90) [WARNUNG] PAC: MC0009: Pointer to Interface zeigt nicht auf die erwartete Schnittstelle in einer FB-Instanz für Eintrag IoConfig_Globals.PiXtend_V2_L_Instance._IIoDrv.__Interface in Area 0, Offset 0x00284238 (0x71E96290) [WARNUNG] PAC: MC0009: Pointer to Interface zeigt nicht auf die erwartete Schnittstelle in einer FB-Instanz für Eintrag IoConfig_Globals.PiXtend_V2_S_DAC_Instance._IIoDrv.__Interface in Area 0, Offset 0x002846C8 (0x71E96720) [INFORMATION] PAC: Überprüfter Speicher für 21336 Objekte. 4 Prüfung(en) fehlgeschlagen. [INFORMATION] PAC: Check took 00:00:14.0491831. Applikation lässt sich downloaden. Ausführen mündet in Ausnahmefehler Die Applikation läuft auf der Runtime CODESYS Control for Raspberry Pi MC SL. Die Codesys Version ist 3.5 SP20 mit allen Updates. Kennt jemand eine Speichergrenze für lokale Variablen bzw. eventuelle Einstellmöglichkeiten? Vielen Dank
Last updated: 2024-05-06

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

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

Post by testlogic on Sending Sequential Modbus TCP Packets CODESYS Forge talk (Post)
I have a Modbus TCP slave device where I need to do sequential writes to the same register. The register I'm writing to is kind of like a command line, each packet is a command word encoded in Hexadecimal. I am having difficulty implementing this system in CoDeSys 3.5 SP19. I feel like the structure of the program should be something along the lines of (Pseudocode): ModbusTCPSend(Command Register, Command1) ModbusTCPSend(Command Register, Command2) ModbusTCPSend(Command Register, Command3) I have tried to implement this with a rising edge trigger wMot1OPCode := 16#E1; //Stop Motor & Kill Program xMot1SendOP := TRUE; //Send OP on rising edge xMot1SendOP := FALSE; //Reset wMot1OPCode := 16#9E; //Disable Motor xMot1SendOP :=TRUE; //Send OP on rising edge xMot1SendOP := FALSE; //Reset Where "wMot1OPCode" is the IO map for writing to the command register, and "xMot1SendOP" is the rising edge trigger for that modbus channel. However, this doesn't work. The device never responds to the modbus commands. It seems like the trigger variable is switched too quickly for modbus to send the packet. I know the modbus register is working, because I can set the channel to cyclic and the device will respond. However, I can't use this reliably because I need each command to be sent once, in order. Cyclic keeps re-sending the commands and seems like it could miss a command as well if one was sent in-between cycle time. I have also trying using the Application trigger as described by https://faq.codesys.com/pages/viewpage.action?pageId=24510480, but this is also not working for me. See attached picture for my FBD code. This seems like a simple function, I can't tell what I'm doing wrong here. Thanks for the help.
Last updated: 2024-03-06

Post by thysonfury on OPTO22 Groov Epic PR2 Modbus Comms Dropping out every 2 hours and 4 Mins CODESYS Forge talk (Post)
Hi after some assistance with an error on a Groov PR2 PLC. We have a few different communications set up as shown below: One Modbus TCP Slave Connection - ( Sending / Receiving Data from a PC ) Two Modbus TCP Master Connection - ( Reading Data from a UPS Panel and Reading Data Gas Chromatograph) One Modbus RTU Slave Connection 485 - (Reading Data from a fire and gas panel) One Modbus RTU Master Connection 485 - (Sending Data to a Telemetry Unit) All Licenses have been installed as per OPTO22 suggestions of the order below: Modbus TCP Master Modbus TCP Slave Modbus RTU Master Modbus RTU Slave When I check on License manager the RTU Master license seems to disappear on installing the RTU. (What ever reason I’ve been told this is “normal”). If I use Device License Read It will successfully read all the licenses correctly. Now the issue is every 2 hours and between 4. For what ever reason the communications seems to end and lock up for about 20 seconds. During this time even if I was logged into the PLC it would kick me off and I’d have to re type the password to enter. Most of the devices can handle this however the RTU flags up a communications failure at the SCADA and is raising alarms every 2 hours and 4 mins. We’ve had multiple people go through the code to check for anything obvious. Does anyone have any ideas?
Last updated: 2024-04-15

Post by thysonfury on OPTO22 Groov Epic PR2 Modbus Comms Dropping out every 2 hours and 4 Mins CODESYS Forge talk (Post)
Hi after some assistance with an error on a Groov PR2 PLC. We have a few different communications set up as shown below: One Modbus TCP Slave Connection - ( Sending / Receiving Data from a PC ) Two Modbus TCP Master Connection - ( Reading Data from a UPS Panel and Reading Data Gas Chromatograph) One Modbus RTU Slave Connection 485 - (Reading Data from a fire and gas panel) One Modbus RTU Master Connection 485 - (Sending Data to a Telemetry Unit) All Licenses have been installed as per OPTO22 suggestions of the order below: Modbus TCP Master Modbus TCP Slave Modbus RTU Master Modbus RTU Slave When I check on License manager the RTU Master license seems to disappear on installing the RTU. (What ever reason I’ve been told this is “normal”). If I use Device License Read It will successfully read all the licenses correctly. Now the issue is every 2 hours and between 4. For what ever reason the communications seems to end and lock up for about 20 seconds. During this time even if I was logged into the PLC it would kick me off and I’d have to re type the password to enter. Most of the devices can handle this however the RTU flags up a communications failure at the SCADA and is raising alarms every 2 hours and 4 mins. We’ve had multiple people go through the code to check for anything obvious. Does anyone have any ideas?
Last updated: 2024-04-15

<< < 1 .. 51 52 53 54 > >> (Page 53 of 54)

Showing results of 1340

Sort by relevance or date