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 george32 on Readable IO names
CODESYS Forge
talk
(Post)
Hello Folks, I have a quite basic understanding of how PLC programming works. However I keep getting stuck on 1 problem I could not get my head around. The problem is as follow: I have a PLC with 60 IO (20 inputs, 40 outputs). Each IO is defined as a function block. Furthermore I have an external IO card connected trough a CanBus connection. This IO card has 4 analog input channels (USINT), 4 digital inputs (Bool) and 4, digital outputs (Bool) Because I have 2 different components which both has data have I made 4 arrays to store the data off every component in one variable. PLC_Input: Array [1..20] of BOOL; PLC_Output: Array [1..40] of BOOL IOCard_Input: Array [1..8] of BOOL IOCard_Output: Array [1..4] of BOOL Because the control and reading of the different in and outputs is done by a TCP connection I want to use some kind of enumeration or struct to give each index a name so that my main would be a little bit more readable instead of all the magic numbers. Also this would make my program more dynamic for the furter in case I need to changes some in the IO nummers. For example: pump is placed on the fysical terminal strip number place 54, which is the 3th output of the IO card in the program: if I am sending a message with value 54 I would like to control IOCard_Output[3]. If there is a solution or methode to get this done, I can eventually do the following in my main program: IOCard_Output[Pump]. I have tried the following: IOCard_Output[Pump - 51] with an enumration but this keeps raising an error I hope some of you could help me further with this problem. In gross lines: I want to couple all the different IO to a more readable name and this readable name should control the right Array index Thanks in advance, George
Last updated: 2024-09-26
Post by raghusingh77 on Get $100 EVERY TIME USE THIS COUPON CODE OF ACU934948 TEMU
CODESYS Forge
talk
(Post)
Temu has quickly established itself as a leading online shopping platform, offering customers a wide array of products at unbeatable prices. As we move through 2024, shoppers can take advantage of exciting promotions, including the $100 off coupon code [ACU934948]. This article will guide you through how to maximize your savings with this code and other fantastic offers available on Temu. Exclusive Discounts for New Users For those who are new to Temu, the platform offers an enticing 30% discount on orders over $39. By using the coupon code [ACU934948], first-time users can enjoy this immediate savings opportunity. Additionally, new users can benefit from a special promotion that provides up to 75% off their first purchase. This makes it an ideal time for newcomers to explore Temu's extensive inventory while enjoying significant discounts. Massive October Promotions October 2024 is shaping up to be a month filled with incredible deals on Temu. Shoppers can access discounts of up to 90% off select items when using the coupon code [ACU934948]. This promotion is part of Temu's strategy to attract both new and returning customers during the busy shopping season. Flat Discounts and Bundle Offers The $100 off coupon code [ACU934948] stands out as a valuable offer, providing a flat discount that enhances the overall value of your purchases. This coupon is applicable not only for new users but also for existing customers, ensuring that everyone can benefit from substantial savings. Furthermore, Temu has introduced bundle offers that combine this $100 discount with additional promotions, allowing customers to save up to 70% on select products. Temu Rewards Program for Loyal Customers Temu values its loyal customers through its comprehensive Rewards Program, which offers exclusive deals and discounts. By using the coupon code [ACU934948], existing customers can enjoy additional benefits, including potential cash-back offers. For example, eligible purchases may yield up to 25% cash back, making it even more rewarding to shop at Temu. How to Redeem Your Coupons Using Temu's coupon codes is straightforward: Browse Products: Start by exploring Temu’s extensive range of items. Add to Cart: Once you find what you like, add it to your shopping cart. Apply the Coupon Code: At checkout, enter the coupon code [ACU934948] in the designated field and click "Apply." Complete Your Purchase: Review your discounted total before finalizing your order. Tips for Maximizing Savings Redeem Temu Coupon Code [ACU934948]. TEMU COUPON $100 OFF [ACU934948] TEMU COUPON $100 OFF FOR EXISTING CUSTOMERS [ACU934948] TEMU COUPON $100 OFF FIRST ORDER [ACU934948] TEMU COUPON $100 OFF REDDIT [ACU934948] TEMU COUPON $100 OFF FOR EXISTING CUSTOMERS REDDIT [ACU934948] TEMU COUPON $100 OFF NEW USER [ACU934948] TEMU COUPON $100 OFF FOR EXISTING CUSTOMERS 2024 [ACU934948] TEMU COUPON $100 OFF CODE [ACU934948] TEMU COUPON $100 OFF FIRST ORDER FREE SHIPPING [ACU934948] TEMU COUPON $100 OFF FOR EXISTING CUSTOMERS FREE SHIPPING USA [ACU934948] TEMU COUPON $100 OFF HOW DOES IT WORK [ACU934948] TEMU COUPON $100 OFF FOR EXISTING CUSTOMERS CANADA [ACU934948] TEMU COUPON $100 OFF 2024 [ACU934948] TEMU COUPON $100 OFF FOR NEW CUSTOMERS [ACU934948] TEMU COUPON $100 OFF CANADA [ACU934948] TEMU COUPON $100 OFF FOR EXISTING CUSTOMERS FIRST ORDER [ACU934948] TEMU 100 OFF COUPON BUNDLE [ACU934948] 100 COUPON CODES [ACU934948] 1 BUCKS TO PHP [ACU934948] IS THERE A COUPON IN THE PHILIPPINES [ACU934948] 100 BUCKS TO PHP [ACU934948] TEMU $100 OFF COUPON [ACU934948] TEMU $100 OFF CODE [ACU934948] TEMU 100 VALUE COUPON BUNDLE [ACU934948] TEMU COUPON $100 OFF FOR EXISTING CUSTOMERS FREE SHIPPING [ACU934948] TEMU 100 OFF COUPON CODE LEGIT [ACU934948] TEMU 100 OFF COUPON CODE REDDIT [ACU934948] TEMU 100 OFF COUPON CODE FOR EXISTING USERS [ACU934948] TEMU 100 OFF COUPON CODE UK [ACU934948] TEMU COUPON CODE $100 OFF FREE SHIPPING [ACU934948] TEMU COUPON CODES 100 PERCENT OFF [ACU934948] WHAT IS A HIGH COUPON RATE [ACU934948] HOW TO CALCULATE COUPON RATE WITHOUT COUPON PAYMENT [ACU934948] WHAT IS THE COUPON RATE [ACU934948] HOW TO CALCULATE COUPON VALUE [ACU934948] USING COUPONS AND REBATES TO LOWER THE PRICE OF AN ITEM IS AN EXAMPLE OF [ACU934948] TEMU 100 DOLLAR OFF COUPON [ACU934948] DOMINOS COUPON CODE 100 OFF [ACU934948] DOMINO'S 100 RS OFF COUPON CODE [ACU934948] TEMU COUPON $100 OFF EXISTING CUSTOMERS [ACU934948] WHAT IS 10 OFF 100 DOLLARS [ACU934948] 100 OFF PROMO CODE [ACU934948] 1 CASHBACK ON 100 DOLLARS [ACU934948] IS TEMU 100 OFF COUPON LEGIT [ACU934948] TEMU COUPON $100 OFF [ACU934948] TEMU COUPON $100 OFF LEGIT [ACU934948] Temu Coupon Code $100 OFF [ACU934948] Stacking Discounts: While you cannot apply multiple coupon codes in one transaction, ensure you're using the most beneficial code available. Lightning Deals: Keep an eye out for limited-time "Lightning Deals," which often feature discounts of up to 80%. Free Shipping Offers: Temu provides free standard shipping on all orders, enhancing the value of your purchases. Conclusion With its competitive pricing and generous promotional offers like the $100 off coupon code [ACU934948], Temu is an excellent choice for savvy shoppers looking for great deals. Whether you are a new user eager to explore or an existing customer ready to reap rewards, Temu provides ample opportunities to save significantly on your purchases. Don't miss out—redeem your coupons today and enjoy an exceptional shopping experience filled with incredible value
Last updated: 2024-10-26
Post by smeitink on Timeout Error in Modbus Communication with WAGO PFC200 and iEM2050 Meter using 750-652 Module
CODESYS Forge
talk
(Post)
Hi all, I'm looking for help with an issue I've come across while trying to facilitate Modbus communication between a WAGO PFC200 PLC using a 750-652 communication module and an iEM2050 Series Single Phase Energy Meter. I believe to have everything wired and setup correcty, but I keep running into a "Error time out" message, and by now I don't really know what else to try. My setup is as follows: A PFC200 Wago PLC, which has 2 750-652 Serial Interfaces extension modules connected to its field bus. I'm using one of these to talk to a Schneider iEM2050 - kWh-meter over modbus. I have connected terminal 23 (A) of the iEM2050 to connector 6 (A) on the 750-652. I have connected terminal 24 (B) of the iEM2050 to connector 2 (B) of the 750-652. I'm using 200mm of twisted together wires to connected them both, and I have placed a 120 ohm resistor between A and B at both ends. I've attached relevant pinout images to this post. I then wrote a simple program that configures the Mobus port, as per the datasheet of the iEM2050. You can find an image of the relavent page attached to this post too. This is my program: PROGRAM PLC_PRG VAR Master: FbMbMasterSerial; xIsConnected: BOOL; xError: BOOL; iIndex: INT := 1; xTrigger: BOOL; utQuery : typMbQuery := ( bUnitId := 1, // The Modbus unit or slave address bFunctionCode := 4, // Function code for reading input registers uiReadAddress := 1829, // adress for the Power on off counter uiReadQuantity := 1 // Quantity of registers to read ); iStep: INT; oStatusModbus: WagoSysErrorBase.FbResult; utResponseModbus: typMbResponse; xConnect: BOOL := FALSE; delayTimer: TON; END_VAR Master( xConnect:= xConnect, I_Port:= _750_652_24_1, udiBaudrate:= 9600, usiDataBits:= 8, eParity:= WagoTypesCom.eTTYParity.Even, eStopBits:= WagoTypesCom.eTTYStopBits.One, eHandshake:= WagoTypesCom.eTTYHandshake.None, ePhysical:= WagoTypesCom.eTTYPhysicalLayer.RS485_HalfDuplex, xIsConnected=> xIsConnected, xError=> xError, oStatus=> oStatusModbus, eFrameType:= WagoAppPlcModbus.eMbFrameType.RTU, tTimeOut:= T#5S, utQuery:= utQuery, xTrigger:= xTrigger, utResponse:= utResponseModbus); delayTimer(IN := TRUE, PT := T#3S); // Use the Q output of the timer to set xConnect after the delay IF delayTimer.Q THEN xConnect := TRUE; END_IF CASE iStep OF 0: //Wacht totdat de master de poort geopend heeft IF xIsConnected THEN iStep := 1; END_IF 1: //Stuur request naar de slave xTrigger := TRUE; iStep := 2; 2: //Wacht totdat de master klaar is met het afhandelen van de request IF NOT xTrigger THEN iStep := 3; END_IF END_CASE The TON delay before opening the port is due to a an error I encountered when opening it straight away. This seems to be a bug, as described here. However, the TON solved that particular issue. I tried reading multiple registers, but like I said, I still always end up with the "Error time out". What else can I test or try at this point?
Last updated: 2024-02-24
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
.