LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Shared Variable using Modbus

I am using LabVIEW 8.0 and communicating to a Honeywell PLC (HC900) using TCP/IP and the Modbus Protocol.

I have the Ethernet communications link setup properly and I'm communicating with the PLC as I can monitor a small program that the controller is running.

In LabVIEW, I have set up some shared variables, and deployed them with no problems.

Here's the rub: I have no problem controlling digital (On/Off) functions however the Analog functions are causing me grief. I can't seem to read back proper values.

I am curious  if anybody has  used a ModBus connection to a Honeywell PLC and can shed some light on Analog Shared Variables.


0 Kudos
Message 1 of 10
(5,284 Views)

Hi Tariah,
Have you been able to track down where the numbers are wrong?  Are wrong values coming into LabVIEW from the device or are they Shared Variables providing the wrong values.  You can use probes and execution highlighting to find out where the numbers are going wrong.  If they are wrong coming in from LabVIEW, have you confirmed that the values are correct directly from the device?  I know you mentioned that the digital values were correct, but wanted to make sure with the analog values.

Also, how are the numbers wrong?  Are they old values that could be an issue with buffering/retrieving data?  Are they off by a certain value each time?  Are the wrong values reproducible?

Anyway, please answer these questions and we can take a look further into the issue for you.

Have a great day!

Chris R.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 10
(5,266 Views)
Hi Chris,
 It turns out that I wasn't reading the Modbus correctly. I had set up my shared variables as singles and thought LabVIEW would somehow do the conversion to a floating point value for me. 
Instead,  I had to set up the shared variables as U16 (each address in the PLC is 16-bits) and set one variable to the address I wanted to read and another to that address + 1. Then I had to write a VI that converts the results from both addresses to IEEE format in order to obtain the floating point value. That was fun...whew! 
So I can now read the returned values from the Honeywell HC900 PLC.

I can't control the PLC's values yet....not sure why, but it'll come.

Thanks for the response,

Tariah
0 Kudos
Message 3 of 10
(5,258 Views)

Hi Tariah,

Thanks for the update!  I am glad you got the shared variable/modbus part up and running.  Let us know if you have any other questions!

Good luck and have a great day!

Chris R.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 10
(5,245 Views)
Well, it seems that writing to a PLC address is more of a road block than I had expected. 
I can write to an address with another software package but not LV.
Honeywell service has no clue.  Does anybody here use LV and shared variables to read/write to a PLC...any brand of PLC?


0 Kudos
Message 5 of 10
(5,222 Views)
Tariah, How are you? I hope well.
 
There are different ways to read/write to and from a PLC. You can use OPC, Modbus (Ethernet/Serial), etc. However, based on your posts, I presume you are using Modbus.
 
In LabVIEW 8.0, you can create a new shared variable (Right click on My Computer >> New Variable) and also create a new Modbus I/O Server. In the shared variable properties, check the "Bind to Source" check box >> Click Browse >> Expand your project to display the Modbus I/O Server you created, select it and click OK >> Specify the Address you want to write to.
 
In your properties page for your Shared Variable (sv), make sure you configure the sv properly (make it either read or write or read/write) depending on what you are trying to do. Updating the sv should update the Modbus address...
 
Please post and let us know how it goes.
 
Efosa O.
NIAE
 
 
0 Kudos
Message 6 of 10
(5,211 Views)
Thanks for the input Efosa,

Yes, I am using Modbus via an Ethernet connection. The communication between PC and PLC is fine as I can program the PLC with software running on the same PC as the LabVIEW application.
 
I have set up a shared variable library and also a ModBbus I/O server with the proper IP address.  I have several shared variables that control digital (boolean) variables in the PLC program and they work fine; reading and writing.
I have several shared variables that read analog variables in the PLC program and they work fine.

But I can't write to any PLC analog variables. No errors reported...just doesn't work.

And another peculiar issue...LV Shared Variables that are set up as doubles don't act like floating point doubles after I check the Bind to Source in the "Shared Variable Properties" dialog.  A value like 3.85 gets truncated to 3.
I bind to a path; a Modbus holding register address in the 400001-465535 range.

BTW, you can even see this in the I/O demo provided by NI with DSC module, which just uses a simulated modbus connection.

Loads of fun, this stuff!  (he says, while the customer's clock keeps tickin')







 
 
0 Kudos
Message 7 of 10
(5,197 Views)

Tariah, hello.

In your previous post, you say everything works except writing to Modbus addresses of analog variables. This should not be the case. One thing you can check is to make sure the addresses you are writing to are not read-only addresses.

Another thing you can try to check is the "Access Type" of the sv. Make sure if you are writing, you make it a write only sv if you are reading from it, you make it a read only sv.

Besides that, I am not sure why you are not able to write analog values to your PLC.

Lastly, I am not entirely sure what you mean when you say "LV Shared Variables that are set up as doubles don't act like floating point doubles after I check the Bind to Source in the Shared Variables Properties" dialog. Does this mean that you are reading floating point values from different Modbus Addresses and they are being displayed as integers in LabVIEW? If you can expound on that, it will be helpful. As far as I know, when a sv is BOUND to a Modbus Address, you will get whatever value is in the address converted to whatever datatype your sv is configured as.

Regards,
Efosa O.
NIAE

0 Kudos
Message 8 of 10
(5,178 Views)

I have tried every combination of "access type"...no luck. The PLC address are read/write, also.

As to the double shared variable issue, LV ships with a ModBus demo and the problem exists in that, also. Values such as 3.8  or 7.34  become 3 and 7 respectively.  And this is with shared variables configured as "doubles".  Even if I manage to get communication with the PLC working, this will be a show-stopper.

If I solve the problem I'll post the answer.

Thanks
0 Kudos
Message 9 of 10
(5,157 Views)
 

Tariah, hello. I hope things are going well.

I was wondering, what version of the DSC module are you using? I know that there were a lot of fixes when DSC 8.0.1 came out. I will really recommend you downloading and installing DSC 8.0.1 if you do not have it installed yet. Make sure you take a look at the Readme and you also have the necessary software installed.

Another thing will be to try communicating with another PLC if you have one. It really seems strange that you are able to write and read from the booleans, and read from the doubles, but not write.

Please keep us posted. Thanks

Efosa O.
NIAE

0 Kudos
Message 10 of 10
(5,145 Views)