Using Cam Data for Function Blocks
Cam diagrams are used as a basis to generate cam data structures with a corresponding number of cam points.
These data structures can be used to parameterize the FB_MultiCam / MC_Cam_ID function blocks or a POU with equivalent functionality.
Cam data is used to initialize function blocks/modules that are processing cam data structures in the application program.
Specifying the Target Function Block
The Configuration tab of the cam motion editor provides an input field that allows you to specify an existing cam data structure as target. If a target is defined, cam data will automatically be written to this target structure when the program is initialized. If the expression is indeterminable, a diagnostic message will be generated.
From the target defined, EcoStruxure Machine Expert detects whether the data structures are CommonMotionType or PacDriveLib structures and parameterization is performed accordingly.
Generating Data for Cam Data Structures
When the project is built (via the Build command from the Build menu or shortcut F11), IEC source code is generated and written into the specified cam data structure.
The parameterization statements for the cam data structure are generated in the following format:
MyMultiCam.MultiCamData.diNumberOfCamPoints := 3;
MyMultiCam.MultiCamData.lrYPeriod := 0;
MyMultiCam.MultiCamData.astCamPoint[0].lrX := 0;
MyMultiCam.MultiCamData.astCamPoint[0].lrY := 100;
MyMultiCam.MultiCamData.astCamPoint[0].lrM := 0;
MyMultiCam.MultiCamData.astCamPoint[0].lrK := 0;
MyMultiCam.MultiCamData.astCamPoint[0].lrLambda := 0.5;
MyMultiCam.MultiCamData.astCamPoint[0].lrC := 1;
MyMultiCam.MultiCamData.astCamPoint[0].etCamType := ET_CAMTYPE.Poly5Com;
MyMultiCam.MultiCamData.astCamPoint[1].lrX := 100;
MyMultiCam.MultiCamData.astCamPoint[1].lrY := 0;
MyMultiCam.MultiCamData.astCamPoint[1].lrM := 0;
MyMultiCam.MultiCamData.astCamPoint[1].lrK := 0;
MyMultiCam.MultiCamData.astCamPoint[1].lrLambda := 0.5;
MyMultiCam.MultiCamData.astCamPoint[1].lrC := 1;
MyMultiCam.MultiCamData.astCamPoint[1].etCamType := ET_CAMTYPE.SimplSin;
In this example, MyMultiCam.MultiCamData is configured as target data structure.
The generated data is based on cam diagrams that were edited in offline mode. They are not updated in online mode.
Each cam segment is defined by a CamPoint that specifies the data located on the left margin of the segment. The right CamPoint of a cam segment corresponds to the left CamPoint of the next cam segment. To identify the end point of the cam diagram, the last cam segment is defined by an own right CamPoint.
There is a maximum of 32 CamPoints available for a cam data structure. When a target structure has been selected with a cam diagram having more than 31 segments, a diagnostic message will be generated. In order to design the motion of an axis with more than 31 segments, you must divide it into several cam diagrams.
NOTE: If several cam diagrams are incorporated, for drive sizing with Motion Sizer, Motion Sizer make sure to use the total cam curve including all sub cam diagrams.
Initializing the Function Block
In order to provide the configured cam data to the target structure, an initialization code is executed once during start-up. This initialization task is executed by a program POU that is called up as initialization code after the user initialization processes have been completed.