Share this

LeadStudio Usage Tips - How to Achieve One-Click Start of Electronic Cam After Power Loss

2026-04-06 03:32:25 · · #1

Once the master and slave axes are bound to the electronic cam, the slave axis will continue to move synchronously with the master axis unless the cam is unbound or the slave axis is stopped in an emergency.

However, when the equipment loses power, the electronic cam's operating state is not remembered. Users often need to reset the shaft and re-bind the cam after power is restored, making it impossible to maintain the electronic cam's state before the power outage. In actual production, if a reset is required every time the equipment is powered on, it will definitely affect actual production efficiency.

For example, in pillow packaging machine applications, customers often require the equipment to be able to start with one key without resetting. In this case, the PLC needs to be able to continue the cam state before the power failure, so that the film pulling shaft and the rotary knife shaft can run directly after the power is restored.

Therefore, the following provides a method for implementing one-click start of the electronic cam after power failure based on LeadStudio.

Version Requirements

LeadStudio programming software version: V2.6.6.0 and above

PLC firmware version: 7905 and above

Introduction to related functional blocks

This example uses the following function blocks:

1. Cam-start function block

2. Cam follower shaft displacement acquisition function block

Sample Explanation

This example uses two rotary axes as master and slave axes. After the cam travels a certain distance, the PLC is restarted to simulate the situation where the cam restarts after a power failure.

01. Add two axes in sequence (as master and slave axes respectively).

02. Add an electronic cam configuration

03. Write the cam start program

Call function block

Call the cam start function block and the cam slave axis displacement acquisition function block, and then invert the acquired cam slave axis displacement and assign it to the SlaveOffset (slave axis offset) of the cam start function block.

As shown in the diagram above, the cam-start function block has several important parameters that require detailed explanation.

1. StartPosition (Cam gauge starting position)

After the function block is started, it needs to wait for the spindle position to reach StartPosition before the cam table can be executed. This parameter determines when the slave axis binds to the spindle. For example, if it is set to 60, then after the function block is started, it needs to wait for the spindle position to be equal to 60 before the cam table can be executed.

In this example, the real-time position feedback from the spindle is assigned to StartPosition. After the PLC is powered off and restarted, and the cam is restarted, the cam will immediately couple the master and slave axes starting from the current spindle position and begin executing the cam table. 2. When the MasterStartPosition (spindle tracking distance) and StartMode (spindle tracking distance mode) function blocks are started and begin executing the cam table, the spindle must pass the position specified by MasterStartPosition before the slave axis begins to follow the spindle in cam motion. According to the StartMode setting, MasterStartPosition can be specified in two ways: relative mode and absolute mode. The relative mode specifies the distance the spindle is displaced relative to MasterStartPosition from StartPosition, while the absolute mode specifies the actual position of the spindle moving to the position of MasterStartPosition. The main function of MasterStartPosition is to set the phase of the spindle to the position where it stopped last time when starting the cam, skipping part of the cam segment, thereby enabling the slave axis to start the cam without resetting and directly start running from the position where it stopped last time. In this example, StartMode is set to 0 (absolute mode), and MasterStartPosition is set to the real-time position feedback from the master spindle. This ensures that the slave axis can immediately execute the cam action after power-on startup. 3. MasterOffset (Master Spindle Offset) and SlaveOffset (Slave Axis Offset): Setting SlaveOffset offsets the slave axis displacement, moving the cam table along its vertical axis. In this example, since the slave axis position is 0 when the cam starts (reset to zero upon power-on), SlaveOffset is needed to eliminate the position step caused by MasterStartPosition. SlaveOffset is obtained from MC_GetCamTableDistance (cam slave axis displacement acquisition function block). The Phase input to MC_GetCamTableDistance is the real-time position feedback from the master spindle. The target position of the slave axis in the cam table is calculated using the current position of the master spindle. MasterOffset offsets the cam phase of the master spindle, moving the cam table along its horizontal axis. This is the core parameter for achieving cam hold-up even when power is off. If MasterOffset is not set, the cam's starting point is 0, and the cam will start moving from point 0 each time it is started. However, the cam may have already crossed point 0 before the power failure. Therefore, to restore the cam state before the power failure, MasterOffset must be set to offset the spindle phase. In this example, the value of MasterOffset is the inversion of the real-time position feedback from the spindle. The purpose is to offset the spindle phase to the cam phase before the power failure. After startup, the cam will continue to perform cam movements according to the cam phase before the power failure.

Trigger function block execution

Before starting the cam, the slave axis displacement acquisition function block needs to be triggered first. The slave axis displacement is then inverted and assigned to the SlaveOffset of the cam start function block before the cam start function block is executed. The program can be seen in the following figure:

Simulation test

PLC startup simulation debugging

Start Cam

Enter axis debugging interface

① Enter the axis debugging interface of the spindle (Axis_0) and trigger the spindle movement.

② Enter the axis debugging interface of the slave axis (Axis_1) and observe the position of the axis.

③ Compare the master and slave axis positions in the cam configuration table.

Restart the PLC and then start the cam.

① Restart the PLC

This simulates a power outage and restart scenario (in actual use, the spindle position needs to be saved using a power-off retention variable and restored using MC_SetPosition upon power-up).

② Restart the cam

Re-entering the axis debugging interface

① Trigger the spindle to reposition by 20, from 25→45

② Observe the slave axis; the slave axis follows the master axis from 150 to 190.

③ Comparing the cam configuration table, the master and slave axes continue to use the electronic cams from before the PLC restart.

-LeadStudio-

Smaller, faster, and easier-to-use PLC programming platform

Read next

CATDOLL Coco Soft Silicone Head

You can choose the skin tone, eye color, and wig, or upgrade to implanted hair. Soft silicone heads come with a functio...

Articles 2026-02-22
CATDOLL 136CM Sasha

CATDOLL 136CM Sasha

Articles
2026-02-22
CATDOLL 123CM Momoko TPE

CATDOLL 123CM Momoko TPE

Articles
2026-02-22
CATDOLL 138CM Tami Torso Doll

CATDOLL 138CM Tami Torso Doll

Articles
2026-02-22