Jump to content

Component: Servo Motor Controller (Mechatronics)

From Flowcode Help
Revision as of 21:16, 27 January 2026 by Wiki bot (talk | contribs)
Author Matrix Ltd
Version 8.8
Category Mechatronics


Servo Motor Controller component

Can control up to eight standard PWM driven servo's. Supports 8-bit and 16-bit movement resolutions. 'Servo Object' properties allow you to connect the controller to on-screen simulations using the "Servo Motor" component and its derivatives.

Version information

Library Version, Component Version, Date, Author, Info
8, 8.0, 28-01-25, MW, Fixed bug that is preventing duty remain the same below 128, remins high above 127.


Detailed description

No detailed description exists yet for this component

Examples

Example showing how to control three servos using AutoMoveToPosion, MoveTopposition & SetPosition component macros.
Controlling Servos Example.fcfx

Example using BL0162 Servo controller for BL0055 Arduino Shield

Samples the Port D8-D13 (portB) switches and moves the servo motors based on the input states.

D8 increments motor 0, D9 decrements motor on channel 0.

D10 increments motor 1, D11 decrements motor on channel 1.

D12 increments motor 3, D13 decrements motor on channel 2.

Connections:

Servo Board Port D0-D2.

Switch Board Port D8 - D13

LCD A0 to A5 (PortC)

BL0162 Servos Example for BL0055

Macro reference

AutoMoveToAngle

AutoMoveToAngle
Automatically moves towards the new angle at a fixed rate determined by the AutoMoveSpeed. AutoMove not currently supported by ESP32. 
- BYTE Channel
The channel to assign the new position. Range: 0-7 
- BYTE Angle
Angle in degrees, Range 0 to calibration angle 
- VOID Return


AutoMoveToPosition

AutoMoveToPosition
Automatically moves towards the new position at a fixed rate determined by the AutoMoveSpeed. 
- BYTE Channel
The channel to assign the new position. Range: 0-7 
- BYTE Position
Position to automatically move to. Range: 0-255 
- VOID Return


AutoMoveToPositionInt

AutoMoveToPositionInt
Automatically moves towards the new 16-bit position at a fixed rate determined by the AutoMoveSpeed. 
- BYTE Channel
The channel to assign the new position. Range: 0-7 
- UINT Position
Position to automatically move to. Range: 0-65535 
- VOID Return


DisableServo

DisableServo
Disables a servo channel effectivly disabling the motor. 
- BYTE Channel
The channel to set the position for. First channel is zero. 
- VOID Return


EnableServo

EnableServo
Enables a servo channel effectivly setting the position of the motor to the value in the local position variable. 
- BYTE Channel
The channel to set the position for. First channel is zero. 
- VOID Return


Initialise

Initialise
Sets up the servo motor interrupts 
- VOID Return


IsAutoMoving

IsAutoMoving
Is the AutoMoveToPosition movement complete. Returns 1 if the servos are still moving. Returns 0 if all servo movement is complete. 
- BYTE Return


IsServoAutoMoving

IsServoAutoMoving
Is the AutoMoveToPosition movement complete for a specific servo output. Returns 1 if the servo is still moving. Returns 0 if the servo movement is complete. 
- BYTE Channel
Servo Motor Output Range: 0-7 
- BYTE Return


MoveToAngle

MoveToAngle
Moves a single step towards the new angle, the rate of movement is determined by how often the move to macro is called. Returns 1 if the position has been reached. 
- BYTE Channel
The channel to assign the new position. Range: 0-7 
- BYTE Angle
Angle in degrees, Range 0 to calibration angle 
- BOOL Return


MoveToPosition

MoveToPosition
Moves a single step towards the new position, the rate of movement is determined by how often the move to macro is called. Returns 1 if the position has been reached. 
- BYTE Channel
The channel to assign the new position. Range: 0-7 
- BYTE Position
Target position to move towards. Range: 0-255 
- BYTE Return


MoveToPositionInt

MoveToPositionInt
Moves a single step towards the new position, the rate of movement is determined by how often the move to macro is called. Returns 1 if the position has been reached. 
- BYTE Channel
The channel to assign the new position. Range: 0-7 
- UINT Position
Target position to move towards. Range: 0-65535 
- BYTE Return


SetAutoMoveSpeed

SetAutoMoveSpeed
Sets the speed of the auto move to position macro. Default speed is shown in the Servo_Period_Multiplier property. 
- BYTE Speed
1=Slowest (Default), 2= Double, 3=Triple, 4=Quadruple 
- VOID Return


SetAutoMoveSpeedInt

SetAutoMoveSpeedInt
Sets the speed of the auto move to position macro. Default speed is shown in the Servo_Period_Multiplier property. 
- UINT Speed
1=Slowest (Default), 2= Double, 3=Triple, 4=Quadruple 
- VOID Return


SetPosition

SetPosition
Moves directly to the specified position with no interpolation.  
- BYTE Channel
The channel to assign the new position. Range: 0-7 
- BYTE Position
Position to jump to. Range: 0-255 
- VOID Return


SetPositionInt

SetPositionInt
Moves directly to the specified position with no interpolation. Uses a 16-bit position parameter to add extra precision. 
- BYTE Channel
The channel to assign the new position. Range: 0-7 
- UINT Position
Position to jump to. Range: 0-65535 
- VOID Return


