Honza T. / Mbed 2 deprecated DC_motor_control_test

Dependencies:   FastPWM mbed FastIO MODSERIAL

Embed: (wiki syntax)

« Back to documentation index

main.cpp File Reference

main.cpp File Reference

Basic DC motor control test, rpm feedback by simple impulse signal, PID speed control. More...

Go to the source code of this file.

Functions

static void tskImpSens (void)
 RPM calculation.
static void tskLEDBlink (void)
 User LED flashing.
static void tskPWMWrite (void)
 Writes new duty cycle value into PWM generator.
static void tskRPMSetpoint (void)
 Implementation of periodic change of RPM Setpoint.
static void tskBackground (void)
 Implementation of background task.
static void setup (void)
 System initialization - called at the prologue of main().

Detailed Description

Basic DC motor control test, rpm feedback by simple impulse signal, PID speed control.

Author:
Jan Tetour <jan.tetour@gmail.com>

Test application for STM32F4 for small DC motor control. Main specifications:

  • DC motor controlled by PWM
  • Motor driver used L298N
  • RPM evaluated via simple impulse sensor
  • Speed (RPM) controlled by PID controller

Definition in file main.cpp.


Function Documentation

void setup ( void   ) [static]

System initialization - called at the prologue of main().

Note:
None.

Caries out system level initialization at the beginning of the main().

Definition at line 120 of file main.cpp.

void tskBackground ( void   ) [static]

Implementation of background task.

Periodically called from main loop without delay.

Note:
These actions are candidates for refactoring to event based implementation.
Warning:
Initial implementation. Simple and easy.

This function implements actions, which needs to be processed with high priority. Is intended to be called in every pass of main loop.

Definition at line 224 of file main.cpp.

void tskImpSens ( void   ) [static]

RPM calculation.

Note:
Needs refactoring to implement ifdef for 2 different implementation (with/without PID).

Stores impulse count per measurement period and clears impulse counter.

Definition at line 152 of file main.cpp.

void tskLEDBlink ( void   ) [static]

User LED flashing.

Implements User LED flashing.

Definition at line 165 of file main.cpp.

void tskPWMWrite ( void   ) [static]

Writes new duty cycle value into PWM generator.

Note:
Needs refactoring to implement ifdef for 2 different implementation (with/without PID).
Warning:
Not finished.

Calculates new dyty cycle and writes the value into PWM generator.

Definition at line 177 of file main.cpp.

void tskRPMSetpoint ( void   ) [static]

Implementation of periodic change of RPM Setpoint.

Simulates setpoint changes to asses dynamic behaviour.

Note:
For test purposes.

Increases Setpoint value step by step with every invocation.

Definition at line 205 of file main.cpp.