K3 Modbus Index Example v1 0

12
K3_Modbus_Index_Example_v1_0.docx 9/2/2010 Page 1 of 12 Sample Code Programming Example Kinetix 3 in Index Mode using Modbus and MicroLogix

Transcript of K3 Modbus Index Example v1 0

Page 1: K3 Modbus Index Example v1 0

K3_Modbus_Index_Example_v1_0.docx

9/2/2010 Page 1 of 12

Sample Code

Programming Example

Kinetix 3 in Index Mode using Modbus

and MicroLogix

Page 2: K3 Modbus Index Example v1 0

K3_Modbus_Index_Example_v1_0.docx

9/2/2010 Page 2 of 12

Sample Code

Introduction This sample code example shows one method to control a Kinetix 3 drive in Index mode with a

MicroLogix PLC using Modbus RTU.

This document will cover the following items:

• Basic drive setup.

• Communication connections for KINETIX 3 and MicroLogix.

• Brief explanation of the program code.

Basic Drive Setup Install, connect, and commission the drive per user manual 2071-UM001. The user manual will step

through using Ultraware online with the drive, configure the drive for the installed motor/feedback

and autotuning.

Note: Ultraware ver 1.79 or later is required.

In addition to the basic setup, the following steps are specific to this sample code. Although the

drive configuration is accomplished using Ultraware, parameter numbers are included if the user

chooses to use the integral keypad.

Included with the sample code is an Ultraware file of a drive configured for Index mode and

controlled over Modbus.

Note: The Ultraware file does not show the drive serial communications as Modbus. This is because

the drive is connected to Ultraware when the file was saved.

Page 3: K3 Modbus Index Example v1 0

K3_Modbus_Index_Example_v1_0.docx

9/2/2010 Page 3 of 12

Sample Code

Set Operations Mode

Ultraware

On the Drive tab, set Operations Mode (Main/Override) to “Indexing” mode.

Parameters.

Pr0.00 Operations Mode

Set to I(12). (F(1) – Default)

I(12) – Index

Set Modbus Control

Ultraware

On the Drive tab under Communications, set MODBUS Run Function Control to “Enable” and

set MODBUS Input Function Control to “Enable”

Parameters.

Pr0.32 I/O Control Authority

Set to 0x11. (0x00 – Default)

0x1 – Digit 0 Enable Modus Input Function Control

0x1 – Digit 1 Enable Modus Run Function Control

Index Configuration

The following configures Indexes 0-3 for the KINETIX 3 Index mode sample code. This configuration is

required for the sample code, but your application can vary.

Note: The motor in the example has an absolute encoder with 131072 counts/rev. Velocity is in RPM.

Ultraware.

On the Indexing tab under Mode Configuration, configure Indexes 0-3:

Index 0 Setup Index 1 Setup Index 2 Setup Index 3 Setup

Mode Absolute Incremental Incremental Incremental

Distance 0 131072 262144 -65536

Dwell 0 2000 1500 0

Velocity 750 100 50 200

Accel 62.50 62.50 62.50 62.50

Decel 62.50 62.50 62.50 62.50

Next Index 0 2 3 0

Action When Complete Stop Start Next Start Next Stop

Page 4: K3 Modbus Index Example v1 0

K3_Modbus_Index_Example_v1_0.docx

9/2/2010 Page 4 of 12

Sample Code

Parameters.

IN02.00 Index 0 Option

Set to 0000. (0001 – Default)

Absolute move, Stop when complete.

IN02.01 Index 1 Option

Set to 0011. (0001 – Default)

Incremental move, Start Next Index when complete.

IN02.02 Index 2 Option

Set to 0011. (0001 – Default)

Incremental move, Start Next Index when complete.

IN02.03 Index 3 Option

Set to 0001. (0001 – Default)

Incremental move, Stop when complete.

IN04.00 Index 0 Position/Distance

Set Low word to 00000. (01000 – Default)

Set High word to 00000.

Move Position 0 Counts.

IN04.01 Index 1 Position/Distance

Set Low word to 31072. (01000 – Default)

Set High word to 00001.

Move Position 131072 Counts.

IN04.02 Index 2 Position/Distance

Set Low word to 62144. (01000 – Default)

Set High word to 00002.

Move Position 262144 Counts.

IN04.03 Index 3 Position/Distance

Set Low word to -65536. (01000 – Default)

Set High word to 00000.

Move Position -65536 Counts.

IN07.00 Index 0 Dwell

Set to 0. (0 – Default)

Dwell 0ms.

IN07.01 Index 1 Dwell

Set to 2000. (0 – Default)

Dwell 2000ms.

Page 5: K3 Modbus Index Example v1 0

K3_Modbus_Index_Example_v1_0.docx

9/2/2010 Page 5 of 12

Sample Code

IN07.02 Index 2 Dwell

Set to 1500. (0 – Default)

Dwell 1500ms.

IN07.03 Index 3 Dwell

Set to 0. (0 – Default)

Dwell 0ms.

IN08.00 Index 0 Velocity

Set to 750. (750 – Default)

Index Velocity – 750RPM.

IN08.01 Index 1 Velocity

