Ask Me About Webinar: Data Center Assets - Modeling, Cooling, and CFD Simulation Join our 30-minute expert session on July 10, 2025 (9:00 AM & 5:00 PM CET), to explore Digital Twins, cooling simulations, and IT infrastructure modeling. Learn how to boost resiliency and plan power capacity effectively.Register now to secure your spot!
Read input register with M340, via READ_VAR
Modicon PAC Forum
A forum for topics related to the scope of Modicon PAC offers and ecosystem along the whole lifecycle: Modicon M580 and 340, EcoStruxure Control Expert, EcoStruxure Process Expert (Unity Pro) and more.
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send InviteCancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2025-09-1203:02 AM
Read input register with M340, via READ_VAR
Hello,
I'm trying to read the values on a flow meter via Modbus TCP with a M340 CPU and a NOE card.
The hardware configuration goes like this: Flow meter -> Modbus RTU to TCP Gateway -> NOE.
When I use a Modbus TCP Client on my PC (simply Modbus), I can read the modbus register just fine.
I use the function 4 "Read Input Registers", and I'm reading for example the 30103 register.
To do this in Control Expert (License XL and V16.0 by the way), I wrote this code in the MAST task:
GEST_READVAR[2] := 50; IF NOT GEST_READVAR[0].0 THEN READ_VAR (ADR := ADDM('Ethernet_1{192.168.50.153}1'), OBJ := '%IW', NUM := 30103, NB := length_arint(RECP_READVAR), GEST := GEST_READVAR, RECP => RECP_READVAR); END_IF;
reTest := WORD_AS_REAL(LOW := INT_TO_WORD(RECP_READVAR[0]), HIGH := INT_TO_WORD(RECP_READVAR[1]));
(RECP_READVAR is an ARRAY[0..1] OF INT, reTest is a REAL).
Currently, the values of lines 0 and 1 in the RECP array are both 0, but simply modbus displays other values, so something must be wrong but I don't know what.
Does anyone have an idea of what I can do to make this work?
(you can find the datasheet of the Modbus RTU module attached to the topic, with register numbers on pages 19 to 26)
Thanks a lot for the time anyone would take to look into this😀