Component: DC Motor (Mechatronics): Difference between revisions
Appearance
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder"" |
|||
| (8 intermediate revisions by 3 users not shown) | |||
| Line 15: | Line 15: | ||
DC Motor that can be driven in one or both directions using digital output pins, PWM or HBRIDGE peripherals. | DC Motor that can be driven in one or both directions using digital output pins, PWM or HBRIDGE peripherals. | ||
== | ==Version information== | ||
Library Version, Component Version, Date, Author, Info | |||
2, 1.2, 13-11-24, BR, Altered property tooltips to make them more meaningful | |||
==Detailed description== | ==Detailed description== | ||
| Line 47: | Line 46: | ||
Simple example showing how to drive the motor component by only using Enable and two port pins. | |||
{{Fcfile|DC_Motor_pin_control.fcfx|DC Motor pin control}} | |||
==Macro reference== | ==Macro reference== | ||
===Break=== | ===Break=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Break''' | ||
|- | |- | ||
| colspan="2" | Actively drives both ends of the motor by setting the pins according to the 'Brake Pattern' property. | | colspan="2" | Actively drives both ends of the motor by setting the pins according to the 'Brake Pattern' property. | ||
| Line 82: | Line 67: | ||
===Coast=== | ===Coast=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Coast''' | ||
|- | |- | ||
| colspan="2" | Turn off power to the motor by setting the pins according to the 'Coast Pattern' property. | | colspan="2" | Turn off power to the motor by setting the pins according to the 'Coast Pattern' property. | ||
| Line 96: | Line 81: | ||
===Disable=== | ===Disable=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Disable''' | ||
|- | |- | ||
| colspan="2" | Disable the motor output | | colspan="2" | Disable the motor output | ||
| Line 110: | Line 95: | ||
===Enable=== | ===Enable=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Enable''' | ||
|- | |- | ||
| colspan="2" | Enables the motor output | | colspan="2" | Enables the motor output | ||
| Line 124: | Line 109: | ||
===Forwards=== | ===Forwards=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Forwards''' | ||
|- | |- | ||
| colspan="2" | Set the motor turning in the forwards direction by setting the pins according to the 'Forwards Pattern' property. | | colspan="2" | Set the motor turning in the forwards direction by setting the pins according to the 'Forwards Pattern' property. | ||
| Line 143: | Line 128: | ||
===GetSimAngle=== | ===GetSimAngle=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''GetSimAngle''' | ||
|- | |- | ||
| colspan="2" | Gets the angle of the simulated motor shaft in degrees. | | colspan="2" | Gets the angle of the simulated motor shaft in degrees. | ||
| Line 157: | Line 142: | ||
===Reverse=== | ===Reverse=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Reverse''' | ||
|- | |- | ||
| colspan="2" | Set the motor turning in the reverse direction by setting the pins according to the 'Reverse Pattern' property. | | colspan="2" | Set the motor turning in the reverse direction by setting the pins according to the 'Reverse Pattern' property. | ||
| Line 177: | Line 162: | ||
==Property reference== | ==Property reference== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Properties''' | ||
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]] | ||
| width="90%" | | width="90%" class="mtx-class-propfolder" | Control Type | ||
|- | |- | ||
|- | |- | ||
| Line 190: | Line 175: | ||
| width="90%" | Control Method | | width="90%" | Control Method | ||
|- | |- | ||
| colspan="2" | Controls how the motor is controlled. On/Off requires output pins PWM requires a hardware PWM channel H-Bridge requires a hardware H-Bridge channel | | colspan="2" | Controls how the motor is controlled. On/Off requires basic output pins, motor is full speed or stopped. PWM requires a hardware PWM channel and allows the motor speed to be controlled. H-Bridge requires a hardware H-Bridge channel and allows the motor speed to be controlled. | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | ||
| width="90%" | Bridge Type | | width="90%" | Bridge Type | ||
|- | |- | ||
| colspan="2" | | | colspan="2" | Half Bridge - Motor can only be controlled in one direction. Full Bridge - Motor can be controlled in both directions. | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | ||
| Line 202: | Line 187: | ||
| colspan="2" | Decides how the motor outputs are enabled. | | colspan="2" | Decides how the motor outputs are enabled. | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]] | ||
| width="90%" | | width="90%" class="mtx-class-propfolder" | Connections | ||
|- | |- | ||
|- | |- | ||
| Line 236: | Line 221: | ||
| colspan="2" | States of pins A and B required to stop the motor. | | colspan="2" | States of pins A and B required to stop the motor. | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]] | ||
| width="90%" | | width="90%" class="mtx-class-propfolder" | Software PWM Settings | ||
|- | |||
|- | |||
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | |||
| width="90%" | Timer | |||
|- | |||
| colspan="2" | Timer Peripheral to use to monitor the passage of time. | |||
|- | |||
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | |||
| width="90%" | Prescaler | |||
|- | |||
| colspan="2" | Scaler applied to the timer, Small scalers allow for finer resolution but will limit the max time and also put more load on the microcontroller. Recommended to use as large a setting as possible which still provides enough accuracy. | |||
|- | |||
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]] | |||
| width="90%" | Resolution | |||
|- | |||
| colspan="2" | Number of discrete values that the duty can have. e.g. 16 would allow duty values of 0-15 Recommend keeping this value low to avoid excessive amounts of interrupts. | |||
|- | |||
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]] | |||
| width="90%" | Frequency (Hz) | |||
|- | |||
| colspan="2" | The frequency of the PWM output in Hz. Recommend keeping this low as possible to avoid having excessive amounts of interrupts. | |||
|- | |||
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]] | |||
| width="90%" | Required Interrupt Rate (Hz) | |||
|- | |||
| colspan="2" | The calculated required rate of interrupts | |||
|- | |||
| width="10%" align="center" | [[File:Fc9-type-15-icon.png]] | |||
| width="90%" | Accuracy | |||
|- | |||
| colspan="2" | How close we can get to the required timings with the selected timer and prescaler | |||
|- | |||
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | |||
| width="90%" | Off Time Setting | |||
|- | |||
| colspan="2" | Decides what to do when output PWM output is low. | |||
|- | |||
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]] | |||
| width="90%" class="mtx-class-propfolder" | Simulation Settings | |||
|- | |- | ||
|- | |- | ||
| Line 250: | Line 274: | ||
| colspan="2" | Speed of the motor when turned on. Positive speed -> Counter-clockwsie Negative speed -> Clockwise | | colspan="2" | Speed of the motor when turned on. Positive speed -> Counter-clockwsie Negative speed -> Clockwise | ||
|} | |} | ||
==Component Source Code== | |||
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_DCMotor_2d.fcfx FC_Comp_Source_DCMotor_2d.fcfx] | |||
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_DCMotor_2d.fcfx FC_Comp_Source_DCMotor_2d.fcfx] | |||
Latest revision as of 14:37, 13 July 2026
| Author | Matrix TSL |
| Version | 1.2 |
| Category | Mechatronics |
DC Motor component
DC Motor that can be driven in one or both directions using digital output pins, PWM or HBRIDGE peripherals.
Version information
Library Version, Component Version, Date, Author, Info 2, 1.2, 13-11-24, BR, Altered property tooltips to make them more meaningful
Detailed description
No detailed description exists yet for this component
Examples
Simple example showing how to drive the motor component by only using Enable and two port pins.
Macro reference
Break
| Break | |
| Actively drives both ends of the motor by setting the pins according to the 'Brake Pattern' property. | |
| Return | |
Coast
| Coast | |
| Turn off power to the motor by setting the pins according to the 'Coast Pattern' property. | |
| Return | |
Disable
| Disable | |
| Disable the motor output | |
| Return | |
Enable
| Enable | |
| Enables the motor output | |
| Return | |
Forwards
| Forwards | |
| Set the motor turning in the forwards direction by setting the pins according to the 'Forwards Pattern' property. | |
| Duty | |
| Sets the motor power for PWM or H-Bridge outputs | |
| Return | |
GetSimAngle
| GetSimAngle | |
| Gets the angle of the simulated motor shaft in degrees. | |
| Return | |
Reverse
| Reverse | |
| Set the motor turning in the reverse direction by setting the pins according to the 'Reverse Pattern' property. | |
| Duty | |
| Sets the motor power for PWM or H-Bridge outputs | |
| Return | |
Property reference
Component Source Code
Please click here to download the component source project: FC_Comp_Source_DCMotor_2d.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_DCMotor_2d.fcfx