LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus RTU - Reading Holding registers problem - Novus myPCLab

Solved!
Go to solution

Hello,

 

I'm trying for a few days to read Holding registers in Novus myPCLab (it uses Modbus RTU protocol). I used both DSC module and Modbus library with no success (it appears to connect correctly but cant read).

I need to read the given current.

 

Does anyone have any idea about what am I doing wrong? 

 


 

 

Here are my vi and the modbus address.

Modbus address

Via DSC

Modbus via DSC

I used the PLC address at "HR Inicial" and 1 at "numero de registros"

 

 

Via library

Modbus_lib.PNG

Modbus_lib2

I used the PLC address in "starting address"

0 Kudos
Message 1 of 6
(5,210 Views)
Solution
Accepted by topic author victorfc

You created a connection that is set to use a "Unit ID" of 0.  Generally slave devices never use a device number of 0 because that is considered a broadcast address.

 

Double check the slave address of your device.  Then make sure you use that number.

 

I'm assuming you are communicating to a device that behaves as a slave.  If so, then you should create a Modbus master in your code.  With the new modbus communication protocol subVI's, you have created a slave.  One slave can't talk to another slave.

 

 

Likewise in your second image where you use the older Modbus library, you did not connect any constant to the top of the WriteRead SubVI that sets the serial parameters of the devices such as RTU and the slave address, so it also defaults to 0.  Again, a broadcast address.

0 Kudos
Message 2 of 6
(5,199 Views)

Thank you RavensFan, it worked great after I created a Modbus Master. I was trying to communicate a slave with another slave, as you said.

By now, I can read and write at my 2 equipments (Novus PCLab and PLN-2 via Novus USB-i485).

0 Kudos
Message 3 of 6
(5,126 Views)

My problem now is that my VI doesn't stops after I stop the while loop, it is necessary for a flat sequence implementation.

 

Or my other best option is to read and write without closing the Modbus connection. Is that possible with a global variable? 
I guess I do have to execute this "Modbus VI" to get my variables at a Main VI if they are in the same project. So, can I make my "Modbus VI" works in the background while the Main VI (who reads and write the addresses from the global variable) works, and when I finish running it, they stop together?

 

ModBUS VI

ModBUS master.PNG

0 Kudos
Message 4 of 6
(5,118 Views)
Solution
Accepted by topic author victorfc

If you hit your stop button  (which is what I figure your button called "Fim da Leitura" is supposed to be), your VI is still going to be running, waiting on an event to happen in the event structure.  I would recommend that you make a value change event for that button and put the terminal inside of it and wire it to the stop terminal for the loop.  That way when you hit the button, the event structure fires and sends the true value to stop the loop.

 

I don't know of anything else that is going to keep your VI running.

 

You can certainly break your modbus code off and have it work in a different loop, or a different VI.  Global variables are one of many ways to transfer data between VI's.  Though it usually isn't my first choice.  You can also use queues or notifiers.

0 Kudos
Message 5 of 6
(5,110 Views)

Thank you, RavensFan. It works fine now!
I owe you a beer!

Message 6 of 6
(5,076 Views)