half-way commit to explain some of what is going on
[clinton/Smoothieware.git] / src / modules / robot / Stepper.h
CommitLineData
4cff3ded
AW
1/*
2 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
3 Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4 Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
6*/
7
8#ifndef STEPPER_H
9#define STEPPER_H
10#include "libs/Module.h"
11#include "libs/Kernel.h"
12#include "Planner.h"
13#include "Block.h"
14
8c309ca9 15#define microseconds_per_step_pulse_checksum 42333
4cff3ded
AW
16#define acceleration_ticks_per_second_checksum 25075
17#define minimum_steps_per_minute_checksum 9003
18#define base_stepping_frequency_checksum 21918
4cff3ded
AW
19#define alpha_step_pin_checksum 11468
20#define beta_step_pin_checksum 22114
21#define gamma_step_pin_checksum 1225
22#define alpha_dir_pin_checksum 55887
23#define beta_dir_pin_checksum 28644
24#define gamma_dir_pin_checksum 46412
bee725fc
AW
25#define alpha_en_pin_checksum 35042
26#define beta_en_pin_checksum 34680
27#define gamma_en_pin_checksum 26335
28
4cff3ded
AW
29
30class Stepper : public Module {
31 public:
32 Stepper();
33 void on_module_loaded();
da24d6ae 34 void on_config_reload(void* argument);
3a4fa0c1
AW
35 void on_block_begin(void* argument);
36 void on_block_end(void* argument);
15908331 37 void on_gcode_execute(void* argument);
befcf5cc
AW
38 void on_play(void* argument);
39 void on_pause(void* argument);
8b8b3339 40 uint32_t main_interrupt(uint32_t dummy);
4cff3ded
AW
41 void trapezoid_generator_reset();
42 void set_step_events_per_minute(double steps_per_minute);
8b8b3339 43 uint32_t trapezoid_generator_tick(uint32_t dummy);
feb204be 44 uint32_t stepper_motor_finished_move(uint32_t dummy);
4cff3ded 45 int config_step_timer( int cycles );
feb204be
AW
46 uint32_t step_events_completed();
47
3a4fa0c1 48
4cff3ded 49 Block* current_block;
4cff3ded
AW
50 int counters[3];
51 int stepped[3];
52 int offsets[3];
53 float counter_alpha;
54 float counter_beta;
55 float counter_gamma;
feb204be 56 //int step_events_completed;
4cff3ded
AW
57 unsigned int out_bits;
58 double trapezoid_adjusted_rate;
59 int trapezoid_tick_cycle_counter;
60 int cycles_per_step_event;
61 bool trapezoid_generator_busy;
62 int microseconds_per_step_pulse;
63 int acceleration_ticks_per_second;
4cff3ded
AW
64 int minimum_steps_per_minute;
65 int base_stepping_frequency;
e6b22382
AW
66 Pin* alpha_step_pin;
67 Pin* beta_step_pin;
68 Pin* gamma_step_pin;
69 Pin* alpha_dir_pin;
70 Pin* beta_dir_pin;
71 Pin* gamma_dir_pin;
bee725fc
AW
72 Pin* alpha_en_pin;
73 Pin* beta_en_pin;
74 Pin* gamma_en_pin;
a2cd92c0
AW
75 unsigned short step_bits[3];
76 int counter_increment;
81b547a1 77 bool paused;
feb204be
AW
78
79 StepperMotor* main_stepper;
80
4cff3ded
AW
81};
82
83
84
85
86#endif