robotics/common/motor3.c File Reference

#include "motorconfig3.h"

Go to the source code of this file.

Functions

void update_motor_3 (uint8 u8_motor, uint8 u8_direction, uint16 u16_duration)
void initialize_motor_3 (void)
 ESOS_USER_INTERRUPT (ESOS_IRQ_PIC24_T3)


Detailed Description

Author:
Thomas Donaldson
This file contains the function definitions for the motor library. It is not meant to be edited directly, and all configuration of the library should be done through motorconfig3.h.

Definition in file motor3.c.


Function Documentation

ESOS_USER_INTERRUPT ( ESOS_IRQ_PIC24_T3   ) 

Since the timer is being used solely for PWM, the ISR only needs to clear the interrupt flag.

Definition at line 223 of file motor3.c.

void initialize_motor_3 ( void   ) 

Initializes the selected motors. Each motor is associated with an output compare, and each output compare is initialized to a 100 count duration until update_motor_3() is called.

Definition at line 129 of file motor3.c.

void update_motor_3 ( uint8  u8_motor,
uint8  u8_direction,
uint16  u16_duration 
)

This function is used to update each motor with a new direction and PWM duration. The motor (see Motor References) and direction (see Motor States) parameters are already defined, and the duration parameter is in terms of Timer ticks, which can be easily calculated with usToU16Ticks(). This function will ASSERT() if an invalid duration or motor is passed. Also, a bit mask is applied to the direction parameter so any editing of Motor States should be done with care.

As an example, to set motor 2 to 90% speed in reverse:

 update_motor_3(MOTOR_3_2, MOTOR_REVERSE, usToU16Ticks(360, MOTOR_PRESCALER_3)); 

Definition at line 24 of file motor3.c.


Generated on Sun Mar 15 11:14:22 2009 for PIC24 Support Libraries by  doxygen 1.5.8