Jump to content

Component: Grove I2C Motor Driver (Mechatronics): Difference between revisions

From Flowcode Help
Created page with "{| style="width:50%" |- | width="20%" style="color:gray;" | Author | Matrix TSL |- | width="20%" style="color:gray;" | Version | 1.0 |- | width="20%" style="color:gray..."
 
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder""
 
(6 intermediate revisions by 2 users not shown)
Line 20: Line 20:


Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_Grove_I2C_Motor_Driver.fcfx FC_Comp_Source_Grove_I2C_Motor_Driver.fcfx]
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_Grove_I2C_Motor_Driver.fcfx FC_Comp_Source_Grove_I2C_Motor_Driver.fcfx]
==Detailed description==
Mechanical encoders can be a bit electrically noisy when switching and so to have reliable operation it is recommended to have a simple filter as shown here.
[[Image:EncoderCircuit.jpg]]
==Examples==
===Polling===
Example program showing how to use a quadrature encoder component using a polling method.
{{Fcfile|Quad_Encoder_Test_2d.fcfx|Quad_Encoder_Test}}
===Timer Interrupt Based Polling===
Example program showing how to use a quadrature encoder component using a polling method via a timer interrupt.
{{Fcfile|Quad_Encoder_Timer_2d.fcfx|Quad_Encoder_Timer}}
===Interrupt On Change===
Example program showing how to use a quadrature encoder component using a interrupt on pin state change interrupt (IOC).
{{Fcfile|Quad_Encoder_IOC_2d.fcfx|Quad_Encoder_IOC}}




Line 54: Line 25:


===Frequency===
===Frequency===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| 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;" | '''Frequency'''
| width="90%" class="mtx-class-macrohead" | '''Frequency'''
|-
|-
| colspan="2" | Set the frequency of PWM (cycle length = 510, system clock = 16MHz) 
| colspan="2" | Set the frequency of PWM (cycle length = 510, system clock = 16MHz) 
Line 73: Line 44:


===Initialise===
===Initialise===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| 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;" | '''Initialise'''
| width="90%" class="mtx-class-macrohead" | '''Initialise'''
|-
|-
| colspan="2" | Sets up the I2C ready for communications 
| colspan="2" | Sets up the I2C ready for communications 
Line 87: Line 58:


===Speed===
===Speed===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| 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;" | '''Speed'''
| width="90%" class="mtx-class-macrohead" | '''Speed'''
|-
|-
| colspan="2" | Sets the speed of a motor. 
| colspan="2" | Sets the speed of a motor. 
Line 111: Line 82:


===Stop===
===Stop===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| 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;" | '''Stop'''
| width="90%" class="mtx-class-macrohead" | '''Stop'''
|-
|-
| colspan="2" | Stop one motor 
| colspan="2" | Stop one motor 
Line 131: Line 102:
==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'''  
|-
|-
|-
|-
| 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;" | Communications
| width="90%" class="mtx-class-propfolder" | Communications
|-
|-
|-
|-
Line 181: Line 152:
| colspan="2" |  
| colspan="2" |  
|-
|-
| 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
|-
|-
|-
|-

Latest revision as of 14:36, 13 July 2026

Author Matrix TSL
Version 1.0
Category Mechatronics


Grove I2C Motor Driver component

A grove board based around the L298P motor driver IC allowing control of two DC motors or a single stepper motor.

Component Source Code

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

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


Macro reference

Frequency

Frequency
Set the frequency of PWM (cycle length = 510, system clock = 16MHz) 
- BYTE FrequencySelection
1=31.372 KHz, 2=3.921 KHz, 3=490 Hz, 4=122 Hz, 5=30 Hz 
- VOID Return


Initialise

Initialise
Sets up the I2C ready for communications 
- VOID Return


Speed

Speed
Sets the speed of a motor. 
- BYTE Motor
1=Motor1 / 2=Motor2 
- INT Speed
Range: -255 to 255 where -255 = Full Backwards, 0=Stop, 255=Full Forwards 
- VOID Return


Stop

Stop
Stop one motor 
- BYTE Motor
1 = Motor1 / 2 = Motor2 
- VOID Return


Property reference

Properties
Communications
I2C Address
 
Channel
Channel selection 
SDA
Pin used for SDA (data signal) 
SCL
Pin used for SCL (clock signal) 
Stop Delay
On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not a 10ms delay between an I2C stop event and the next I2C start event. Most modern microcontrollers will not have a problem so this property can be disabled to speed up the I2C communications.  
Baud Select
Baud rate option selector 
Baud Rate
Baud rate to be used 
Default Frequency
 
Simulation
Scope Traces
Selects if the component pin connections are automatically generated on the data recorder window or not. Yes: Automatically add the component pins to a group on the data recorder which will reflect the sim data during simultion. No: Do not show the pin signals on the data recorder window. 
Console Data
Selects if the console data is automatically generated or not 
API
Specifies the API component on the panel to interact with to provide comms simulation.