LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Entering Negative values in MODBUS command

The code snippet used below is used to write RPM values to a Variable Frequency Drive over the MODBUS RTU - RS485 Communication Bus. 

 

Works OK for CW rpm as the value written is 0 to +5000 for a speed of 0 to 1450 rpm.

 

But communication fails when I try to enter negative values for RPM and I get a time out error.  As I can see LV converts the negative RPM values to corresponding HEX using 2's complement method and processes the command.  But though the drive manual says to write negative values to get CCW rpm, not sure why it fails. 

 

If there anything wrong in the code snippet ? 

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

Hi Moga,

 


@MogaRaghu wrote:

If there anything wrong in the code snippet ? 


How should we know when you don't supply information on your VFD…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 19
(2,330 Views)

Oh ... sorry. 

 

Attaching the document which my vendor gave me. No need to waste time on whole document - chapter 8 has all sample codes for 16bit / 32 bit Read and Write. 

 

Of course nowhere it mentions about negative value as parameter but that is an information from supplier who says its done like that in PLC based control systems. 

 

Thanks

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 19
(2,265 Views)

Hi Moga,

 


@MogaRaghu wrote:

Attaching the document which my vendor gave me. No need to waste time on whole document - chapter 8 has all sample codes for 16bit / 32 bit Read and Write. 


Thanks for the manual!

 


@MogaRaghu wrote:

But communication fails when I try to enter negative values for RPM and I get a time out error.


Did you read chapter 6.5? It explains the responses of the VFD!

When you send a request, but don't get a response, then there are two possible reasons given in this chapter.

I guess it's the 3rd item in this list which applies here…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 19
(2,256 Views)

@GerdW

 

Thanks

 

Yes I also saw that and possibly the main issue is with the command string formatting.  Will look into why.  Maybe I will try to use the Plasmionique  Modbus master VIs instead of the simple VI snippets that I now use and see if there is any improvement. 

 

As to  the third entry it says in the failed case I dont get a response. It makes trouble shooting that much more tough.  When the going gets tough, the tough get going. So....

 

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

I am trying to control a Nidec drive over Modbus RTU.

 

All required commands and address have been validated using ModScan 32 app.  Working well. 

 

Tried to use the same parameters in a simple VI. But so far i have been met with only Illegal Address / Comm Time out / Undefined errors. 

 

This same setup works with a Bonfiglioli drive with only change in address and command values.  SO this means basically nothing wrong with the code.

 

Just wanted to know if there are any tools to capture the actual data transaction between the PC and drive.... I can atleast compare both data transactions when using Modscan32 and then my LV Code. 

 

Any pointers to solution welcome. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 6 of 19
(2,207 Views)

You wrote the value of 40642 as your register.  That doesn't work in Modbus.  The actual register address is 641.  You need to strip the prefix of 4 and subtract 1.

 

Modbus annoying classifies the different groups of registers with a prefix number (3 for input registers, 4 for holding registers, 1 for discrete inputs, and to just confuse things more, 0 or basically "nothing" for coils.)  And to add more confusing, when they use the numbering scheme with prefixes, they start at 1.  But the actual registers are 0-based like pretty much anything in the computer world.

 

Take a look at this link I found to try to remember the prefix for the coils and discrete inputs.  It does a decent job of explaining it.

 

And why aren't you using the Modbus libraries for LabVIEW you can find in VI Package Manager?

Message 7 of 19
(2,193 Views)

@Ravens

 

Please attach the mentioned link for recalling the prefix for coils etc

 

Also I did a traffic capture for the following setup :

Device ID : 0x01

Function code : 0x03

Address : 642 

Command word : 449 

 

As you can see from the attached image of capture, I am able to identify above in different parts of the capture. But cannot correlate with what is group that goes from PC to VFD and what comes from VFD to PC. I think if this is clear then I can modify my code to generate in line with same.

 

Thanks for your support !!

 

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

I don't completely understand your question.

 

The part in grey is from the PC to the VFD.

Slave Address 1

Function code 3  (Read Holding Registers)

Starting address:  0281x  is 641 decimal.   So that would be 40642.  It seems like your modscan32 software took the 0642 you entered (basically and subtracted the 1 for you).  Since the prefix of 4 (for holding registers) 3 (for input registers), 0 (for coils), and 1 (for discrete inputs) when you look at the full 1-based address you often find in manuals for modbus never actually is transferred into the real message with the 0-based address, it just gets dropped.  Interesting enough, the manual you attached earlier never mentions them.  It just gives you the basic non-prefixed, 0-based address.

Length of 1 address

Last two bytes are checksum.

 

The part in black is the response from the VFD to the PC.

Slave Address 1

Function code 3  (Read Holding Registers)

2 data bytes coming

Data:  01C1x  is a decimal value of 449

Last two bytes are checksum

 

Unfortunately, in the manual you attached earlier, I could not find any definition of what address 641 (0-based) or 40642 (prefixed, 1-based) holding register is supposed to be.  Or even what 642(0-based) or 40643 (prefixed, 1-based) means, if that is what you were trying for.

 

Here is what your it would look like in LabVIEW using an older Modbus library that I like the best and the same parameters your Modscan screenshot is doing.

Note: this only runs on 1 time.  You can add to this to make it run in a loop.

 

 

0 Kudos
Message 9 of 19
(2,159 Views)

The part in grey is from PC to  VFD  and so should contain the following :

 

Device address

Function Code

Starting Param Address

Number of registers

Command word

CRC

 

My query was on the absence of the command word from the real time trace - without this how does the VFD know what I intend to tell it to do ? 

 

With regard to the Modbus library I see only the Plasmionique Modbus Master  and the NI Modbus Library in the VIPM browser. Where do you get the one you developed the snippet on ? I have seen this earlier but not sure if its still around ...

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 10 of 19
(2,141 Views)