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: 

Do serial modbus commands need to be converted?

I am trying to write new register values to my Direct Logic 205 PLC through a VI using a modbus command from the NI modbus library.  The Com port and PLC are communicating and I am able to change the register values at the location specified.  However, my data field is not cooperating with me in way that I can input the desired value into it and write it to the register.  The increment/decrement button indicates that there may be some sort of conversion that needs to take place that I am not aware of.  Could you look at the sample VI I've attached and offer advice? When I increase the value to above 10-15, the data field and actual register value indicator shows a "0" is being written to the register.
 
I would like to be able to write the value I put in the data field directly to the PLC register.    Is there a way to do this?
 
Also, as I develop the full blown VI to write parameter values to my PLC I will need to write to multiple registers.  Is there a way to do this other than using several modbus command queries for each item?
 
Thanks for the help!
Jim
 
0 Kudos
Message 1 of 6
(2,695 Views)

Okay...I removed the number to hex function and dec. str. to number function from my read sequence and it is working like I need it to work.  However, can someone let me know if it is possible to enter/write multiple registers from one modbus command?  Use an array or something?

Thanks!

Jim

 

0 Kudos
Message 2 of 6
(2,682 Views)


@jdover wrote:

....  However, can someone let me know if it is possible to enter/write multiple registers from one modbus command?  Use an array or something?



Take a look at the Modbus Command cluster in your VI .... one of the choices for the function code is  Write Multiple Registers ... and Data is an U16 array.  I've used it with DL205 and 305 PLCs.

Good luck.

Message Edited by Donald on 05-25-2007 03:24 PM

=====================================================
Fading out. " ... J. Arthur Rank on gong."
0 Kudos
Message 3 of 6
(2,676 Views)

Donald,

Thanks for the help.  When I change the selection to Write Multiple Registers, do the array elements in the numeric field correspond with the register values?  For example, does element 1 write into the starting register address, does element 2 write to the the next register address, etc? 

Also, I need some of these element values to be user-defined when I run the VI and I'm not sure how to connect a control to each element...(other than using an individual command for each value and simply using a single command for each input.)  I've attached the current version that does this but I'm thinking there is a better way to write this code to make it more efficient.

Any ideas?

Thanks!

Jim

 

0 Kudos
Message 4 of 6
(2,668 Views)
jdover wrote:

...  For example, does element 1 write into the starting register address, does element 2 write to the the next register address, etc? 

Yes. 

Also, I need some of these element values to be user-defined when I run the VI and I'm not sure how to connect a control to each element...(other than using an individual command for each value and simply using a single command for each input.)  I've attached the current version that does this but I'm thinking there is a better way to write this code to make it more efficient.

In the end, you need to send an array of U16 to your registers.  There are a lot of ways to present the user with means to enter values for your setpoints, etc.   I tend to use clusters and convert to an array as req'd.  A (very) quick and dirty example is attached.

=====================================================
Fading out. " ... J. Arthur Rank on gong."
Message 5 of 6
(2,660 Views)

Donald,

Thanks for the example.  Your solution is MUCH simpler than what I came up with in the meantime.  I will use it in the future.

Thanks very much!

Jim

 

0 Kudos
Message 6 of 6
(2,577 Views)