LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

modbus write data and read register

I have had difficulty in developing code for Modbus. I do not have the DSC, state, lookout modules. These modules have been refered to by many users on this forum. I have a working modbus interface to a watlow 4Fd controller. I had problems passing global variables to the modbus. One of the NI app engineers was super helpful in adding the missing globals. I have a GUI interface where I need to send data and read the register. I am trying to send a decimal value to the data register and read the register for the returned value. I am unclear on how to achieve the two last issues? 
Download All
0 Kudos
Message 1 of 15
(4,127 Views)

Your second VI has no block diagram, thus I couldn't load it.

 

Your first VI doesn't have much going on in it, and we don't have those global variables.  So there really isn't any help we can give until we get more details on what your issue is.

0 Kudos
Message 2 of 15
(4,120 Views)
Have you tried the free NI modbus library that you can download here. http://sine.ni.com/devzone/cda/epd/p/id/4756
0 Kudos
Message 3 of 15
(4,097 Views)
I forgot the VI'S.
Download All
0 Kudos
Message 4 of 15
(4,085 Views)

Just start with the MB Serial Master Example available in the NI VI's for download.

 

Does the device have any software it provides to communicate with it?  If so, make sure you can communicate using that.  Baud rate, parity,stop bits, using null modem vs. straight through cable, are all important.  Know what the slave address number is assigned for that device.  See if there are any settings you program through the front panel of the device to determine the communication method.  It might have different options like ANSI, RTU, other proprietary methods.

 

Read the communication manual that it has.  Register numbers, command codes are important.

 

Do this with the NI VI.  Don't mess with any global variables yet.  So far with what you've posted (and some VI's still aren't able to be opened), I don't see any reason to break up the VI's and use global variables yet.

 

If you run into issues, post that VI along with any error messages (including error numbers) that you may get.

 

PS.  Keep the communication in one thread, this one since it is your original and has most of the information.

Message Edited by Ravens Fan on 05-27-2009 01:54 PM
0 Kudos
Message 5 of 15
(4,064 Views)
Were you able to see the modbus Vi from the zip files? I have the gloabals in the modbus VI.
0 Kudos
Message 6 of 15
(4,052 Views)

I have attached a BMP to show the (5 ) globals that are in the Modbus VI. Numeric 1,2,3 are OK. It is the DATA "in blue" and the REGISTER "in purple". I am having problems withe data and the register.

 

Thanks

 

 

Philip

0 Kudos
Message 7 of 15
(4,049 Views)

You're 3 numerics should be U16, U16, and U8 respectively to eliminate the coercion dots.  They should have more descriptive names than numeric.  Rather than having different variables for each, make the cluster the only variable in the global variable.

 

You still haven't explained what problems you are having iwth the data and the registers.  What registers are you trying to read/write to?  Do you have a copy of the communications manual you can post or link to?  Save your VI with the actual data you are trying to use saved as defaults so we can see how you are setting them up.

 

Rather than worrying about writing, just start with trying to read a valid register to begin with.

0 Kudos
Message 8 of 15
(4,042 Views)

I can set the values and read back by manualy setting the "Write to Register, etc" by passing a numeric value. Type the value in the modbus VI.

 

I am trying to send global varibles from my GUI to set the temperature and then monitor the temperature on a strip chart recorder. Read temperature is 300. Section 7.2 communications is the part on the modbus registers.

 

Thanks

 

 

Philip

0 Kudos
Message 9 of 15
(4,039 Views)

So your modbus communication is working correctly?

 

I'm not sure which VI is your GUI.  Or how the MB Interface Choice vs. Temperature System Demo fit together.  Or how the Globals tangle things up.  Or how temperature status fits in.

 

Which VI is your main front panel?

0 Kudos
Message 10 of 15
(4,035 Views)