Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Metadata (Metadata Plugin)
0version
hiddentrue
1.0.0


Scroll Ignore

Version:

Metadata from
1version



Numbered Headings

Introduction

Modbus gives read/write access to all Cool Muscle registers such as K-parameters, positions, speeds and accelerations. A CML program needs to reside in the motor to execute functions depending on the status of these registers. Below you will find an example program that is used in all Modbus - TCP motors. It uses a control word in the R1 R0 register to execute a number of functions. This code is useful for point-to-point motion and speed control. An application may require a significantly more complex program which can replace the example program. The CML is written to be compiled and sent from Control Room. The user does not need to understand the code but only how to use it. The full program code is supplied for those users wanting to change or get a better understanding of how the program works. Modbus - TCP motors come standard with the Modbus program loaded.

Running the motor

The following list of holding registers can be used to the read and write move data to the motor. 


Holding RegisterParameterDescriptionR/W
40201P1P0Target positionR/W
4060540603S1S0Target speedR/W
4063740635A1A0Target accelerationR/W
40301R1R0Control WordR/W
40003Motor PositionMotors current position in pulsesR
40009Motor StatusMotors current statusR
 


Position, Speed and Acceleration

The default setting for the motor is K37=3 which sets the following units. This can easily be changed by modifying the value of K37.

RegisterUnit/Resolution
P1P01000 pulses/revolution
S1S0100 pulse/s
A1A01K pulses/s2

 

Control Word

The R1 R0 register is used for the Control Word. It has the following value options by default:

R1 R0 ValueDescription
0Do nothing
1Start the position move
2Stop the motor
3Enable the motor
4Disable the motor
5Home the motor
 


Note

These functions can be edited or expanded by changing the default program based on user requirements. Please contact our support team if you need assistance with this.


Some things to note when using the control word

  1. Changing the value of the control word immediately executes the operation 
  2. If the Control Word is left with the value 1 then changing the position once the motor has come to a stop will execute the next move. This allows the Modbus master to only change the position and not need to also toggle the control word to execute the next move.
  3. The home routine is by default set to a hardstop search in the CCW direction. Please see K42 to K48 for home routine options.

 

CML

 

CML Code

The following is the CML code used for motor control in Modbus. It is not required for users to understand the code unless they are looking to change it.

Code Block
languagec#
firstline1
titleCML Modbus Code
linenumberstrue
//set the logic scan rate to 1ms
K87.1=1
//set logic bank 1 to scan on power up
K85.1=1
//set the modbus register offset to 0
K89.1=0
//switch off all automatic motor event reporting
K23.1=0
//make sure carraige return is not automatic after line feed (legacy setting)
K70.1=0

/*create variables for the old/previous target
control word
position
speed
acceleration
These are used to find a change in the target
Init them to 0
*/
var old_ControlWord R1.1				//old control word
R1.1=0
var old_TargetPos P1.1		//old position
P1.1=0
var old_TargetSpd S1.1		//old speed
S1.1=0
var old_TargetAcc A1.1		//old acceleration
A1.1=0

/*create variables for the new target
control word
position
speed
acceleration
These are used to find a change in the target
Init them to 0
*/
var ControlWord R0.1				//control word
R0.1=0
var TargetPos P0.1		//position
P0.1=0
var TargetSpd S0.1		//speed
S0.1=0
var TargetAcc A0.1		//acceleration
A0.1=0 

/*
Logic L1 scans for a change in the word or any target value
if a change is detected it call the relevant logic bank
*/
L1.1
ControlWord!= old_ControlWord, CL2.1, T0.1	//scan control word
TargetPos!= old_TargetPos, CL3.1, T0.1		//scan position
TargetAcc!= old_TargetAcc, CL4.1, T0.1		//scan acceleration
TargetSpd!= old_TargetSpd, CL5.1, T0.1		//scan speed
END.1
/*
Logic L2 is called if there is a change in the control word
1) it saves the new state into the old state
2) It compares the changed value with defined values to 
execute the relavant command
*/
L2.1
old_ControlWord= ControlWord;
old_ControlWord== 1, ^.1, T0.1		//run
old_ControlWord== 2, ].1, T0.1		//stop
old_ControlWord== 3, (.1, T0.1		//enable
old_ControlWord== 4, ).1, T0.1		//disable
old_ControlWord== 5,|.1,T0.1		//home
END.1
/*
Logic L3 executes a change in position
If the control word eqauls 1 then it executes the move immediately
*/
L3.1
old_TargetPos= TargetPos;
ControlWord== 1, ^.1, T0.1	//execute move is ControlWord equals 1
END.1
/*
The following 2 logic banks set the speed and acceleration
Writing to the value through modbus only changes the register
it does not process the change.
The change must be processed through CML for it to be
executed immediately
*/
//Logic L4 sets the acceleration
L4.1
old_TargetAcc= TargetAcc;
TargetAcc= TargetAcc;
END.1
//Logic L4 sets the speed
L5.1
old_TargetSpd= TargetSpd;
TargetSpd= TargetSpd;
END.1
$.1


Download the complete Control Room project here Default Modbus CML program.crp

 Sample

Beijer X2 Base

The following sample uses the Beijer X2 Base 7 HMI to communicate to the CM1:

SingleAxisModbus.zip

The following is the same program configured to run on the CM2 motor:

CM2_SingleAxisModbus.zip

Mitsubishi GOT1000

The following program configures a Mitsubishi GOT1000 to run the motor over Modbus RTU. The application is written in GT Designer3.

GOT1000.zip