LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I can't write holding registers

Solved!
Go to solution
hay My program mast visualize some data of a controller. This with an Ethernet connection. I can read everything and I can write coils bet I cant write the holding registers. I hope someone can help? Heir my VI: Rutte
0 Kudos
Message 1 of 5
(3,345 Views)

Ouch!  Multiple nested stacked sequence structures make it impossible to figure out what is going on.  I am attaching a version of your code where the stacked sequences were converted to flat, then the block diagram was cleaned up.  You should try to use this and work further to clean up the code.

 

I only saw one place where it looked like you were writing to holding registers and it seems to be towards the center of the attached VI.  You are writing to multiple registers, but you are sending an array of 7 numeric doubles to the data element of the Modbus cluster.  This data is being coerced into an U16, and probably only 7 values as well in that array.

 

What you need to do is figure out what type of data you want to send.  Does each value go into 2 consecutive modbus registers?  How do you want to convert from a double representation (which is 8 bytes of data) to two registers of U16 (2 bytes + 2 bytes)?  If you use the right combination of typecast and split/join numbers, then you should be able to go from 7 doubles (perhaps you really want singles? at 4 bytes per) to 14 U16's.

0 Kudos
Message 2 of 5
(3,316 Views)
Thanks for the Flat sequences tip. And for clean up my mess JI think the data must be 16 bit integer because I can read it with 16 bit integer.I also think that the values must fit into 2 consecutive modbus registers. Because when I read it fits. Now I have typecast the data ant I have convert it to I16. bet it didn’t work.

What do you mien with split/join numbers?

 

  
0 Kudos
Message 3 of 5
(3,296 Views)
Solution
Accepted by topic author Modbus probleem

With split or join numbers located in the numeric / data manipulation palette, you can take two U8's and join them into a single U16 (and vice versa using split).  And you can take two U16's and join them into a single U32.

 

Take a look at the attached subVI I made.  It was a wrapper for the Modbus VI functions so that I could use enums to read or write specific registers by name and handle the data manipulation accordingly.  It may call for a couple of typedef's I created for my particular application, but that shouldn't keep you from seeing the structure and how I did the data manipulation using the split and join functions.

0 Kudos
Message 4 of 5
(3,270 Views)
Thanks, My problem is solved. I can write the holding registers!! Thanks for helping me
0 Kudos
Message 5 of 5
(3,246 Views)