Jump to content

Component: DC Motor (Mechatronics): Difference between revisions

From Flowcode Help
m Text replacement - "width="10%" align="center" style="background-color:#D8C9D8;"" to "width="10%" align="center" class="mtx-class-macrohead""
m Text replacement - "width="90%" style="background-color:#D8C9D8; color:#4B008D;"" to "width="90%" class="mtx-class-macrohead""
Line 56: Line 56:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[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;" | '''Break'''
| 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 70: Line 70:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[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;" | '''Coast'''
| 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 84: Line 84:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[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;" | '''Disable'''
| width="90%" class="mtx-class-macrohead" | '''Disable'''
|-
|-
| colspan="2" | Disable the motor output 
| colspan="2" | Disable the motor output 
Line 98: Line 98:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[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;" | '''Enable'''
| width="90%" class="mtx-class-macrohead" | '''Enable'''
|-
|-
| colspan="2" | Enables the motor output 
| colspan="2" | Enables the motor output 
Line 112: Line 112:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[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;" | '''Forwards'''
| 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 131: Line 131:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[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;" | '''GetSimAngle'''
| 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 145: Line 145:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[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;" | '''Reverse'''
| 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 165: Line 165:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[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'''  
|-
|-
|-
|-

Revision as of 14:22, 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.

DC Motor pin control

Macro reference

Break

Break
Actively drives both ends of the motor by setting the pins according to the 'Brake Pattern' property. 
- VOID Return


Coast

Coast
Turn off power to the motor by setting the pins according to the 'Coast Pattern' property. 
- VOID Return


Disable

Disable
Disable the motor output 
- VOID Return


Enable

Enable
Enables the motor output 
- VOID Return


Forwards

Forwards
Set the motor turning in the forwards direction by setting the pins according to the 'Forwards Pattern' property. 
- UINT Duty
Sets the motor power for PWM or H-Bridge outputs 
- VOID Return


GetSimAngle

GetSimAngle
Gets the angle of the simulated motor shaft in degrees. 
- FLOAT Return


Reverse

Reverse
Set the motor turning in the reverse direction by setting the pins according to the 'Reverse Pattern' property. 
- UINT Duty
Sets the motor power for PWM or H-Bridge outputs 
- VOID Return


Property reference

Properties
Control Type
Control Method
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. 
Bridge Type
Half Bridge - Motor can only be controlled in one direction. Full Bridge - Motor can be controlled in both directions. 
Enable Method
Decides how the motor outputs are enabled. 
Connections
PinA
First control pin - set 'pattern' properties below to set the pin's function. 
PinB
Second control pin - set 'pattern' properties below to set the pin's function. 
Forwards Pattern
The state of pins A and B required to drive the motor in a forwards direction. 
Reverse Pattern
States of pins A and B required to drive the motor in a reverse direction. 
Coast Pattern
States of pins A and B required to stop the motor. 
Brake Pattern
States of pins A and B required to stop the motor. 
Software PWM Settings
Timer
Timer Peripheral to use to monitor the passage of time. 
Prescaler
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.  
Resolution
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. 
Frequency (Hz)
The frequency of the PWM output in Hz. Recommend keeping this low as possible to avoid having excessive amounts of interrupts. 
Required Interrupt Rate (Hz)
The calculated required rate of interrupts 
Accuracy
How close we can get to the required timings with the selected timer and prescaler 
Off Time Setting
Decides what to do when output PWM output is low. 
Simulation Settings
Label Colour
 
Speed
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: FC_Comp_Source_DCMotor_2d.fcfx

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