Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus (RS485) and Automation Direct GS2 Example

Solved!
Go to solution

I am looking to see if anyone has used the Automation Direct GS2 Drive and LabView and has a workign VI? I have been looking over Modbus over RS485 that the GS2 uses and I have looked at the Modbus .vi library. Correlating all that into one cohesive thought seems to be escaping me. I am new to LabView and never seen Modbus before and I have a very short schedule to get something going. Even if all the .vi did was start and stop the motor I would be happy. Then I could work the rest out.

 

 

GS2 Manuals

 

 

0 Kudos
Message 1 of 13
(8,687 Views)

Hello MTEng,

 

Unfortunately, as I am sure you have found by now there does not seem to be any examples of using Modbus to communicate to an Automation Direct GS2 Drive in LabVIEW. However, you may still connect to this device through LabVIEW by using the Modbus protocol and either an NI I/O server or the free Modbus library for LabVIEW. If you happen to have access to the LabVIEW Datalogging and Supervisory Control toolkit (DSC), this process will be a fairly simple connection via the I/O server installed by this module and binding Shared Variables to Modbus addresses as is shown in the "Connect LabVIEW to Any PLC with Modbus" link below. However, if you do not have access to an I/O server either through LabVIEW DSC or LabVIEW Real-Time, you may then use the free Modbus Library for LabVIEW to establish this connection. As I believe you may have already found this library, these VI's can be used as a basis for the connection to your device via Modbus however as these VI's are simply a wrapper for lower level VISA commands, programming with this library will require some knowledge of Modbus function calls (although it seems that the Modbus library available not only includes VI's but examples as well) and is not as easy to set up as the Modbus I/O server provided with the DSC Module. I have included a number of links below that may assist you in getting started with this programming but please note that the free Modbus Library is not an official product of National Instruments and may not be supported as such. 

 

http://www.ni.com/white-paper/7675/en (Introduction to Modbus) 

 

http://www.ni.com/white-paper/13911/en (Connection LabVIEW to Any PLC With Modbus) 

 

http://zone.ni.com/devzone/cda/epd/p/id/4756 (Modbus Library for LabVIEW)

 

http://www.ni.com/white-paper/4722/en#toc2 (Using the Modbus Library in LabVIEW (Serial Focused))

Wes W
Application Engineering
National Instruments
www.ni.com/support
0 Kudos
Message 2 of 13
(8,658 Views)

I have read all of those but I have not been able to get from those and then translated into a way to communicate to the GS2. Automation Direct provides free software to run the drive which I have used to confirm that my port setup is correct and that the PC can talk with the drive. However, using the modbus library or creating my own labview library to talk to the drive has proven to be unfruitful. I know that address of the run stop command is hex: 091B, Modbus Decimal: 42332 or Octal 4433. 0 for stop and 1 for run. But how that information converts into a Modbus serial string???? Just not seeing this.

 

I don't want to spend more money on the DSC module ($2500) We have spent almost $10K for LabView Developer and a DAQ. More money to run a $100 drive does not make fiscal sense. I can see from discussions it must be possible with what I have. I just am not seeing it. USB to PIC easy RS-485 Modbus not so obvious.

0 Kudos
Message 3 of 13
(8,649 Views)

Hi,

 

First you have to understand that RS-485 and ModBus are two completely different things.

 

RS-485 is a hardware interface. Just like RS-232, Ethernet, water plumbing

 

ModBus is a (software) protocol. This protocol send data packets over an interface.

 

 

Did you downloaded the LV ModBus library ? Try to understand the function of that library that you need.

Another possibility is to construct the ModBus commands yourself.

 

 

Kees

0 Kudos
Message 4 of 13
(8,641 Views)

Yup I understand RS485 and Modbus are different. Not understanding Modbus terminology and how it correlates to GS2 drive. How using the Modbus VI's I could send a run command to drive.

0 Kudos
Message 5 of 13
(8,638 Views)

ModBus commands are written in different ways in manuals. If I look at the GS2 manual you on page 5-9 the request for the firmwarelevel. Simple command to start with.

 

 

Description                Hexadecimal    Modbus Decimal     Octal

Firmware Version            2110                 48465               20420

 

The decimal part tells you that you should use command 4 (the first figure) and that the ModBus address for the firmware version is 8465 (decimal)

The decimal addresses are the hexadecimal address + 1

 

So to get the firmware version perform a read register (command 4) at hex add. 2110.

 

Let me know if you do this with the MB VI's from the NI MB lib.

 

I also can give you a VI that uses the MB loopback command to test the communication. But I cannot find a list with supported commands. But I also don't want to read all these manuals. That is something that you already did  Smiley Wink

 

 

 

Kees

 

 

 

Message 6 of 13
(8,626 Views)

That was a better explanation then the other info I was looking at as far as address and commands. I at least have the drive displaying an error. Smiley Happy Yesterday it just sat there and showed 00 on the drive display. Sometimes it is the little victories. I am also getting error codes back from the drive which is some sign of life, the drive displays error 03 and my vi displays a 03 when it errors out.

 

From the manual:

error 03: Communications Warning: Illegal data value - The data value received in the command message is not available for AC drive.

 

But now for the continuing headaches.

I have tried to read the firmware version using the command/address you talked about with no success. I guess I would be even happy with that to work. The vi does not accept an address of 091B (run) it will not accept the "B" of the hex number.

 

So for run:

Description                Hexadecimal    Modbus Decimal     Octal

Serial Com Run               091B                 42332                      4433

 

This implies a Read Input Register command 4 to Hex address 091B? Looking at the Modbus intro I see the code 4 in table 2 aka the read Input register. I would say that is just to read the status of the run register. 00-Stop, 01-Run. So what does that corespond to writing to the register 62332?

 

 

0 Kudos
Message 7 of 13
(8,615 Views)
Solution
Accepted by topic author MTEng

Figured it out finally. I have attached two VI's. One to read registers and one to write to registers with notes on how to stop and start drive.

 

Thanks for the help.

Download All
Message 8 of 13
(8,602 Views)

Can you compile those to LV 11 by any chance??

0 Kudos
Message 9 of 13
(7,453 Views)

I realize this is an old post, but I'm trying to do the exact same thing and I'm struggling to get the same Run Stop functionality.   I have checked my dip switches on the GS2 and I believe my RS485 cable is connected correctly.  If I go inside the MODBUS library and pull out the string (with slash codes) that is being sent to the GS2 with the VISA write I see ":0106091B0001D4\r\n" I believe that is correct based on the GS2 manual Chapter 5-32 (see Capture.PNG).  I have checked the baud rate and all the other default settings.  I'm getting MODBUS Exception code: 3 meaning I have an Illegal data value.  What am I missing?  

 

GS2 Manual: https://cdn.automationdirect.com/static/manuals/gs2m/gs2m.pdf   

 

CH5-2:  Gives the Default Comm Parameters

Used in the Read Write VI's provided:

Stop Bits 2

ASCII

Baud Rate 9600

Parity None

Flow Control None

Timeout 500

Address 2331

Slave Address 1

Holding Register 1   (0 for stop, 1 for run)

0 Kudos
Message 10 of 13
(4,790 Views)

From what I understand this error typically means a value contained in the query data field is not an allowable value for the slave. I would double check this. Also, even though the issue is similar you will probably have more luck creating a new post for this issue for better visibility! 

CH
Applications Engineering
National Instruments
http://www.ni.com/en-us/support.html
0 Kudos
Message 11 of 13
(763 Views)

Hi,

 

Never used ModBus ASCII, only RTU, but from what I know I think the command is missing one byte.

01 = Slave address

06 = Command write register

091B = Register address

00 = The data should two bytes

01D4 = The check is also two bytes

 

So either the check or data is missing one byte. If you use the ModBus lib I would not expect this.

Maybe this is Ok for ModBus ASCII. But like I said I never used MB ASCII and I never use the lib.

 

Kees

 

0 Kudos
Message 12 of 13
(757 Views)

Yes, you are correct I was missing data.   I found out that you can edit the Int to display leading and trailing zeros and define how many.  That fixed that problem.  The other issue I had was that you need to go into the GS2 manually and tell it that commands are going to be sent using the RS485.  This was the crux of my problem.  The GS2 will save any settings made.  The default was to read from the control panel.  I changed it to read from the RS485 and to lock the control panel.    

0 Kudos
Message 13 of 13
(724 Views)