Basic 3D printing support working, a gigaton of bugfixes
[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 #include "libs/Module.h"
11 #include "libs/Kernel.h"
12 #include "Planner.h"
13 #include "Block.h"
14
15 #define microseconds_per_step_pulse_ckeckusm 42333
16 #define acceleration_ticks_per_second_checksum 25075
17 #define minimum_steps_per_minute_checksum 9003
18 #define base_stepping_frequency_checksum 21918
19 #define step_gpio_port_checksum 29939
20 #define dir_gpio_port_checksum 39286
21 #define alpha_step_pin_checksum 11468
22 #define beta_step_pin_checksum 22114
23 #define gamma_step_pin_checksum 1225
24 #define alpha_dir_pin_checksum 55887
25 #define beta_dir_pin_checksum 28644
26 #define gamma_dir_pin_checksum 46412
27
28 class Stepper : public Module {
29 public:
30 Stepper();
31 void on_module_loaded();
32 void on_config_reload(void* argument);
33 void on_block_begin(void* argument);
34 void on_block_end(void* argument);
35 void on_play(void* argument);
36 void on_pause(void* argument);
37 void main_interrupt();
38 void trapezoid_generator_reset();
39 void set_step_events_per_minute(double steps_per_minute);
40 void trapezoid_generator_tick();
41 void reset_step_pins();
42 void update_offsets();
43 int config_step_timer( int cycles );
44
45 Block* current_block;
46 int counters[3];
47 int stepped[3];
48 int offsets[3];
49 float counter_alpha;
50 float counter_beta;
51 float counter_gamma;
52 int step_events_completed;
53 unsigned int out_bits;
54 double trapezoid_adjusted_rate;
55 int trapezoid_tick_cycle_counter;
56 int cycles_per_step_event;
57 bool trapezoid_generator_busy;
58 int microseconds_per_step_pulse;
59 int acceleration_ticks_per_second;
60 int divider;
61 int minimum_steps_per_minute;
62 int base_stepping_frequency;
63 LPC_GPIO_TypeDef* step_gpio_port;
64 LPC_GPIO_TypeDef* dir_gpio_port;
65 unsigned short alpha_step_pin;
66 unsigned short beta_step_pin;
67 unsigned short gamma_step_pin;
68 unsigned short alpha_dir_pin;
69 unsigned short beta_dir_pin;
70 unsigned short gamma_dir_pin;
71 unsigned int step_mask;
72 unsigned int dir_mask;
73 unsigned int step_invert_mask;
74 unsigned int dir_invert_mask;
75 unsigned short step_bits[3];
76 int counter_increment;
77 };
78
79
80
81
82 #endif