Navigation:  Equipments (Devices) > SCA06 > Ladder > Motion Control > Motion Control Cam >

MW_CamCalc

Cam Table Calculation

Previous pageReturn to chapter overviewNext page

This block calculates a cam table of the CAM curve.

 

Ladder Representation

 

MW_CamCalc_block

 

Execution Features

 

Program Memory Size

66 Bytes

Data Memory Size

24 Bytes

 

Block Structure

 

Variable Type

Name

Data Type

Description

VAR_IN_OUT

Master

BYTE

Selection of operation master

(0 - Fast digital inputs)

(1 - CANopen)

(2 - Encoder 1)

(3 - Virtual Axis)

(4 - Encoder 2)

Slave

BYTE

Selection of operation slave

(0 - Real axis)

CamTable

WORD

CAM table code

VAR_INPUT

Execute

BOOL

Block enabling

NumberOfPoints

WORD

Number of points of the table

MasterPoints

LREAL

Points of the master

SlavePoints

LREAL

Points of the slave

CurveType

WORD

Type of curve

Periodic

BOOL

Control of the request execution

(0 - Single execution)

(1 - Periodic execution)

VAR_OUTPUT

InSync

BOOL

Output enabling

Busy

BOOL

Flag indicating the block has not yet been ended

Error

BOOL

Error in the execution flag

ErrorID

WORD

Identifier of the occurred error

CamTableID

WORD

Selected CAM table

VAR

MW_CAMCALC_INST_0

MW_CAMCALC

Instance of access to block structure

 

Operation

 

When this block detects a leading edge in Execute, it builds the specified table in CamTable with the programmed data so that it can be used by the MC_CamIn block.

 

When Execute has FALSE value, Done remains FALSE. The Done output is activated when the block finishes the execution successfully, remaining at TRUE level until Execute receives FALSE.

 

If there is any error in the execution, the Error output is enabled and ErrorID displays an error code according to the table below.

 

Code

Description

83

Invalid file of the CAM curve cam table.

84

Invalid Cam Table. Cam Table must be from 11 to 20.

86

Number of points above the programmed in the CAM PROFILES configurator.

87

Invalid position of the master axis. The position of the master axis must be greater than the position of the previous point.

88

MW_CamCalc block in execution. Is only allowed the execution of an MW_CamCalc block at a time.

89

Cam table in use by the MC_CamIn block.

90

Double marker with position of the nonexistent master axis.

91

Double marker with position of the nonexistent slave axis.

92

Word marker with nonexistent curve type.

 

Example in Ladder

 


 
MW_CamCalc_example02
 
MW_CamCalc_example03

 

 

In the transition from 0 to 1 of bit marker CAMCALC_EXECUTE, the MW_CamCalc block is executed and the cam table of TABLE will be calculated according to the block arguments.

 

In this example, the number of points of the curve will be contents of the NUM_POINTS, the position of the master axis will be in accordance with the contents of MASTER_POINTS [0] and MASTER_POINTS [1], the position of the slave axis will be in accordance with the contents of SLAVE_POINTS [0] and SLAVE_POINTS [1] and the type of curve will be in accordance with the contents of CURVE_TYPE [0] and CURVE_TYPE[1].

 

Entering the same values in the tool, we can observe the curve below:

 

MW_CamCalc_example04

 

 

When the calculation of the cam table 11 is finished, the InSync output is set while the Execute input remains set.

With the CAMCALC_DONE set, the MC_CamIn block can be executed.

 

Example in ST

 

 The example below displays the instructions for applying the example above in the ST language.

 

 

VAR

  CAMCALC_EXECUTE, CAMCALC_DONE, CAMIN1_EXECUTE,

      CAMIN1_DONE : BOOL;

  NUM_OF_TABLE, PTS_OF_ARRAY : WORD;

  CAMTABLEID : UINT;

  CURVE_ARRAY : ARRAY [0..1] OF WORD;

  M_PTS_ARRAY, S_PTS_ARRAY : ARRAY [0..1] OF LREAL;

  MW_CAMCALC_INST_0 : FB_MW_CamCalc;

  MC_CAMIN_INST_0 : FB_MC_CamIn;

END_VAR

 

M_PTS_ARRAY[0] := FB_WORD_TO_LREAL(PAR_1050);

M_PTS_ARRAY[1] := FB_WORD_TO_LREAL(PAR_1051);

S_PTS_ARRAY[0] := FB_WORD_TO_LREAL(PAR_1052);

S_PTS_ARRAY[1] := FB_WORD_TO_LREAL(PAR_1053);

CURVE_ARRAY[0] := FB_STORE(WORD#0);

CURVE_ARRAY[1] := FB_STORE(WORD#1);

 

MW_CAMCALC_INST_0.Execute := CAMCALC_EXECUTE;

MW_CAMCALC_INST_0(

  Master:=0,

  Slave:=0,

  CamTable:=NUM_OF_TABLE,

  NumberOfPoints:=PTS_OF_ARRAY,

  MasterPoints:=M_PTS_ARRAY,

  SlavePoints:=S_PTS_ARRAY,

  CurveType:=CURVE_ARRAY,

  Periodic:=1);

CAMTABLEID := MW_CAMCALC_INST_0.CamTableID;

CAMCALC_DONE := MW_CAMCALC_INST_0.InSync;

 

MC_CAMIN_INST_0.Execute := CAMIN1_EXECUTE AND CAMCALC_DONE;

MC_CAMIN_INST_0(

  Master:=0,

  Slave:=0,

  MasterScaling:=1.0,

  SlaveScaling:=1.0,

  MasterSyncPosition:=LREAL#0.0,

  CamTableID:=CAMTABLEID,

  BufferMode:=1);

CAMIN1_DONE := MC_CAMIN_INST_0.InSync;