Stepper motor driver, increment/decrement the position and outputs the correct signals to stepper motor.
Definition in file speed_cntr.c.
#include <ioavr.h>
#include "global.h"
#include "sm_driver.h"
#include "speed_cntr.h"
#include "uart.h"
Include dependency graph for speed_cntr.c:
Go to the source code of this file.
Functions | |
unsigned int | min (unsigned int x, unsigned int y) |
Find minimum value. | |
void | speed_cntr_Init_Timer1 (void) |
Init of Timer/Counter1. | |
void | speed_cntr_Move (signed int step, unsigned int accel, unsigned int decel, unsigned int speed) |
Move the stepper motor a given number of steps. | |
__interrupt void | speed_cntr_TIMER1_COMPA_interrupt (void) |
Timer/Counter1 Output Compare A Match Interrupt. | |
Variables | |
speedRampData | srd |
Cointains data for timer interrupt. |
|
Find minimum value. Returns the smallest value.
Definition at line 281 of file speed_cntr.c.
|
|
Init of Timer/Counter1. Set up Timer/Counter1 to use mode 1 CTC and enable Output Compare A Match Interrupt. Definition at line 143 of file speed_cntr.c. References speedRampData::run_state, srd, and STOP. Referenced by Init().
|
|
Move the stepper motor a given number of steps. Makes the stepper motor move the given number of steps. It accelrate with given accelration up to maximum speed and decelerate with given deceleration so it stops at the given step. If accel/decel is to small and steps to move is to few, speed might not reach the max speed limit before deceleration starts.
Number of steps before we hit max speed. Number of steps before we must start deceleration (if accel does not hit max speed). Definition at line 46 of file speed_cntr.c. References A_SQ, A_T_x100, A_x20000, ACCEL, speedRampData::accel_count, CCW, CW, DECEL, speedRampData::decel_start, speedRampData::decel_val, speedRampData::dir, speedRampData::min_delay, RUN, speedRampData::run_state, GLOBAL_FLAGS::running, srd, status, speedRampData::step_delay, T1_FREQ_148, and TRUE. Referenced by main().
|
|
Timer/Counter1 Output Compare A Match Interrupt. Timer/Counter1 Output Compare A Match Interrupt. Increments/decrements the position of the stepper motor exept after last position, when it stops. The step_delay defines the period of this interrupt and controls the speed of the stepper motor. A new step delay is calculated to follow wanted speed profile on basis of accel/decel parameters. Definition at line 164 of file speed_cntr.c. References ACCEL, speedRampData::accel_count, DECEL, speedRampData::decel_start, speedRampData::decel_val, speedRampData::dir, FALSE, speedRampData::min_delay, RUN, speedRampData::run_state, GLOBAL_FLAGS::running, sm_driver_StepCounter(), srd, status, speedRampData::step_delay, and STOP.
Here is the call graph for this function: ![]() |
|
Cointains data for timer interrupt.
Definition at line 31 of file speed_cntr.c. Referenced by speed_cntr_Init_Timer1(), speed_cntr_Move(), and speed_cntr_TIMER1_COMPA_interrupt(). |