Skip to main content
Skip table of contents

Start/ Stop motion using 2 GPIs


A basic task needed in some applications is to execute a motion with an imposed speed or distance, from the moment when a digital input changes its status.

The following note describes how use MotionLab2 macros programming language for using I/O conditional event (If command) to start a position motion profile moving the actuator in both directions.

This example enables the servo motor and waits for digital input GPI1 to move the a voice coil 5.000 counts; if GPI2 is pressed, the motor moves in the opposite direction.

 Application note objective:

  • Use different macros to structure the programming
  • Learn how to use program flow commands
  • Learn how to use conditional jumps based on input status
  • Learn how to perform a move

Instructions used

The notes use the following instructions

Instruction typeInstructionDescriptionComments
Motor controlMotor ONEnables the servo driveUsed in start-up macro 0
Program flowMacro jumpJumps to a specific macro number'Go To 'equivalent
Program flowIfConditional jumpIt allows execution of a group of program lines if the specified expression is true
MotionPositionExecutes an incremental or absolute moveUse the Position command to generate a move relative or absolute to a specific number of counts
Program flowMacro CallCall a specific macroJumps to a macro, execute code and returns
Program flowMacro ReturnReturns to macro callReturns to macro Call and executes following instructions

Materials used

The following materials have been used for this example:

ProductsVersion / Model
BEI KIMCO Smart Voice coilLAS13-18-000A
Pluto Documentation HomeSTD
Pluto IO extension board1.0
MotionLab Configuration and programming tool 2.7.6

Reference documentation 

Program example

At system power up, macro 0 is executed. Servo drive is Enabled and program jumps to macro #1.

  • If GPI1 is pressed, program calls Macro #3
  • If GPI2 is pressed, program calls Macro #2
  • If no input is pressed, program continues execution in macro #1

Macro #0

This macro is always executed at power-up. After the servo drive is enabled, it jumps to macro #1. This macro should contain all the initialization process.

Macro #1

This macro checks whether GPI1 or GPI2 are pressed.

  • If GPI1 is ON it calls macro 3 otherwise remains in Macro1
  • If GPI2 is ON it calls macro 2 otherwise remains in Macro1

Macro #2 and #3

These macros execute a move function of 5.000 counts, negative or positive. Once target is reached macros return to macro call.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.