LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VFD Drive - Modbus TCP - Unable to read

Solved!
Go to solution

The image below shows a successful communication over TCP between my laptop and a VFD drive.  The software used is  ModScan32 . I have underlined the Request from PC in blue and response from VFD in red. ( ignore the header bytes ) 

Modscan_OK_Comm.jpg

 

I am trying to send the same byte string via a simple LV TCP session. The link up is OK and the Send also is OK.  Only the VFD does not respond and remains silent meaning it has got a junk request . Not sure where is this failing. Is there any LV tool that can show the TCP packets both ways or I will have to use a sniffer like WireShark ?  ( You can see the raw hex string that is generated matching with the blue underlined string above ) 

 

LV Session.jpg

 

Also enclosing the simple VI I created for this .  Though the User Manual does not need a delay between Request and Response I have provided one ... just in case I need it. But nothing from 0 to 50ms seems to help anyway. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 9
(2,996 Views)

@MogaRaghu wrote:

 ( ignore the header bytes ) 

 



Why are you ignoring the header bytes?  That's the MBAP header and it needs to be sent.

 

Also, is there a reason you're making your own MODBUS VI instead of using one of the like 3 free versions already available for LabVIEW?

Message 2 of 9
(2,987 Views)

I recommend you try using Plasmonique Modbus

0 Kudos
Message 3 of 9
(2,959 Views)

Why are you ignoring the header bytes?  That's the MBAP header and it needs to be sent.

 

😄 Not in the way my wordings convey !  I was under the impression that if I use a TCP - Write and TCP-Read functions , the header will happen in background anyway and I only need to focus on building my data packet. 

 

If the above is not the case then these functions cannot be used as I have no clue on what the MBAP header is. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 4 of 9
(2,934 Views)

@drjdpowell

 

Good  suggestion.  

 

There is a catch though.  For some odd ( or  sadistic ? ) reason Bonfiglioli have implemented 32 Bit Read and Write Modbus functions : 100 and 101.  Thus I am unable to use any standard library for Modbus that is available for LV.  In my applications I need to use the functions 3, 6, 100, 101.  And if I need to use any standard library I need to tweak them. 

 

Reason why I am struggling with the  home brewn sub VIs. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 5 of 9
(2,931 Views)

@MogaRaghu wrote:

Why are you ignoring the header bytes?  That's the MBAP header and it needs to be sent.

 

😄 Not in the way my wordings convey !  I was under the impression that if I use a TCP - Write and TCP-Read functions , the header will happen in background anyway and I only need to focus on building my data packet. 

 

If the above is not the case then these functions cannot be used as I have no clue on what the MBAP header is. 


The TCP write function takes care of the TCP header, i.e. what IP address it gets sent to, where it is coming from, all of that stuff.

 

The MBAP header is still your responsibility to send.

 

You can see some details here:

https://devicebase.net/en/schneider-electric-modbus-tcp/questions/what-is-a-mbap-header-and-what-is-...

 

Basically, it's 7 bytes:

2 to identify the request ID (in case the messages are received or replied to out of order)

2 to identify the protocol (always 00 00 for MODBUS)

2 for the length of the message  (INCLUDING the one remaining header byte not sent yet)

1 for the unit ID

 

In your snooped message it is these bytes:

Kyle97330_0-1652889265218.png

0100 for the request ID

0000 for the protocol

0006 for the length (the 1 unit ID byte plus the 5 in the message after)

01 for the unit ID

 

The remaining 5 bytes 03 01 72 00 01 is the remainder which you already have sorted out.

 

The Plasmonique Modbus linked up earlier is one of the 3 LabVIEW toolkits that I mentioned that you probably would want to use to avoid doing this all yourself.  There's also a NI MODBUS library that's new, and then a much older NI library (like, from 2009-ish?) which I am attaching to this post as I can't find an active download link for it.  It has the least "modern" features but it's also the most lightweight, which appeals to some (like myself).

 

Message 6 of 9
(2,905 Views)

There is a Github repo for the NI Modbus library. I believe the VI's in the repo are unlocked.

 

https://github.com/NISystemsEngineering/LabVIEW-Modbus-API 

Message 7 of 9
(2,892 Views)
Solution
Accepted by topic author MogaRaghu

Tried the Plasmionique library.  It works fine for function 3 and 6. But for  function 16 ( for 32 byte read / write )  it fails as it needs two inputs : Address and Byte Array.  For the Bonfig VFD, the function 16 requires the address as part of the Byte Array.  So it gets messed up. 

 

Anyway created a VI  following the exact byte structure as given in the User Manual and it works .  The same is attached herewith. In the process I learned how to create the MBAP header 😀 ( the attached code shows the transaction byte as a constant but in actual code will auto increment it ) 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 8 of 9
(2,871 Views)

Hello,  enter this link that performs the modbus communication with frequency inverter

 

https://www.youtube.com/watch?v=Omc3G62uFoA 

0 Kudos
Message 9 of 9
(2,613 Views)