Merge pull request #399 from Smoothieware/edge
[clinton/Smoothieware.git] / src / modules / robot / Stepper.h
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
11 #include "libs/Module.h"
12
13 class Block;
14 class Hook;
15 class StepperMotor;
16
17 #define microseconds_per_step_pulse_checksum CHECKSUM("microseconds_per_step_pulse")
18 #define acceleration_ticks_per_second_checksum CHECKSUM("acceleration_ticks_per_second")
19 #define minimum_steps_per_minute_checksum CHECKSUM("minimum_steps_per_minute")
20 #define base_stepping_frequency_checksum CHECKSUM("base_stepping_frequency")
21
22 class Stepper : public Module {
23 public:
24 Stepper();
25 void on_module_loaded();
26 void on_config_reload(void* argument);
27 void on_block_begin(void* argument);
28 void on_block_end(void* argument);
29 void on_gcode_received(void* argument);
30 void on_gcode_execute(void* argument);
31 void on_play(void* argument);
32 void on_pause(void* argument);
33 uint32_t main_interrupt(uint32_t dummy);
34 void trapezoid_generator_reset();
35 void set_step_events_per_second(float);
36 uint32_t trapezoid_generator_tick(uint32_t dummy);
37 uint32_t stepper_motor_finished_move(uint32_t dummy);
38 int config_step_timer( int cycles );
39 void turn_enable_pins_on();
40 void turn_enable_pins_off();
41 uint32_t synchronize_acceleration(uint32_t dummy);
42
43 Block* current_block;
44 int counters[3];
45 int stepped[3];
46 int offsets[3];
47 float counter_alpha;
48 float counter_beta;
49 float counter_gamma;
50 //int step_events_completed;
51 unsigned int out_bits;
52 float trapezoid_adjusted_rate;
53 int trapezoid_tick_cycle_counter;
54 int cycles_per_step_event;
55 bool trapezoid_generator_busy;
56 int microseconds_per_step_pulse;
57 int acceleration_ticks_per_second;
58 unsigned int minimum_steps_per_second;
59 int base_stepping_frequency;
60 unsigned short step_bits[3];
61 int counter_increment;
62 bool paused;
63 bool force_speed_update;
64 bool enable_pins_status;
65 Hook* acceleration_tick_hook;
66
67 StepperMotor* main_stepper;
68
69 };
70
71
72
73
74 #endif