SetTrim

SetTrim
Allows the level of trim for each servo channel to be adjusted progmatically. 
- BYTE Channel
The channel to set the position for. First channel is zero. 
- BYTE Trim
Legacy: 0=0us, 1=+25us, 2=+50us, 3=+75us, 4=+100us, 5=-25us, 6=-50us, 7=-75us, 8=-100us or Smooth: 0-200 
- VOID Return


Property reference

Properties
Channels (1 - 8)
Set the number of servo's that you need to control. Value from 1 to 8. 
Connections
Channel 0
Pin on which to output PWM for the servo motor. 
Channel 1
Pin on which to output PWM for the servo motor. 
Channel 2
Pin on which to output PWM for the servo motor. 
Channel 3
Pin on which to output PWM for the servo motor. 
Channel 4
Pin on which to output PWM for the servo motor. 
Channel 5
Pin on which to output PWM for the servo motor. 
Channel 6
Pin on which to output PWM for the servo motor. 
Channel 7
Pin on which to output PWM for the servo motor. 
Resources
Peripherals
Lists the internal peripherals of the MCU used by the component. When the servo motor is initialised you will not be able to use the listed peripherals for other functionality. 
Trim
Trim Mode
 
Trim 0
Trim the pulse width for this channel. Use this to trim the positioning of two servos so that similar input values will produce the same degree of movement. 
Trim 1
Trim the pulse width for this channel. Use this to trim the positioning of two servos so that similar input values will produce the same degree of movement. 
Trim 2
Trim the pulse width for this channel. Use this to trim the positioning of two servos so that similar input values will produce the same degree of movement. 
Trim 3
Trim the pulse width for this channel. Use this to trim the positioning of two servos so that similar input values will produce the same degree of movement. 
Trim 4
Trim the pulse width for this channel. Use this to trim the positioning of two servos so that similar input values will produce the same degree of movement. 
Trim 5
Trim the pulse width for this channel. Use this to trim the positioning of two servos so that similar input values will produce the same degree of movement. 
Trim 6
Trim the pulse width for this channel. Use this to trim the positioning of two servos so that similar input values will produce the same degree of movement. 
Trim 7
Trim the pulse width for this channel. Use this to trim the positioning of two servos so that similar input values will produce the same degree of movement. 
Pulse Width
Minimum (us)
Shortest pulse width that will be used. 
Maximum (us)
Longest pulse width used for the PWM signals. 
Period Multiplier
Number of instructions for 1 / 256th of the positional accuracy. This sets the default movement speed to maintain legacy move speeds. Also sets the multiplication factor to convert from a byte 0-255 to a clocked position value. 
Simulation
Servo Object 0
Drag a servo motor component onto the System Panel, and then select it here, to create an on screen simulation of the way that your flowchart moves the servo's. Servo motors should be based on the 'Servo Motor Base' component, or use a custom component set to responf to 'User.Notify' events (ID = n/a, Data = Position (0-127)). 
Servo Object 1
Drag a servo motor component onto the System Panel, and then select it here, to create an on screen simulation of the way that your flowchart moves the servo's. Servo motors should be based on the 'Servo Motor Base' component, or use a custom component set to responf to 'User.Notify' events (ID = n/a, Data = Position (0-127)). 
Servo Object 2
Drag a servo motor component onto the System Panel, and then select it here, to create an on screen simulation of the way that your flowchart moves the servo's. Servo motors should be based on the 'Servo Motor Base' component, or use a custom component set to responf to 'User.Notify' events (ID = n/a, Data = Position (0-127)). 
Servo Object 3
Drag a servo motor component onto the System Panel, and then select it here, to create an on screen simulation of the way that your flowchart moves the servo's. Servo motors should be based on the 'Servo Motor Base' component, or use a custom component set to responf to 'User.Notify' events (ID = n/a, Data = Position (0-127)). 
Servo Object 4
Drag a servo motor component onto the System Panel, and then select it here, to create an on screen simulation of the way that your flowchart moves the servo's. Servo motors should be based on the 'Servo Motor Base' component, or use a custom component set to responf to 'User.Notify' events (ID = n/a, Data = Position (0-127)). 
Servo Object 5
Drag a servo motor component onto the System Panel, and then select it here, to create an on screen simulation of the way that your flowchart moves the servo's. Servo motors should be based on the 'Servo Motor Base' component, or use a custom component set to responf to 'User.Notify' events (ID = n/a, Data = Position (0-127)). 
Servo Object 6
Drag a servo motor component onto the System Panel, and then select it here, to create an on screen simulation of the way that your flowchart moves the servo's. Servo motors should be based on the 'Servo Motor Base' component, or use a custom component set to responf to 'User.Notify' events (ID = n/a, Data = Position (0-127)). 
Servo Object 7
Drag a servo motor component onto the System Panel, and then select it here, to create an on screen simulation of the way that your flowchart moves the servo's. Servo motors should be based on the 'Servo Motor Base' component, or use a custom component set to responf to 'User.Notify' events (ID = n/a, Data = Position (0-127)). 

Component Source Code

Please click here to download the component source project: FC_Comp_Source_Servo_Controller.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_Servo_Controller.fcfx