smoothie port to mbed online compiler (smoothieware.org)

Dependencies:   mbed

For documentation, license, ..., please check http://smoothieware.org/

This version has been tested with a 3 axis machine

Committer:
scachat
Date:
Tue Jul 31 21:11:18 2012 +0000
Revision:
0:31e91bb0ef3c
smoothie port to mbed online compiler

Who changed what in which revision?

UserRevisionLine numberNew contents of line
scachat 0:31e91bb0ef3c 1 /*
scachat 0:31e91bb0ef3c 2 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
scachat 0:31e91bb0ef3c 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.
scachat 0:31e91bb0ef3c 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.
scachat 0:31e91bb0ef3c 5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
scachat 0:31e91bb0ef3c 6 */
scachat 0:31e91bb0ef3c 7
scachat 0:31e91bb0ef3c 8 #ifndef STEPPER_H
scachat 0:31e91bb0ef3c 9 #define STEPPER_H
scachat 0:31e91bb0ef3c 10 #include "libs/Module.h"
scachat 0:31e91bb0ef3c 11 #include "libs/Kernel.h"
scachat 0:31e91bb0ef3c 12 #include "Planner.h"
scachat 0:31e91bb0ef3c 13 #include "Block.h"
scachat 0:31e91bb0ef3c 14
scachat 0:31e91bb0ef3c 15 #define microseconds_per_step_pulse_checksum 42333
scachat 0:31e91bb0ef3c 16 #define acceleration_ticks_per_second_checksum 25075
scachat 0:31e91bb0ef3c 17 #define minimum_steps_per_minute_checksum 9003
scachat 0:31e91bb0ef3c 18 #define base_stepping_frequency_checksum 21918
scachat 0:31e91bb0ef3c 19 #define alpha_step_pin_checksum 11468
scachat 0:31e91bb0ef3c 20 #define beta_step_pin_checksum 22114
scachat 0:31e91bb0ef3c 21 #define gamma_step_pin_checksum 1225
scachat 0:31e91bb0ef3c 22 #define alpha_dir_pin_checksum 55887
scachat 0:31e91bb0ef3c 23 #define beta_dir_pin_checksum 28644
scachat 0:31e91bb0ef3c 24 #define gamma_dir_pin_checksum 46412
scachat 0:31e91bb0ef3c 25 #define alpha_en_pin_checksum 35042
scachat 0:31e91bb0ef3c 26 #define beta_en_pin_checksum 34680
scachat 0:31e91bb0ef3c 27 #define gamma_en_pin_checksum 26335
scachat 0:31e91bb0ef3c 28
scachat 0:31e91bb0ef3c 29
scachat 0:31e91bb0ef3c 30 class Stepper : public Module {
scachat 0:31e91bb0ef3c 31 public:
scachat 0:31e91bb0ef3c 32 Stepper();
scachat 0:31e91bb0ef3c 33 virtual void on_module_loaded();
scachat 0:31e91bb0ef3c 34 virtual void on_config_reload(void* argument);
scachat 0:31e91bb0ef3c 35 virtual void on_block_begin(void* argument);
scachat 0:31e91bb0ef3c 36 virtual void on_block_end(void* argument);
scachat 0:31e91bb0ef3c 37 virtual void on_gcode_execute(void* argument);
scachat 0:31e91bb0ef3c 38 virtual void on_play(void* argument);
scachat 0:31e91bb0ef3c 39 virtual void on_pause(void* argument);
scachat 0:31e91bb0ef3c 40 uint32_t main_interrupt(uint32_t dummy);
scachat 0:31e91bb0ef3c 41 void trapezoid_generator_reset();
scachat 0:31e91bb0ef3c 42 void set_step_events_per_minute(double steps_per_minute);
scachat 0:31e91bb0ef3c 43 uint32_t trapezoid_generator_tick(uint32_t dummy);
scachat 0:31e91bb0ef3c 44 uint32_t reset_step_pins(uint32_t dummy);
scachat 0:31e91bb0ef3c 45 void update_offsets();
scachat 0:31e91bb0ef3c 46 int config_step_timer( int cycles );
scachat 0:31e91bb0ef3c 47
scachat 0:31e91bb0ef3c 48 Block* current_block;
scachat 0:31e91bb0ef3c 49 int counters[3];
scachat 0:31e91bb0ef3c 50 int stepped[3];
scachat 0:31e91bb0ef3c 51 int offsets[3];
scachat 0:31e91bb0ef3c 52 float counter_alpha;
scachat 0:31e91bb0ef3c 53 float counter_beta;
scachat 0:31e91bb0ef3c 54 float counter_gamma;
scachat 0:31e91bb0ef3c 55 int step_events_completed;
scachat 0:31e91bb0ef3c 56 unsigned int out_bits;
scachat 0:31e91bb0ef3c 57 double trapezoid_adjusted_rate;
scachat 0:31e91bb0ef3c 58 int trapezoid_tick_cycle_counter;
scachat 0:31e91bb0ef3c 59 int cycles_per_step_event;
scachat 0:31e91bb0ef3c 60 bool trapezoid_generator_busy;
scachat 0:31e91bb0ef3c 61 int microseconds_per_step_pulse;
scachat 0:31e91bb0ef3c 62 int acceleration_ticks_per_second;
scachat 0:31e91bb0ef3c 63 int divider;
scachat 0:31e91bb0ef3c 64 int minimum_steps_per_minute;
scachat 0:31e91bb0ef3c 65 int base_stepping_frequency;
scachat 0:31e91bb0ef3c 66 Pin* alpha_step_pin;
scachat 0:31e91bb0ef3c 67 Pin* beta_step_pin;
scachat 0:31e91bb0ef3c 68 Pin* gamma_step_pin;
scachat 0:31e91bb0ef3c 69 Pin* alpha_dir_pin;
scachat 0:31e91bb0ef3c 70 Pin* beta_dir_pin;
scachat 0:31e91bb0ef3c 71 Pin* gamma_dir_pin;
scachat 0:31e91bb0ef3c 72 Pin* alpha_en_pin;
scachat 0:31e91bb0ef3c 73 Pin* beta_en_pin;
scachat 0:31e91bb0ef3c 74 Pin* gamma_en_pin;
scachat 0:31e91bb0ef3c 75 unsigned short step_bits[3];
scachat 0:31e91bb0ef3c 76 int counter_increment;
scachat 0:31e91bb0ef3c 77 bool paused;
scachat 0:31e91bb0ef3c 78 };
scachat 0:31e91bb0ef3c 79
scachat 0:31e91bb0ef3c 80
scachat 0:31e91bb0ef3c 81
scachat 0:31e91bb0ef3c 82
scachat 0:31e91bb0ef3c 83 #endif