Jump to content

Component: Servo Motor Controller (Mechatronics): Difference between revisions

From Flowcode Help
No edit summary
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder""
 
(25 intermediate revisions by 3 users not shown)
Line 5: Line 5:
|-
|-
| width="20%" style="color:gray;" | Version
| width="20%" style="color:gray;" | Version
| 2.1
| 8.8
|-
|-
| width="20%" style="color:gray;" | Category
| width="20%" style="color:gray;" | Category
Line 15: Line 15:
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.  
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.  


==Component Source Code==
==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.


Please click here for the component source code: [https://www.flowcode.co.uk/wikicopy/componentsource/FC_Comp_Source_Servo_Controller.fcfx FC_Comp_Source_Servo_Controller.fcfx]


==Detailed description==
==Detailed description==




Line 29: Line 39:




''<span style="color:red;">No additional examples</span>''
 
 
 
 
Example showing how to control three servos using AutoMoveToPosion, MoveTopposition & SetPosition component macros.<br>
{{Fcfile|Controlling_Servos_Example.fcfx|Controlling Servos Example.fcfx}}<br><br>
 
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)
 
{{Fcfile|BL0162_Servo_BL0055.fcfx|BL0162 Servos Example for BL0055}}<br><br>


==Macro reference==
==Macro reference==


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===AutoMoveToAngle===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DisableServo'''
| width="90%" class="mtx-class-macrohead" | '''AutoMoveToAngle'''
|-
|-
| colspan="2" | Disables a servo channel effectivly disabling the motor.&nbsp;
| colspan="2" | Automatically moves towards the new angle at a fixed rate determined by the AutoMoveSpeed. AutoMove not currently supported by ESP32.&nbsp;
|-
|-
|-
|-
Line 44: Line 80:
| width="90%" | Channel
| width="90%" | Channel
|-
|-
| colspan="2" | The channel to set the position for. First channel is zero.&nbsp;
| colspan="2" | The channel to assign the new position. Range: 0-7&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Angle
|-
| colspan="2" | Angle in degrees, Range 0 to calibration angle&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 51: Line 92:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===AutoMoveToPosition===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetPosition'''
| width="90%" class="mtx-class-macrohead" | '''AutoMoveToPosition'''
|-
|-
| colspan="2" | Moves directly to the specified position with no interpolation. &nbsp;
| colspan="2" | Automatically moves towards the new position at a fixed rate determined by the AutoMoveSpeed.&nbsp;
|-
|-
|-
|-
Line 67: Line 109:
| width="90%" | Position
| width="90%" | Position
|-
|-
| colspan="2" | Position to jump to. Range: 0-255&nbsp;
| colspan="2" | Position to automatically move to. Range: 0-255&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 74: Line 116:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===AutoMoveToPositionInt===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MoveToPositionInt'''
| width="90%" class="mtx-class-macrohead" | '''AutoMoveToPositionInt'''
|-
|-
| colspan="2" | 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.&nbsp;
| colspan="2" | Automatically moves towards the new 16-bit position at a fixed rate determined by the AutoMoveSpeed.&nbsp;
|-
|-
|-
|-
Line 90: Line 133:
| width="90%" | Position
| width="90%" | Position
|-
|-
| colspan="2" | Target position to move towards. Range: 0-65535&nbsp;
| colspan="2" | Position to automatically move to. Range: 0-65535&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===DisableServo===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetPositionInt'''
| width="90%" class="mtx-class-macrohead" | '''DisableServo'''
|-
|-
| colspan="2" | Moves directly to the specified position with no interpolation. Uses a 16-bit position parameter to add extra precision.&nbsp;
| colspan="2" | Disables a servo channel effectivly disabling the motor.&nbsp;
|-
|-
|-
|-
Line 108: Line 152:
| width="90%" | Channel
| width="90%" | Channel
|-
|-
| colspan="2" | The channel to assign the new position. Range: 0-7&nbsp;
| colspan="2" | The channel to set the position for. First channel is zero.&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Position
|-
| colspan="2" | Position to jump to. Range: 0-65535&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 120: Line 159:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===EnableServo===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MoveToPosition'''
| width="90%" class="mtx-class-macrohead" | '''EnableServo'''
|-
|-
| colspan="2" | 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.&nbsp;
| colspan="2" | Enables a servo channel effectivly setting the position of the motor to the value in the local position variable.&nbsp;
|-
|-
|-
|-
Line 131: Line 171:
| width="90%" | Channel
| width="90%" | Channel
|-
|-
| colspan="2" | The channel to assign the new position. Range: 0-7&nbsp;
| colspan="2" | The channel to set the position for.  First channel is zero.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" | Position
|-
| colspan="2" | Target position to move towards. Range: 0-255&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===Initialise===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTrim'''
| width="90%" class="mtx-class-macrohead" | '''Initialise'''
|-
|-
| colspan="2" | Allows the level of trim for each servo channel to be adjusted progmatically.&nbsp;
| colspan="2" | Sets up the servo motor interrupts&nbsp;
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" | Channel
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
 
 
===IsAutoMoving===
{| class="mtx-class-macrotable wikitable"
|-
|-
| colspan="2" | The channel to set the position for. First channel is zero.&nbsp;
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''IsAutoMoving'''
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| colspan="2" | Is the AutoMoveToPosition movement complete.  Returns 1 if the servos are still moving.  Returns 0 if all servo movement is complete.&nbsp;
| width="90%" | Trim
|-
|-
| colspan="2" | Legacy: 0=0us, 1=+25us, 2=+50us, 3=+75us, 4=+100us, 5=-25us, 6=-50us, 7=-75us, 8=-100us or Smooth: 0-200&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===IsServoAutoMoving===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''IsAutoMoving'''
| width="90%" class="mtx-class-macrohead" | '''IsServoAutoMoving'''
|-
|-
| colspan="2" | Is the AutoMoveToPosition movement complete.   Returns 1 if the servos are still moving. Returns 0 if all servo movement is complete.&nbsp;
| colspan="2" | 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.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
|-
| colspan="2" | Servo Motor Output Range: 0-7&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
Line 179: Line 225:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===MoveToAngle===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''MoveToAngle'''
|-
| colspan="2" | 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.&nbsp;
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetAutoMoveSpeedInt'''
|-
|-
| colspan="2" | Sets the speed of the auto move to position macro. Default speed is shown in the Servo_Period_Multiplier property.&nbsp;
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
|-
| colspan="2" | The channel to assign the new position. Range: 0-7&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Speed
| width="90%" | Angle
|-
|-
| colspan="2" | 1=Slowest (Default), 2= Double, 3=Triple, 4=Quadruple&nbsp;
| colspan="2" | Angle in degrees, Range 0 to calibration angle&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===MoveToPosition===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''IsServoAutoMoving'''
| width="90%" class="mtx-class-macrohead" | '''MoveToPosition'''
|-
|-
| colspan="2" | 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.&nbsp;
| colspan="2" | 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.&nbsp;
|-
|-
|-
|-
Line 208: Line 261:
| width="90%" | Channel
| width="90%" | Channel
|-
|-
| colspan="2" | Servo Motor Output Range: 0-7&nbsp;
| colspan="2" | The channel to assign the new position. Range: 0-7&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Position
|-
| colspan="2" | Target position to move towards. Range: 0-255&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
Line 215: Line 273:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===MoveToPositionInt===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AutoMoveToPosition'''
| width="90%" class="mtx-class-macrohead" | '''MoveToPositionInt'''
|-
|-
| colspan="2" | Automatically moves towards the new position at a fixed rate determined by the AutoMoveSpeed.&nbsp;
| colspan="2" | 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.&nbsp;
|-
|-
|-
|-
Line 228: Line 287:
| colspan="2" | The channel to assign the new position. Range: 0-7&nbsp;
| colspan="2" | The channel to assign the new position. Range: 0-7&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Position
| width="90%" | Position
|-
|-
| colspan="2" | Position to automatically move to. Range: 0-255&nbsp;
| colspan="2" | Target position to move towards. Range: 0-65535&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===SetAutoMoveSpeed===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''EnableServo'''
| width="90%" class="mtx-class-macrohead" | '''SetAutoMoveSpeed'''
|-
|-
| colspan="2" | Enables a servo channel effectivly setting the position of the motor to the value in the local position variable.&nbsp;
| colspan="2" | Sets the speed of the auto move to position macro.  Default speed is shown in the Servo_Period_Multiplier property.&nbsp;
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
| width="90%" | Speed
|-
|-
| colspan="2" | The channel to set the position for.  First channel is zero.&nbsp;
| colspan="2" | 1=Slowest (Default), 2= Double, 3=Triple, 4=Quadruple&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 256: Line 316:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===SetAutoMoveSpeedInt===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetAutoMoveSpeed'''
| width="90%" class="mtx-class-macrohead" | '''SetAutoMoveSpeedInt'''
|-
|-
| colspan="2" | Sets the speed of the auto move to position macro.  Default speed is shown in the Servo_Period_Multiplier property.&nbsp;
| colspan="2" | Sets the speed of the auto move to position macro.  Default speed is shown in the Servo_Period_Multiplier property.&nbsp;
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Speed
| width="90%" | Speed
|-
|-
Line 274: Line 335:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===SetPosition===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AutoMoveToPositionInt'''
| width="90%" class="mtx-class-macrohead" | '''SetPosition'''
|-
|-
| colspan="2" | Automatically moves towards the new 16-bit position at a fixed rate determined by the AutoMoveSpeed.&nbsp;
| colspan="2" | Moves directly to the specified position with no interpolation. &nbsp;
|-
|-
|-
|-
Line 287: Line 349:
| colspan="2" | The channel to assign the new position. Range: 0-7&nbsp;
| colspan="2" | The channel to assign the new position. Range: 0-7&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Position
| width="90%" | Position
|-
|-
| colspan="2" | Position to automatically move to. Range: 0-65535&nbsp;
| colspan="2" | Position to jump to. Range: 0-255&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 297: Line 359:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===SetPositionInt===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''SetPositionInt'''
|-
| colspan="2" | Moves directly to the specified position with no interpolation. Uses a 16-bit position parameter to add extra precision.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| colspan="2" | The channel to assign the new position. Range: 0-7&nbsp;
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
|-
|-
| colspan="2" | Sets up the servo motor interrupts&nbsp;
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Position
|-
|-
| colspan="2" | Position to jump to. Range: 0-65535&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 310: Line 383:




===SetTrim===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''SetTrim'''
|-
| colspan="2" | Allows the level of trim for each servo channel to be adjusted progmatically.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | The channel to set the position for.  First channel is zero.&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Trim
|-
| colspan="2" | Legacy: 0=0us, 1=+25us, 2=+50us, 3=+75us, 4=+100us, 5=-25us, 6=-50us, 7=-75us, 8=-100us or Smooth: 0-200&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




==Property reference==
==Property reference==


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
| width="90%" class="mtx-class-macrohead" | '''Properties'''  
|-
|-
|-
|-
Line 325: Line 420:
| colspan="2" | Set the number of servo's that you need to control. Value from 1 to 8.&nbsp;
| colspan="2" | Set the number of servo's that you need to control. Value from 1 to 8.&nbsp;
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Connections
| width="90%" class="mtx-class-propfolder" | Connections
|-
|-
|-
|-
Line 369: Line 464:
| colspan="2" | Pin on which to output PWM for the servo motor.&nbsp;
| colspan="2" | Pin on which to output PWM for the servo motor.&nbsp;
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Resources
| width="90%" class="mtx-class-propfolder" | Resources
|-
|-
|-
|-
Line 378: Line 473:
| colspan="2" | 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.&nbsp;
| colspan="2" | 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.&nbsp;
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Trim
| width="90%" class="mtx-class-propfolder" | Trim
|-
|-
|-
|-
Line 427: Line 522:
| colspan="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.&nbsp;
| colspan="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.&nbsp;
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Pulse Width
| width="90%" class="mtx-class-propfolder" | Pulse Width
|-
|-
|-
|-
Line 446: Line 541:
| colspan="2" | 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.&nbsp;
| colspan="2" | 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.&nbsp;
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
| width="90%" class="mtx-class-propfolder" | Simulation
|-
|-
|-
|-
Line 490: Line 585:
| colspan="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)).&nbsp;
| colspan="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)).&nbsp;
|}
|}
==Component Source Code==
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_Servo_Controller.fcfx FC_Comp_Source_Servo_Controller.fcfx]
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_Servo_Controller.fcfx FC_Comp_Source_Servo_Controller.fcfx]

Latest revision as of 14:37, 13 July 2026

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