CML Examples
Absolute Move Example
This example uses the standard registers to run an absolute move. This could be run from a Control Room CML script, PC, PLC or microcontroller application using serial communication.
R1=0 //clear the controlword before setting the mode
_mop=2 //set the mode of operation to 2. Profile mode
P1=10000 //set target position
S1=100 //set target speed
A1=10 //set target acceleration
A2=10 //set target deceleration
N1=1100 //set the target torque to peak
R1=1 //start the profile move
//While R1=1 any change in the profile registers will execute an immediate change
Speed Move Example
This example uses the standard registers to run a speed move. This could be run from a Control Room CML script, PC, PLC or microcontroller application using serial communication.
R1=0 //clear the controlword before setting the mode
_mop=2 //set the mode of operation to 2. Profile mode
S1=100 //set target speed
A1=10 //set target acceleration
A2=10 //set target deceleration
N1=1100 //set the target torque to peak
R1=9 //start the profile move with the speed mode bit set.
//While R1=9 any change in the profile registers will execute an immediate change
Speed Move Example using Logic and Inputs
This example uses the motors internal programmable logic using two digital inputs to run a speed move.
/* Two Inputs - Two Speeds
This example will run the motor in a speed control mode.
* The speed selected will be based on which input is active
* The speed in this example switches motor direction between CW and CCW
* If both inputs are ON or both inputs are OFF the motor will stop
IN3 - set speed to 20
IN4 - set speed to -20
The example could be extended for other applications
1) by setting 4 different speeds based on the binary combination of the inputs
2) Having the speeds not change direction but adjust speed only. This could be used on something like a conveyor
------------
This example uses direct control.
See https://docs.myostat.ca/cm1-t/user-guide/direct-control#DirectControl-ProfileMode(PositionandSpeed)
------------
This example uses the IN and INFL variables to easily read the input status
IN --> outputs the binary combination of inputs
INMK --> sets and mask on IN to only return inputs required.
See https://docs.myostat.ca/cm1-c/user-guide/internal-state-variables#InternalStateVariables-"IN"
------------
*/
K85=1 //Start L1 on power up
K87=1 //Logic scan time = 1ms
var ModeOfOperation V1 //name V1 as ModeOfOperation
V1="mop" //assign to internal mop variable
var INMask V2
V2="INMK"
var INValue V3
V3="IN"
V4=0
B100 //clear all program banks
L100 //clear all logic banks
//L1 will be used to init all variables
L1.1
R1=0 //clear the controlword before setting the mode
INMask = 12 //Mask only IN3 and IN4 (IN4=8, IN3=4, IN2=2, IN1=1 -> bit combination)
ModeOfOperation=2 //set the mode of operation to 2. Profile mode
S1=0 //init target speed
A1=10 //init target acceleration
A2=10 //init target deceleration
N1=1100 //init the target torque to peak (110% of rated)
R1=9 //start the profile move with the speed mode bit set.
JL2 //jump to L2
END.1
//L2 will monitor the input status and change speed accordingly
L2.1
S2=0;
INValue == 4, S2=20, T0
INValue == 8, S2=-20, T0
S1=S2; //set direct control speed
END.1
$.1