LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

MODBUS - writing a value and reading other value

Hi Guys,

 

I am here again, my issue it is pretty simple, but I am not getting a solution. 

I did a supervispory to control two servo motors by Modbus protocol and the labview is working rightly with the PLC, but there is something that I did not get configure well. 

 

I am using the modbus address  - 404097, when I write some values till a certain number it is equal, but when I write a value big that certain number the labview sends a number with the value minor and when I up more the number more the labview send a number with the value minor. How can I fix it?

 

I took some pictures to show

 

I tested the PLC with the high values and worked correctly.  



Regards

 

 

Download All
0 Kudos
Message 1 of 8
(3,862 Views)

What does "value minor" mean?

 

A register is a U16.  That mean it can take a value from 0 to 65535.

 

I can't tell how "Delocmento" compares to the modbus register as the terminal is just sitting on the diagram.  I don't know how you have the register 404097 configured in your library.  It is odd that both your control and indicator are double floating point while the modbus register is obviously an integer.

 

But I think if that 100,000 number is what you are trying to write.  But it is rolling over or something since it is larger than what a U16 can handle.

Also, make sure you use datatype that match the properties of the register.

 

If you take 100,000 and subtract 65536 (the value of 2^16), you'll get 34,464.  Wow!  That is the number you have in the last picture.🤓

 

You need to look at the manual for your device to see what range of values you can actually write to your 404097 register.

 

 

0 Kudos
Message 2 of 8
(3,852 Views)

RavensFan has said most of what I would want to have said.

 

One thing he didn't mention that I will is that if you can check your manual, it's possible that there's a MODBUS address 1 higher or 1 lower where you can store the higher bits of the number.  If you can find if that address exists, and then write a "1" to it and "34464" to the address you're using now, it might interpret that as the 100,000 you're trying to use.

 

If there's a register named "value major" there's a good chance that's it, since you refer to "value minor".

0 Kudos
Message 3 of 8
(3,843 Views)

Kyle has some good points.

 

"Value major" "value minor" aren't phrases I've heard of before.  IN Modbus, if you are using pairs of registers, they will be referred to as "Most Significant Word" and "Least Significant Word".

 

And if you are working with 2 registers, are they spelled out in the manual  (I hope you have read the manual!) as representing a U32 integer or a single precision or 32-bit floating point number?

0 Kudos
Message 4 of 8
(3,834 Views)

Hi,

 

Most times if I see a ModBus address as 404097 I read this as a DCS like address.

What it actually says is use ModBus command 4 (read register) with address 4097 - 1. (This is address 0x1000 in hexadecimal)

 

Beside that 404097 is beyond the 16 bit boundary of (standard)  ModBus.

 

Kees

0 Kudos
Message 5 of 8
(3,779 Views)

Hi Guys,

 

Sorry for my mistake, English is not my native language and I do not know all technical words for some situations, but I am good learner.

 

So, "value minor" means  small number. 

 

Before I ask for a help here, I changed the register to  Int32, because I want to write negative number too and it takes -2147483648 to 2147483648.

 

The register 404097 is the modbus address in decimal converted from hexadecimal. The first number 4 is the modbus code which means write/read register. And the number 04097 is the modbus address where I will recieve (or send) datas from (to) some device where I will put (read) a number.

 

I have already read the manual device before and the problem it was not in the range of the values. 

 

I got a solution using another way inside PLC program. I used the same registers in the PLC that I was trying to write with the labview.

0 Kudos
Message 6 of 8
(3,729 Views)

Exactly, Kees. 

 

You are right about the modbus code.

0 Kudos
Message 7 of 8
(3,728 Views)

@K C wrote:

Hi,

 

Most times if I see a ModBus address as 404097 I read this as a DCS like address.

What it actually says is use ModBus command 4 (read register) with address 4097 - 1. (This is address 0x1000 in hexadecimal)

 

Beside that 404097 is beyond the 16 bit boundary of (standard)  ModBus.

 

Kees


True, but it also depends on the way the device is being addressed.  If this was one of the Modbus libraries running as LabVIEW subVI's, then yes, you drop the 4, subtract 1, and would wire 4096 to the address terminal of the subVI.  And if this is truly a pair of registers, then you'd wire a quantity of 2.

 

In this screen shot, it is a networked shared variable.  We don't have any LabVIEW code or project attached (just pictures 😬) so we don't know how the variable is configured.  I can't remember if using libraries and variables to talk to a Modbus device is a feature of the DSC module, or something built into regular LabVIEW.  Honestly, I've used that probalby once to experiment, but otherwise use LabVIEW itself to communicate with my Modbus devices.  But it is very possible that the library wants the full address name. and you'd configure it has 404097, and the underlying network communication will convert it to 4096 in the raw bytes of the communication (whether serial or TCP/IP, and the information from the original poster doesn't even tell us that!

 

So 404097 may not be a problem in that picture.  But there most certainly is a problem if the OP expects a single register to handle a number larger than 65535.

0 Kudos
Message 8 of 8
(3,717 Views)