Set to 100. (750 – Default)

Index Velocity – 100RPM.

IN08.02 Index 2 Velocity

Set to 50. (750 – Default)

Index Velocity – 50RPM.

IN08.03 Index 3 Velocity

Set to 200. (750 – Default)

Index Velocity – 200RPM.

IN12.00 Index 0 Next Index

Set to 0. (0 – Default)

Index Next Index – 0.

IN12.01 Index 1 Next Index

Set to 2. (0 – Default)

Index Next Index – 2.

IN12.02 Index 2 Next Index

Set to 3. (0 – Default)

Index Next Index – 3.

IN12.03 Index 3 Next Index

Set to 0. (0 – Default)

Index Next Index – 0.

Page 6: K3 Modbus Index Example v1 0

K3_Modbus_Index_Example_v1_0.docx

9/2/2010 Page 6 of 12

Sample Code

Configure Digital Inputs

Ultraware.

On the Digital Inputs tab configure inputs:

Input 1 – Drive Enable

Input 2 – Moving Enable

Input 3 – Fault Reset

Input 4 – Unassigned

Input 5 – Unassigned

Input 6 – Unassigned

Input 7 – Unassigned

Input 8 – Unassigned

Input 9 – Unassigned

Input 10 – Unassigned

Parameters. See user manual 2071-UM001 for specific digit definitions.

Pr0.10 Allocation of Input Signals 1

Set to 0x0BB1. (0x4BB1 – Default)

Pr0.11 Allocation of Input Signals 2

Set to 0x0003. (0x0003 – Default)

Pr0.12 Allocation of Input Signals 3

Set to 0x0000. (0x0000 – Default)

Pr0.13 Allocation of Input Signals 4

Set to 0x0000. (0x0000 – Default)

Pr0.14 Allocation of Input Signals 5

Set to 0x0020. (0x0000 – Default)

Pr0.15 Allocation of Input Signals 6

Set to 0x0000. (0x0000 – Default)

Pr0.16 Allocation of Input Signals 7

Set to 0x0000. (0x0000 – Default)

Pr0.17 Allocation of Input Signals 8

Set to 0x0000. (0x0000 – Default)

Pr0.18 Allocation of Input Signals 9

Set to 0x0000. (0x0000 – Default)

Page 7: K3 Modbus Index Example v1 0

K3_Modbus_Index_Example_v1_0.docx

9/2/2010 Page 7 of 12

Sample Code

Homing Configuration

Homing is required before the drive will run an Index. The KINETIX 3 in the example is configured for

Home to Marker. Your requirements for homing may differ.

Ultraware

On the Homing tab under Mode Configuration, configure Homing:

Homing Type – Home to Marker

Auto Start Homing – Inactive

Homing Velocity – 100RPM

Offset Move Distance – 0

Move Distance after Home Sensor - 0

Parameters.

IN01.00 Homing Type

Set to 8. (1 – Default)

Home to Marker

IN01.01 Auto Start Homing

Set to 2. (2 – Default)

Inactive

IN01.02 Homing Velocity

Set to 100. (100 – Default)

Homing velocity – 100RPM

IN01.05 Offset Move Distance

Set Low word to 00000. (00000 – Default)

Set High word to 00000.

Offset Move Distance – 0 Counts

IN01.08 Move Distance After Home Sensor

Set Low word to 00000. (00000 – Default)

Set High word to 00000.

Move Distance after Home Sensor – 0 Counts

Page 8: K3 Modbus Index Example v1 0

K3_Modbus_Index_Example_v1_0.docx

9/2/2010 Page 8 of 12

Sample Code

Set Serial Port Configuration

The drive serial port configuration can be viewed with Ultraware. However changing one of the

parameters will cause a communication loss. It is recommended that the serial port configuration be set

through the drive keypad.

KINETIX 3 Drive serial port configuration for communication with Ultraware:

Parameters.

Pr0.09 Serial Port Configuration

Set to 0x0005. (0x0005 – Default)

0x5 – Digit 0 Baudrate - 57600 bps

0x0 – Digit 1 8 Data, No Parity, 1 Stop bit

0x0 – Digit 2 Protocol ASCII

0x0 – Digit 3 RS232 – 0

KINETIX 3 Drive serial port configuration for Modbus communication with MicroLogix:

Parameters.

Pr0.09 Serial Port Configuration

Set to 0x1102. (0x0005 – Default)

0x2 – Digit 0 Baudrate - 19200 bps

0x0 – Digit 1 8 Data, No Parity, 1 Stop bit

0x1 – Digit 2 Protocol MODBUS-RTU

0x1 – Digit 3 RS485 - 1

Page 9: K3 Modbus Index Example v1 0

K3_Modbus_Index_Example_v1_0.docx

9/2/2010 Page 9 of 12

Sample Code

Kinetix 3 communication Connections The Kinetix 3 communication port can be configured for RS232 communications for Ultraware or RS485

Modbus RTU.

3 cables are available for serial communication with the Kinetix 3.

2090-CCMPCDS-23AAxx

Kinetix 3 Comm0A or Comm0B to PC 9-pin serial port for RS232 programming with Ultraware.

