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/>.
10 #include "libs/Module.h"
11 #include "libs/Kernel.h"
15 #define microseconds_per_step_pulse_checksum CHECKSUM("microseconds_per_step_pulse")
16 #define acceleration_ticks_per_second_checksum CHECKSUM("acceleration_ticks_per_second")
17 #define minimum_steps_per_minute_checksum CHECKSUM("minimum_steps_per_minute")
18 #define base_stepping_frequency_checksum CHECKSUM("base_stepping_frequency")
19 #define alpha_step_pin_checksum CHECKSUM("alpha_step_pin")
20 #define beta_step_pin_checksum CHECKSUM("beta_step_pin")
21 #define gamma_step_pin_checksum CHECKSUM("gamma_step_pin")
22 #define alpha_dir_pin_checksum CHECKSUM("alpha_dir_pin")
23 #define beta_dir_pin_checksum CHECKSUM("beta_dir_pin")
24 #define gamma_dir_pin_checksum CHECKSUM("gamma_dir_pin")
25 #define alpha_en_pin_checksum CHECKSUM("alpha_en_pin")
26 #define beta_en_pin_checksum CHECKSUM("beta_en_pin")
27 #define gamma_en_pin_checksum CHECKSUM("gamma_en_pin")
30 class Stepper
: public Module
{
33 void on_module_loaded();
34 void on_config_reload(void* argument
);
35 void on_block_begin(void* argument
);
36 void on_block_end(void* argument
);
37 void on_gcode_execute(void* argument
);
38 void on_play(void* argument
);
39 void on_pause(void* argument
);
40 uint32_t main_interrupt(uint32_t dummy
);
41 void trapezoid_generator_reset();
42 void set_step_events_per_minute(double steps_per_minute
);
43 uint32_t trapezoid_generator_tick(uint32_t dummy
);
44 uint32_t stepper_motor_finished_move(uint32_t dummy
);
45 int config_step_timer( int cycles
);
46 void turn_enable_pins_on();
47 void turn_enable_pins_off();
48 uint32_t synchronize_acceleration(uint32_t dummy
);
57 //int step_events_completed;
58 unsigned int out_bits
;
59 double trapezoid_adjusted_rate
;
60 int trapezoid_tick_cycle_counter
;
61 int cycles_per_step_event
;
62 bool trapezoid_generator_busy
;
63 int microseconds_per_step_pulse
;
64 int acceleration_ticks_per_second
;
65 unsigned int minimum_steps_per_minute
;
66 int base_stepping_frequency
;
67 unsigned short step_bits
[3];
68 int counter_increment
;
70 bool force_speed_update
;
71 bool enable_pins_status
;
72 Hook
* acceleration_tick_hook
;
74 StepperMotor
* main_stepper
;