#include "esos.h"
#include "esos_pic24.h"
#include "motor3.h"
Go to the source code of this file.
Defines | |
#define | NUM_MOTORS_USED_3 1 |
#define | MOTOR_PRESCALER_3 64 |
#define | MOTOR_IRQ_LEVEL_3 2 |
#define | MOTOR_PULSE_PERIOD_3 usToU16Ticks(400, MOTOR_PRESCALER_3); |
Motor 3 Ports | |
Each motor requires three ports (two for direction and one for PWM). For each MOTOR_3_<n>_DIR_PORT_1 and MOTOR_3_<n>_DIR_PORT_2 (where 'n' <= NUM_MOTORS_USED_3) assign a port. These ports should also correspond to a CONFIG_RB<n>_AS_DIG_OUTPUT() call in CONFIG_MOTOR_3_<n>. Additionally in CONFIG_MOTOR_3_<n>, the PWM port for motor 'n' is assigned in the CONFIG_OC<n>_TO_RP() call. See CONFIG_MOTOR_3_1() for an example. | |
#define | MOTOR_3_1_DIR_PORT_1 _LATB8 |
#define | MOTOR_3_1_DIR_PORT_2 _LATB7 |
#define | CONFIG_MOTOR_3_1() |
#define | MOTOR_3_2_DIR_PORT_1 _LATB<X> |
#define | MOTOR_3_2_DIR_PORT_2 _LATB<Y> |
#define | CONFIG_MOTOR_3_2() |
#define | MOTOR_3_3_DIR_PORT_1 _LATB<X> |
#define | MOTOR_3_3_DIR_PORT_2 _LATB<Y> |
#define | CONFIG_MOTOR_3_3() |
#define | MOTOR_3_4_DIR_PORT_1 _LATB<X> |
#define | MOTOR_3_4_DIR_PORT_2 _LATB<Y> |
#define | CONFIG_MOTOR_3_4() |
#define | MOTOR_3_5_DIR_PORT_1 _LATB<X> |
#define | MOTOR_3_5_DIR_PORT_2 _LATB<Y> |
#define | CONFIG_MOTOR_3_5() |
#define | MOTOR_3_6_DIR_PORT_1 _LATB<X> |
#define | MOTOR_3_6_DIR_PORT_2 _LATB<Y> |
#define | CONFIG_MOTOR_3_6() |
#define | MOTOR_3_7_DIR_PORT_1 _LATB<X> |
#define | MOTOR_3_7_DIR_PORT_2 _LATB<Y> |
#define | CONFIG_MOTOR_3_7() |
#define | MOTOR_3_8_DIR_PORT_1 _LATB<X> |
#define | MOTOR_3_8_DIR_PORT_2 _LATB<Y> |
#define | CONFIG_MOTOR_3_8() |
It is recommended to copy the motor3 library files (both .c and .h) over to the local project directory. This allows for editing motorconfig2.h without affecting the original library.
This header file serves as the main point of motor3 configuration, while motor3.h and motor3.c provide implement motor operation. In order to configure motors for your needs:
#define ESOS_USE_IRQS
To choose the the state and speed of each motor, make a call to update_motor_3(). For example, setting motor 4 to 75% speed forward:
update_motor_3(MOTOR_3_4, MOTOR_FORWARD, usToU16Ticks(300, MOTOR_PRESCALER_3));
For more advanced usage, MOTOR_PRESCALER_3 chooses the prescaler for the Timer. The default setting works well for Fosc = 40 MHz. Also, MOTOR_IRQ_LEVEL_3 adjusts the interrupt's priority.
Definition in file motorconfig3.h.
#define CONFIG_MOTOR_3_1 | ( | ) |
Value:
{CONFIG_RB8_AS_DIG_OUTPUT(); \ CONFIG_RB7_AS_DIG_OUTPUT(); \ CONFIG_OC1_TO_RP(6);}
Definition at line 85 of file motorconfig3.h.
#define MOTOR_3_1_DIR_PORT_1 _LATB8 |
Maps the "forward" direction pin to a PIC24 port. This is linked with CONFIG_MOTOR_3_<n>, be sure to edit them correspondingly.
Definition at line 73 of file motorconfig3.h.
#define MOTOR_3_1_DIR_PORT_2 _LATB7 |
Maps the "reverse" direction pin to a PIC24 port. This is linked with CONFIG_MOTOR_3_<n>, be sure to edit them correspondingly.
Definition at line 78 of file motorconfig3.h.
#define MOTOR_IRQ_LEVEL_3 2 |
Defined as the desired timer interrupt priority. For systems running on ESOS, the available choices are 1-4, with 1 being the highest. Otherwise, the available choices are 1-7, with 7 being the highest.
Definition at line 54 of file motorconfig3.h.
#define MOTOR_PRESCALER_3 64 |
Defined as the desired timer prescaler. Available prescalers are 1, 8, 64, and 256.
Definition at line 48 of file motorconfig3.h.
#define MOTOR_PULSE_PERIOD_3 usToU16Ticks(400, MOTOR_PRESCALER_3); |
Defines the period during which all servos are updated. Defaults to a 400us period (2.5 KHz).
Definition at line 58 of file motorconfig3.h.
#define NUM_MOTORS_USED_3 1 |
Specifies the number of motors this library will operate. Valid values are from 1 to MAX_NUM_MOTORS_3. This number should correspond with the number of Motor 3 Ports that are assigned
Definition at line 44 of file motorconfig3.h.