LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

modbus RTU protocol datatypes

Solved!
Go to solution

Hai, madam

 

I need to read the data from CONZERV EM6400 DigitAN power meter which communicates through RS 485 port via the Modbus RTU protocol. I have never worked on this protocol. Can you please help me how to proceed with following information in hand using LabView 8.0

 

This is the information got from the manual.

- RS 485 port Modbus RTU protocol.

- Data are in 32 bit format (Two registers holds a single data value).

- Each modbus register size is 16 bits.

 

I using RS-485 to RS-232 converter.

 

Thanks,

 

 

0 Kudos
Message 31 of 58
(4,312 Views)

Hello ,

           I am sending u one attachment see it and try same.just change  starting address in modbus command and device id of energy meter in serial parameters control.

0 Kudos
Message 32 of 58
(4,288 Views)

Thanks for your replay,

 

I tried with the vi which you have sent to me. I am getting Timeout error.I am attaching the vi with this message and tell me where i am going wrong.

 

Is there any offset register to be given in labview? i need to read only 2 registers and the start address specified in the command is exactly the value specified in the register map no offset is added.

 

Thanks,

Download All
0 Kudos
Message 33 of 58
(4,255 Views)

When you send the Modbus address, you do not include the 4 at the beginning that indicates it is a hold register.  So instead of 43923, use 3923.  Also try 3922 as sometimes the LV registers are zero based while the Modbus register in the device would begin at 1.

0 Kudos
Message 34 of 58
(4,249 Views)

Hello Dear,

                   i have made some changes in your Vi.u should change 43923 to 3923 and starting address start from 20.now i think its work.

0 Kudos
Message 35 of 58
(4,243 Views)
Twenty is not the starting address, it is the number of addresses to read. And he said he only wanted to read two addresses.
0 Kudos
Message 36 of 58
(4,238 Views)

Hai,

 

As attachemnt is in higher version i am not able to download could please post it in LabView 8.0.

 

 

Thanks,

0 Kudos
Message 37 of 58
(4,234 Views)
hello,i am attaching png file.change your starting address as per your requirement
0 Kudos
Message 38 of 58
(4,232 Views)

Hai,Shubhlaxmi and Ravens

 

 I did the changes as suggested by you but i am getting the same error.

 

This is my connections.Computer----USB to RS-232 converter----Isolated RS-232 to RS-485/422 converter (Transio A53 MOXA)----Power meter.Txd of Isolated RS-232 to RS-485/422 converter is connected to + of the power meter.Rxd of Isolated RS-232 to RS-485/422 converter is connected to - of the powermeter.

 

ObservationsI run the program wth highlight excecution to see the  souce of error. 

Error started in MB Serial Init.vi  with code 1073676294 at VISA Read in MB Serial Init.vi when this error flows to MB Serial Master query.vi program endsup with timeout error having code 6101.

When i run the program i can see that Txd,CTS and RTS leds in the converter blinks. Then i think whatever i am sending from my computer it is reaching the powermeter.

 

Thanks,
0 Kudos
Message 39 of 58
(4,164 Views)

Actually what you have shown is not an error but a warning.  It has a postive error number and the status is an OK check mark.  It is a warning saying you received exactly as many bytes as you asked for, and more may be available.  It is occurring in the MB serial Init VI.

 

Now that MB Serial Init VI does something that's good, then a couple things that are pointless.  I think this was a poorly written VI.  First it sets all the settings for the serial port, baud rate, parity, timeout, termination character.  That is all good.  Then it proceeds to determine how many ports are in the receive buffer than proceeds to read them and do nothing with them.  This effectively flushes the receive buffer.  That is where the warning is being generated.  It reads exactly as many bytes as are in the buffer.  It should probably just tell it to clear this specific warning/error because it is meaningless, but instead it just passes it on.  Then the VI proceeds to forcefully flush transmit and receive buffers.  While this is okay in theory, why did it bother reading the data in the receive buffer.  It does nothing with it, and proceeds to flush it anyway.

 

I recommend that you don't use the MB Serial Init VI at all.  Just use the Serial Config VI that is part of the normal VISA Serial palette.  Looking back at some of my Modbus code, I don't think I ever used that Serial Init VI.  I can't remember if I tried and came across the same issue or not.  I either used the Serial Config VI, or just went with the serial port settings that I hard coded in either MAX or windows.

 

Get rid of the MB Serial Init VI, use the Serial Config VI and try again.

 

I don't know if this will actually solve your 6101 error.  From what I can see, it shouldn't be causing it.  It looks like the 6101 error code is originated from the subVI MB Serial String to MB Data Unit within MB R (which is a part of MB WR) .  The 6 seems to be a digit that LabVIEW itself added on to a 101 error from the Modbus Exception Code.  I looked on Modbus.org http://www.modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf and couldn't find a 101 error.  There is a 1 error which means Illegal Function.   Looking at your screenshot in, I don't even know how you got the description Timeout Error, because the MB Serial String to MB Data Unit would return the exception code as MODBUS Exeption Code: 6101.

 

As for your hardware setup, there are a lot of connections going on going USB to RS-232 to RS-485 back to RS-232.  I would recommend getting a USB to 485 converter to eliminate one extra device.

 

Also,  why are you still trying to read 20 addresses?  I thought you originally said you only wanted to read 2 addresses.  And double check your starting address because originally you wanted 43293 and now you are starting at 43007 (give or take 1).

Message Edited by Ravens Fan on 02-13-2009 12:23 AM
0 Kudos
Message 40 of 58
(4,149 Views)