From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus TCP/IP with while loop doesn't work

Solved!
Go to solution

Hi,

 

I am using a Acuvim II energy meter through Modbus TCP/IP, and would look to automate the data so that I could use a while loop and change it every 2 seconds. However, I am not able to do it on a while loop, since I would receive a error 538182, so I have done it as a for loop however it is not effective... Any ideas on how to implement this?

 

Thanks!

0 Kudos
Message 1 of 3
(1,238 Views)
Solution
Accepted by topic author kepham

That error says the address you are using is not allowed.  I have a suspicion it is the way you set up your Modbus read.

Also, I'm suspicious of how you set up 3 simultaneous Modbus calls to the same server.

 

You created an array of addresses that are consecutive, index through them can ask for 2 registers.  So just looking at the top call, you have an array of registers 16386 and 16387.  On first loop iteration, your starting address is 16386 and you request 2, which means you get back an array of 16386 and 16387.  On the second loop iteration, your starting address is 16387 and you request 2, which means you get back an array of 16387 and 16388.  If 16388 doesn't exist, you would get an error like you see.  Or maybe it is one of the other pairs of registers.  Edit:  I just saw you have a 1 wired to the N terminal.

 

Take several steps back.  Don't try to do 3 things at once and multiple registers.  Create a single modbus call, and go through read just 1 register.  See if that works.  Do that for all 6 of the addresses you have broken up among the arrays.  Hopefully they all work.

 

Now try for 3 more registers (16388, 16404, 16414).  Do any of them fail with the error you saw?  That explains why you are getting the error.

 

Now create a For Loop with just a single Modbus Read.  Auto-index on an array of 3 values (16386, 16402, 16412) with a number to read of 2.  Move your value conversion into the For Loop.  Auto-index the outputs and now you have an array that consists of the 3 number you want.

 

See attached VI for a cleaned up version that is more likely to work.

Message 2 of 3
(1,212 Views)

Thank you so much! It worked!

0 Kudos
Message 3 of 3
(1,192 Views)