Defines | Functions | Variables

engine.c File Reference

#include <lpc21xx.h>
#include <deb_led.h>
#include <system_def.h>
#include "engine.h"
Include dependency graph for engine.c:

Defines

#define ENGINE_PIN_A   7
 PWM output for engine A, pin P0.7.
#define ENGINE_PIN_B   8
 PWM output for engine B, pin P0.8.
#define ENGINE_ENA   28
 Enable output for engine A, pin P1.28.
#define ENGINE_ENB   30
 Enable output for engine B, pin P1.30.
#define ENGINE_IN2A   27
 Direction output for engine A , pin P1.27.
#define ENGINE_IN2B   29
 Direction output for engine A , pin P1.29.
#define PWM_FREQ   20000
 PWM frequency.
#define PWM_RES   100
 PWM resolution.
#define PWM_STEP   ((CPU_APB_HZ / PWM_FREQ)/PWM_RES + 1)
 Calculates smallest step PWM for resolution 0~100%.

Functions

void engine_A_en (unsigned status)
 Enables or disables the ouput on engine A.
void engine_B_en (unsigned status)
 Enables or disables the ouput on engine B.
void engine_A_dir (unsigned dir)
 Changes motor A direction.
void engine_B_dir (unsigned dir)
 Changes motor B direction.
void engine_A_pwm (unsigned pwm)
 Sets motor A PWM value.
void engine_B_pwm (unsigned pwm)
 Sets motor B PWM value.
void init_engine_A ()
 Inicializes Engine A - enables PWM outputs and sets IOs.
void init_engine_B ()
 Inicializes Engine B - enables PWM outputs and sets IOs.

Variables

unsigned int pwm_A = 0
 Actual value of PWM A.
unsigned int pwm_B = 0
 Actual value of PWM B.

Define Documentation

#define ENGINE_ENA   28

Enable output for engine A, pin P1.28.

#define ENGINE_ENB   30

Enable output for engine B, pin P1.30.

#define ENGINE_IN2A   27

Direction output for engine A , pin P1.27.

#define ENGINE_IN2B   29

Direction output for engine A , pin P1.29.

#define ENGINE_PIN_A   7

PWM output for engine A, pin P0.7.

#define ENGINE_PIN_B   8

PWM output for engine B, pin P0.8.

#define PWM_FREQ   20000

PWM frequency.

#define PWM_RES   100

PWM resolution.

#define PWM_STEP   ((CPU_APB_HZ / PWM_FREQ)/PWM_RES + 1)

Calculates smallest step PWM for resolution 0~100%.


Function Documentation

void engine_A_dir ( unsigned  dir  ) 

Changes motor A direction.

Parameters:
dir direction parameters are defined in engine.h

Here is the call graph for this function:

Here is the caller graph for this function:

void engine_A_en ( unsigned  status  ) 

Enables or disables the ouput on engine A.

Causes smooth stop, without break.

Parameters:
status status parameters are defined in engine.h

Here is the caller graph for this function:

void engine_A_pwm ( unsigned  pwm  ) 

Sets motor A PWM value.

Parameters:
pwm Unsigned int, 0~100%
Note:
0 causes fast stop

Here is the caller graph for this function:

void engine_B_dir ( unsigned  dir  ) 

Changes motor B direction.

Parameters:
dir direction parameters are defined in engine.h

Here is the call graph for this function:

Here is the caller graph for this function:

void engine_B_en ( unsigned  status  ) 

Enables or disables the ouput on engine B.

Causes smooth stop, without break.

Parameters:
status status parameters are defined in engine.h

Here is the caller graph for this function:

void engine_B_pwm ( unsigned  pwm  ) 

Sets motor B PWM value.

Parameters:
pwm Unsigned int, 0~100%
Note:
0 causes fast stop

Here is the caller graph for this function:

void init_engine_A (  ) 

Inicializes Engine A - enables PWM outputs and sets IOs.

Uses PWM channel - PWMMR2. If is somthing other set on PWM channels, it will affect the main PWM frequency If the engine B is set it will afect its output for one cycle

Here is the caller graph for this function:

void init_engine_B (  ) 

Inicializes Engine B - enables PWM outputs and sets IOs.

Uses PWM channel - PWMMR2. If is somthing other set on PWM channels, it will affect the main PWM frequency If the engine A is set it will afect its output for one cycle

Here is the caller graph for this function:


Variable Documentation

unsigned int pwm_A = 0

Actual value of PWM A.

unsigned int pwm_B = 0

Actual value of PWM B.