Jump to content

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

From Flowcode Help
No edit summary
No edit summary
Line 17: Line 17:
==Component Source Code==
==Component Source Code==


Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_Servo_Controller_Mod.fcfx FC_Comp_Source_Servo_Controller_Mod.fcfx]
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_temp/Servo_Controller_Mod.fcfx FC_Comp_Source_temp/Servo_Controller_Mod.fcfx]


Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_Servo_Controller_Mod.fcfx FC_Comp_Source_Servo_Controller_Mod.fcfx]
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_temp/Servo_Controller_Mod.fcfx FC_Comp_Source_temp/Servo_Controller_Mod.fcfx]


==Detailed description==
==Detailed description==
Line 96: Line 96:


[[File:LinkedServo.jpg]]
[[File:LinkedServo.jpg]]




Line 103: Line 105:
==Macro reference==
==Macro reference==


===DisableServo===
===AutoMoveToPosition===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DisableServo'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AutoMoveToPosition'''
|-
|-
| colspan="2" | Disables a servo channel effectivly disabling the motor. 
| colspan="2" | Automatically moves towards the new position with a fixed rate of 100 steps per second. 
|-
|-
|-
|-
Line 116: Line 118:
|-
|-
| colspan="2" | The channel to set the position for.  First channel is zero. 
| colspan="2" | The channel to set the position for.  First channel is zero. 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Position
|-
| colspan="2" | Position to move to. 
|-
|-
| 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 122: Line 129:




===SetPosition===
===DisableServo===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetPosition'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DisableServo'''
|-
|-
| colspan="2" | Moves directly to the specified position with no interpolation. 
| colspan="2" | Disables a servo channel effectivly disabling the motor. 
|-
|-
|-
|-
Line 135: Line 142:
|-
|-
| colspan="2" | The channel to set the position for.  First channel is zero. 
| colspan="2" | The channel to set the position for.  First channel is zero. 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Position
|-
| colspan="2" | Target position to move towards. 
|-
|-
| 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 146: Line 148:




===MoveToPosition===
===EnableServo===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MoveToPosition'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''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. 
| colspan="2" | Enables a servo channel effectivly setting the position of the motor to the value in the local position variable. 
|-
|-
|-
|-
Line 160: Line 162:
| colspan="2" | The channel to set the position for.  First channel is zero. 
| colspan="2" | The channel to set the position for.  First channel is zero. 
|-
|-
| 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. 
|-
| 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''
|}
|}




===SetTrim===
===Initialise===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTrim'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
|-
|-
| colspan="2" | Allows the level of trim for each servo channel to be adjusted progmatically. 
| colspan="2" | Sets up the servo motor interrupts 
|-
|-
| 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. 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Trim
|-
|-
| colspan="2" | 0=0us, 1=+25us, 2=+50us, 3=+75us, 4=+100us, 5=-25us, 6=-50us, 7=-75us, 8=-100us 
|-
|-
| 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 208: Line 195:




===AutoMoveToPosition===
===MoveToPosition===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AutoMoveToPosition'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MoveToPosition'''
|-
|-
| colspan="2" | Automatically moves towards the new position with a fixed rate of 100 steps per second. 
| 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. 
|-
|-
|-
|-
Line 225: Line 212:
| width="90%" | Position
| width="90%" | Position
|-
|-
| colspan="2" | Position to move to. 
| colspan="2" | Target position to move towards. 
|-
|-
| 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''
|}
|}




===EnableServo===
===SetAutoMoveSpeed===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''EnableServo'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetAutoMoveSpeed'''
|-
|-
| colspan="2" | Enables a servo channel effectivly setting the position of the motor to the value in the local position variable. 
| colspan="2" | Sets the speed of the auto move to position macro. Default speed is 1. 
|-
|-
|-
|-
| 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. 
| colspan="2" | 1=Slowest (Default), 2= Double, 3=Triple, 4=Quadruple 
|-
|-
| 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 251: Line 238:




===SetAutoMoveSpeed===
===SetPosition===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetAutoMoveSpeed'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetPosition'''
|-
| colspan="2" | Moves directly to the specified position with no interpolation. 
|-
|-
|-
| colspan="2" | Sets the speed of the auto move to position macro. Default speed is 1. 
| 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. 
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Speed
| width="90%" | Position
|-
|-
| colspan="2" | 1=Slowest (Default), 2= Double, 3=Triple, 4=Quadruple 
| colspan="2" | Target position to move towards. 
|-
|-
| 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 270: Line 262:




===Initialise===
===SetTrim===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTrim'''
|-
| colspan="2" | Allows the level of trim for each servo channel to be adjusted progmatically. 
|-
|-
| 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. 
|-
|-
| colspan="2" | Sets up the servo motor interrupts 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Trim
|-
|-
| colspan="2" | 0=0us, 1=+25us, 2=+50us, 3=+75us, 4=+100us, 5=-25us, 6=-50us, 7=-75us, 8=-100us 
|-
|-
| 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

Revision as of 12:03, 3 February 2023

Author Matrix Ltd
Version 1.5
Category Mechatronics


Servo Controller Mod component

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

Component Source Code

Please click here to download the component source project: FC_Comp_Source_temp/Servo_Controller_Mod.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_temp/Servo_Controller_Mod.fcfx

Detailed description

No detailed description exists yet for this component

Examples

Importing from v5

The servo component in Flowcode v6 onwards has a new Initialise macro which will need to be added to your program before any other calls to the servo motor component are made.

Controlling a servo with an analogue input

This example reads the value of the analogue potentiometer and uses this to set the position of the servo motor. Servo Example 1 The Servo controller is linked to the standard servo component but this could be linked to any object on the panel.


Creating a multi-axis actuator using servo motors

This example links two servo motors together using panel primitive objects and groups. Servo Example 2 The Servo controller can handle up to 8 motors and is used to control both of the standard servo components on the panel.




Macro reference

AutoMoveToPosition

AutoMoveToPosition
Automatically moves towards the new position with a fixed rate of 100 steps per second. 
- BYTE Channel
The channel to set the position for. First channel is zero. 
- BYTE Position
Position to move to. 
- 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 servo is still moving. Returns 0 if the servo movement is complete. 
- BYTE 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 set the position for. First channel is zero. 
- BYTE Position
Target position to move towards. 
- BYTE Return


SetAutoMoveSpeed

SetAutoMoveSpeed
Sets the speed of the auto move to position macro. Default speed is 1. 
- BYTE 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 set the position for. First channel is zero. 
- BYTE Position
Target position to move towards. 
- 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
0=0us, 1=+25us, 2=+50us, 3=+75us, 4=+100us, 5=-25us, 6=-50us, 7=-75us, 8=-100us 
- 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. 
Trim
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. 
Pulse Width
Minimum (us)
Shortest pulse width that will be used. 
Maximum (us)
Longest pulse width used for the PWM signals. 
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)).