Start/ Stop motion using 2 GPIs
Description
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 type | Instruction | Description | Comments |
---|---|---|---|
Motor control | Motor ON | Enables the servo drive | Used in start-up macro 0 |
Program flow | Macro jump | Jumps to a specific macro number | 'Go To 'equivalent |
Program flow | If | Conditional jump | It allows execution of a group of program lines if the specified expression is true |
Motion | Position | Executes an incremental or absolute move | Use the Position command to generate a move relative or absolute to a specific number of counts |
Program flow | Macro Call | Call a specific macro | Jumps to a macro, execute code and returns |
Program flow | Macro Return | Returns to macro call | Returns to macro Call and executes following instructions |
Materials used
The following materials have been used for this example:
Products | Version / Model |
---|---|
BEI KIMCO Smart Voice coil | LAS13-18-000A |
Pluto Documentation Home | STD |
Pluto IO extension board | 1.0 |
MotionLab Configuration and programming tool | 2.7.6 |
Reference documentation
- BEI KIMCO LAS13-18-000A datasheet
- Pluto Servo Drive Installation Manual
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.