2090-CCMCNDS-48AAxx

Kinetix 3 Comm0A or Comm0B to MicroLogix 1100/1400 channel 0 port for RS485 Modbus RTU.

2090-CCMDSDS-48AAxx

Kinetix 3 Comm0A or Comm0B to Kinetix 3 Comm0A or Comm0B for multi-drive RS485 Modbus RTU.

Note: The configuration of the serial port includes both Comm0A and Comm0B. Changing between RS-

232 and RS-485 Modbus requires different cabling and serial port configurations.

RS232 connection for configuration with Ultraware.

Page 10: K3 Modbus Index Example v1 0

K3_Modbus_Index_Example_v1_0.docx

9/2/2010 Page 10 of 12

Sample Code

RS485 connection for control over Modbus RTU.

The following shows connection to a MicroLogix 1100 or 1400 (MicroLogix 1400 shown). If the Kinetix 3

is the only device on the network or the last device on the network, the 485 Term switches on the front

of the drive need to be set “ON”.

Page 11: K3 Modbus Index Example v1 0

K3_Modbus_Index_Example_v1_0.docx

9/2/2010 Page 11 of 12

Sample Code

Sample Code The MicroLogix 1400 is used in the example but can be converted to a MicroLogix 1100. The KINETIX

3 Index sample code has 2 routines.

• Drive Communication routine

o Read drive status words

o Write drive command words

o Read Warning code

o Read Fault code

• Drive Control routine

o Enable the drive

o Disable the drive

o Fault reset

o Home

o Select an Index

o Start Index

o Stop drive

The Drive Control routine contains command bits to Fault Reset, Home, Run Sequence, and

Stop. These bits can be “toggled” when online with the controller, set by code added by the

user, or set from the Custom Data Monitor.

B131:0/2 From User Program Drive01 Fault Reset.

This bit will set the Fault Reset Bit in the Command word.

B131:0/5 From User Program Drive01 Home.

This bit will execute a sequence to enable the drive and start homing.

B131:0/0 From User Program Drive01 Run.

This bit will execute a run sequence to enable the drive, select Index 1, and start the

indexing. The indexes are configured so Index 1 calls Index 2 when complete. Index 2

calls Index 3 when complete. It loops back to the beginning when Index 3 is complete.

B131:0/1 From User Program Drive01 Stop.

This bit will execute a sequence to stop the drive. When it comes to a stop, the drive is

disabled.

Also included in the example, is code to stop and disable the drive on a fault and read the fault

and error code.

Page 12: K3 Modbus Index Example v1 0

K3_Modbus_Index_Example_v1_0.docx

9/2/2010 Page 12 of 12

Sample Code

Disclaimer This sample code delivered by Rockwell Automation is just an example of how to control a KINETIX 3

drive.

Disclaimer Of Warranty

THE MATERIALS DELIVERED WITH THIS EXAMPLE ARE PROVIDED "AS IS" WITHOUT WARRANTIES

OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ALL IMPLIED

WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT

OR OTHER VIOLATION OF RIGHTS. ROCKWELL AUTOMATION DOES NOT WARRANT OR MAKE ANY

REPRESENTATIONS REGARDING THE USE, VALIDITY, ACCURACY, OR RELIABILITY OF, OR THE

RESULTS OF THE USE OF, OR OTHERWISE, RESPECTING THE MATERIALS MAINTAINED ON OR

ACCESSED BY WAY OF THIS SITE OR ANY WEB SITES LINKED TO THIS SITE. FURTHERMORE, ALL

WARRANTIES, CONDITIONS, REPRESENTATIONS, INDEMNITIES AND GUARANTEES WITH RESPECT

TO THE ACCURACY, OPERATION, CAPACITY, SPEED, FUNCTIONALITY, QUALIFICATIONS, OR

CAPABILITIES OF THE SOFTWARE, SYSTEMS AND SERVICES COMPRISING OR UTILIZED IN THE

OPERATION OF THIS CODE, WHETHER EXPRESS OR IMPLIED, ARISING BY LAW, CUSTOM, PRIOR

ORAL OR WRITTEN STATEMENTS BY ROCKWELL AUTOMATION, OR OTHERWISE (INCLUDING, BUT

NOT LIMITED TO ANY WARRANTY OF SATISFACTORY QUALITY, MERCHANTABILITY, FITNESS FOR

PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT) ARE HEREBY EXPRESSLY EXCLUDED

AND DISCLAIMED.

Disclaimer Of Liability

UNDER NO CIRCUMSTANCES (INCLUDING NEGLIGENCE) WILL ROCKWELL AUTOMATION BE

LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL

DAMAGES (INCLUDING WITHOUT LIMITATION, BUSINESS INTERRUPTION, DELAYS, LOSS OF DATA

OR PROFIT) ARISING OUT OF THE POSTING (OR THE INABILITY TO POST) OR THE USE (OR THE

INABILITY TO USE) THE DELIVERED CODE EVEN IF ROCKWELL AUTOMATION HAS BEEN ADVISED

OF THE POSSIBILITY OF SUCH DAMAGES.