How axes work in cam
In this section, we introduce cam and cam movement, and show how to make a cam move in KINGSTAR.
Understanding cam
A cam is typically an irregular-shaped mechanical piece fixed to a rotating shaft. In cam mechanism, there is a follower against the cam's edge. The follower moves up and down as the cam rotates with the shaft. Since the cam's outline is irregular, every time the distance the follower moves up and down is different.
ECAM uses this idea to define the relationship between the master and slave axes. The master axis is like the shaft, the slave axis is like the follower, and the cam determines the position profile. Each slave's position corresponds to a master's. The master's starting value and the interval between two adjacent master positions vary between ECAM tables.
The following is an example of a cam and ECAM.
Cam | ECAM | ECAM table | |
---|---|---|---|
|
|
Master | Slave |
0 | 100 | ||
10 | 102 | ||
45 | 101 | ||
87 | 97 | ||
125 | 94 | ||
190 | 91 | ||
. | . | ||
. | . | ||
358 | 99 |
Using cam
Cam is a multi-axis motion that links two axes: master and slave. After linking them you move the master axis. During the master's movement, the slave automatically moves to a position corresponding to the master's. The slave's movement always follows the master's, until the master moves out of the predetermined range or the cam is aborted. The range of master and slave's positions is based on a cam table you defined.
The process below shows how to use linear cam in KINGSTAR:
SetCamTable -> SetAxisCam -> MoveAxis functions-> ReleaseAxis
Defining a cam table
Before you start the cam motion, you need to use the SetCamTable function to define a cam table that includes master and slave axis' positions. By default, the master and the slave axes use absolute coordinates. If you don't use offset or scale, their positions in the cam table (table positions) are the same as absolute positions. If you add offset or scale, you need to use the specified formula to calculate the table positions. For more information about offset and scale, see Defining cam motion.
Periodic
The McCamTable structure contains a parameter called Periodic, which determines whether the cam motion curve is repeated. When you define the cam table using SetCamTable, you can set Periodic to TRUE or FALSE. TRUE is to repeat and FALSE is not to repeat. Depending on the table positions you define, the cam motion curve repeats in different ways.
Non-periodic
For non-periodic cam motion, the slave axis follows the movement of the master axis only when the master moves within the range defined in the cam table. Once the master moves out of the range, the slave stops following and stays at the last position it reaches.
Non-periodic |
---|
Periodic - same range
For periodic cam motion, if the start and end positions of the slave axis are the same, the slave will periodically move within the specified range.
Periodic - same range |
---|
Periodic - continue
For periodic cam motion, if the start and end positions of the slave axis are different, the offset is added to the slave's positions each cycle.
Periodic - continue |
---|
Defining cam motion
Next, you use SetAxisCam to specify the axes to be the master and slave. The slave axis is attached to the master and moves in synchronized motion. You can also decide whether you want to add offset or scale to the cam table. The master and slave can have their own offset and scale. That is, you can add offset or scale only to the master or slave axis instead of adding offset or scale to both of them. Offset and scale are independent of each other. You can use one of them or both at the same time. For example, you can add offset to the master's positions or scale the slave's positions.
In this guide, we introduce two examples: (1) offset (2) offset and scale.
Offset
When adding offset, you need to calculate the table positions using the following formula:
MasterTablePos = MasterAbsPos - MasterOffset
SlaveTablePos = The position corresponding to the MasterTablePos
SlaveAbsPos = SlaveTablePos + SlaveOffset
Consider the following figure as an example. The master positions are offset by six and the slave's positions are offset by five. When you set the master and slave positions in cam table, keep in mind they are the results of absolute positions minus the offset. The master's table position 1, 2, 3 are actually the absolute position 7, 8, 9. The slave's table position 1, 2, 3 are actually the absolute position 6, 7, 8.
Offset |
---|
Offset and scale
In addition to offset, you can scale your cam table. Consider the following figure as an example. The master positions are first offset by six and the slave's positions are offset by five, and then the cam table is scaled by two. When you calculate your table positions, use the following formula:
MasterTablePos = (MasterAbsPos - MasterOffset) / MasterScale
SlaveTablePos = The position corresponding to the MasterTablePos
SlaveAbsPos = (SlaveTablePos * SlaveScale) + SlaveOffset
Because the cam table is scaled, we need to divide the scaled factor to get the original table positions. Thus, the master's table position 0.5, 1, 1.5 are actually the absolute position 7, 8, 9. The slave's table position 0.5, 1, 1.5 are actually the absolute position 6, 7, 8.
Offset and scale |
---|
Cam start mode
In SetAxisCam you can use the StartMode parameter to decide how your axes start to cam. There are four start modes: camAbsolute
, camRelative
, camRampDistance
, and camRampTime
.
camAbsolute | |
---|---|
If the master and slave axes are not in position as the cam starts, the slave will jump to the target position and then start moving. It would be better to use this feature after the axes are in position. |
camRelative | |
---|---|
If the master and slave axes are not in position as the cam starts, the slave will jump to the target position and then start moving. It would be better to use this feature after the axes are in position. |
camRampDistance | |
---|---|
Consider this figure as an example. As the master moves six units forward, the slave starts to move to the corresponding position. It gets closer and closer to the cam motion curve. When the master moves two units backward, the slave also moves backward, until it reaches the cam position corresponding to the master. After you set SetAxisCam and use Move functions to move the master, the slave starts to synchronize with the master. The slave is in position once the master moves more than the ramp distance. |
camRampTime | |
---|---|
Consider this figure as an example. We set StartParameter to 2 seconds. The master is staying at the position 3. As soon as you send the SetAxisCam command, the slave starts to move. After 2 seconds it reaches the cam position that is corresponding to the master. After you set SetAxisCam, the slave starts to synchronize with the master. The slave is in position after the ramp time is expired. |
Moving the cammed axis
After setting the table positions in SetAxisCam, we can start to move our axes. For linear cam movement, you can use MoveAxisAbsolute, MoveAxisAdditive or MoveAxisRelative functions. Take MoveAxisAbsolute as example, it has a Position parameter. You need to write the value of the master's absolute position into Position.
After sending the MoveAxisAbsolute command to KINGSTAR, the cammed axes start to move.
Detaching the cammed axis
The slave axis can be detached manually or automatically, depending on your settings and need.
Manually: use ReleaseAxis to detach the slave axis from the master.
Automatically: if Periodic in the McCamTable structure is set to FALSE, the slave axis will be automatically detached when the master axis moves out of the range of the cam table.