05-17-2022 11:12 AM
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 )
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 )
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.
Solved! Go to Solution.
05-17-2022 11:33 AM
@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?
05-17-2022 12:58 PM
I recommend you try using Plasmonique Modbus
05-18-2022 12:33 AM
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.
05-18-2022 12:42 AM
@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.
05-18-2022 11:06 AM
@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:
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:
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).
05-18-2022 05:35 PM
There is a Github repo for the NI Modbus library. I believe the VI's in the repo are unlocked.
05-20-2022 11:03 AM
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 )
10-15-2022 11:32 AM
Hello, enter this link that performs the modbus communication with frequency inverter