You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

 

 

Version: 1.0.0

CML Runtime Code

The following CML code shows what is running inside the Cool Muscle. The Ethernet/IP writes to R0, P0, A0 and S0 to control the motor. V0 is also written to and can be customised to read/write data defined by the user.

Change the CML in the motor with care. If the communication ports are disabled the unit will need to be returned to the factory to be reset.

 

EIP CML Code
/* This program uses a control word to execute defined functions on the motor.
It has been developed for Modbus modules needing to control the motor but can be used as generic control.
R0.1 --> Control Word
P0.1 --> Target Position
A0.1 --> Target Acceleration
S0.1 --> Target Speed
Note:
	1) If you are using the Ethernet/IP module the baudrate is set to 57600. The motor should be matched.
	2) This code does not switch on Modbus mode. Some modules use COM1 on Modbus and others on COM2. 
	   Please contact tech support for more information
*/
//init a number of variables
R1.1=0
P1.1=0
A1.1=0
S1.1=0
N1=1
N2=2
N3=3
N4=4
N5=5    
//clear banks
b100
l100
//L1.1 scans for changes in any of the R0, P0, A0 and S0 values
L1.1
R.1!= R1.1, CL2.1, T0.1
P.1!= P1.1, CL3.1, T0.1
A.1!= A1.1, CL4.1, T0.1
S.1!= S1.1, CL5.1, T0.1
END.1

//R0 has changed. Save the new value and execute the required command
L2.1
R1.1= R.1;
R1.1== N1.1, ^.1, T0.1
R1.1== N2.1, ].1, T0.1
R1.1== N3.1, (.1, T0.1
R1.1== N4.1, ).1, T0.1
R1.1== N5.1, |.1, T0.1
END.1
//P0 has changed. Save the value. 
//If the control word is set to run then automatically execute the next position. Current position must be completed first
L3.1
P1.1= P.1;
R.1== N1.1, ^.1, T0.1
END.1
//A0 has changed. Changing the modbus register does not execute the change. A0.1=A0.1 will execute the change immediately.
L4.1
A1.1= A.1;
A.1= A.1;
END.1
//S0 has changed. Changing the modbus register does not execute the change. S0.1=S0.1 will execute the change immediately.
L5.1
S1.1= S.1;
S.1= S.1;
END.1
//set L1 to run on power up at 1ms scan time        
K85.1=1     
K87.1=1
K89.1=0	//set modbus offset=0 
K23.1=0 //set for no events
//save to EEPROM
$.1
  • No labels