LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus TCP with Beckhoff (Wago)

Hi Unclebump, I don't have those details yet!
Is there a reason for concern?  
0 Kudos
Message 11 of 23
(5,978 Views)

A single modbus command is limited to about 100 registers at a time. It helps to read blocks of data at one time. 100 registers in a row can be read faster than 10 groups of ten registers spread out all over the place. Here is a thread with the modbus protocol guide.

http://forums.ni.com/ni/board/message?board.id=170&message.id=197677&query.id=44668#M197677

0 Kudos
Message 12 of 23
(5,956 Views)
Hi, I have a setup using ModbusTCP with a Beckhoff BC9000 and a KL2712 Module
and of course the famous NI modbus Library which the help documentation is very limited.
 
How can I read Blocks of registers using labview Library as you describe below?
I played around with the library and it seems like the Command VI (control) allows you to read or write 9 registers is this correct? 
Is this consider a Block?
 
Why does LabView subtract 1 to the address? I had to use 16384 to read modbus address 16385
is this right?
 
According to a programmer he programmed in a real number (251.741) into registers 16385 and 16386
making it a 32 bit. I understand in labview the registers are U16 integers, this is where I had to use the starting address as 16384 and a quantity of 2 , but the result was a number that did not make sense, of course I was reading each register individually  is it possible to put both registers together and display it as a real number and if so how is done? By the way he used TwinCat. 
 
What is the exception code input in the master query VI? I was not able to write to an input register
an error was given, it had something  to do with this code.
 
Thanks for any help  
0 Kudos
Message 13 of 23
(5,899 Views)
To read blocks of registers you should set the quantity value to the size that you need. In the modbus command control block, the field just after the starting address determines how much data to read.  Max is around 100-125 16 bit holding registers. If you need more data than that, you will have to implement multiple reads in a loop structure.
 
Some modbus devices use zero based addressing. Plc's say that the first holding register is 40001, other devices say it is 40000. Kind of like labview using 0 for the first array index.
 
Your labview code will have to convert the two 16 bit registers into a floating point number. I know there are examples on the forums for doing this conversion. I think they used typecasting.
 
The exception code is returned by the modbus device when an error is present. Maybe trying to write to an illegal address, or read a range that does not exist. Google modbus exception codes for more info.
 
download the modbus protocol guide pdf file in this thread.
0 Kudos
Message 14 of 23
(5,887 Views)
Hi I'm having trouble writing digital (discrete) values from the modbus command control block.
For example a bit in a register was defined as boolean  (%MX4.0, Bit 0 at %MB4) This corresponds to modbus address 416387 
(16386 in LabView). I can turn the bit on if a write a UI16 byte for example 1 or  65535. I would like to turn the bit on using the dicrete input
but I always get an error I'm not sure what I'm doing wrong.
0 Kudos
Message 15 of 23
(5,852 Views)
A register beginning with a 4  (40,000 or 400,000 series) is a holding register, not a discrete input or coil.  So it has a U16  value, not a boolean.
 
 
0 Kudos
Message 16 of 23
(5,847 Views)
Hi I understand, how does labview address registers containing coils or discrete (digital lines)
can you give an example ?
 
Thanks
0 Kudos
Message 17 of 23
(5,844 Views)

You would select the function code for coils and address it as 0-based, but they will be the registers in the 00000 series.  Use function code 1 to read and 5 to write a single coil or  15 to write multiple.

For discrete inputs, you can only read them.  They are in the 10000 series and are also zero based.  Use function code 2 to read them.

The device will know which bank of registers to address 0 series 10000 series  30000 series  40000 series, based on which function code you are sending to read or write.

0 Kudos
Message 18 of 23
(5,840 Views)
It will depend on what modbus function codes your device supports. Function code 22 is a Mask write to a holding register.
0 Kudos
Message 19 of 23
(5,836 Views)
Hi, I believe the modbus device supports the following codes: 1 2 3 4 5 6 8 15 16 and 23
8 being Diagnostics and 23 Write and read a number of process data outputs the rest are standard modbus codes. I don't think the  LabView modbus Library support code 23 nor 8.
 
 
0 Kudos
Message 20 of 23
(5,832 Views)