Rostock2 #110

Merged
merged 11 commits into from Feb 15, 2013
@@ -8,6 +8,8 @@ The samples include:
* Smoothieboard - This directory contains a sample configuration for the
most recent Smoothieboard.
+* Smoothieboard.Rostock - This directory contains a sample config for a
+ Rostock or Kossel style bot using the most recent Smoothieboard.
You can find even more information about Smoothie configuration at this URL:
http://smoothieware.org/configuring-smoothie
@@ -0,0 +1,118 @@
+# Robot module configurations : general handling of movement G-codes and slicing into moves
+default_feed_rate 4000 # Default rate ( mm/minute ) for G1/G2/G3 moves
+default_seek_rate 4000 # Default rate ( mm/minute ) for G0 moves
+mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for these segments. Smaller values mean more resolution, higher values mean faster computation
+mm_per_line_segment 0.5 # Lines can be cut into segments ( not usefull with cartesian coordinates robots, but very useful on a delta type bot ).
+
+# Arm solution configuration : Cartesian robot. Translates mm positions into stepper positions
+arm_solution rostock # selects the rostock arm solution
+
+alpha_steps_per_mm 80 # Steps per mm for alpha stepper
+beta_steps_per_mm 80 # Steps per mm for beta stepper
+gamma_steps_per_mm 80 # Steps per mm for gamma stepper
+
+alpha_angle 0.0 # this provides an optional offset from the alpha tower to the x/y system
+beta_relative_angle 120.0 # this is the angle in degrees from the alpha tower to the beta tower
+gamma_relative_angle 240.0 # this is the angle in degrees from the alpha tower to the gamma tower
+
+arm_length 430.0 # this is the length of an arm from hinge to hinge
+arm_radius 220.675 # this is the horiontal distance from hinge to hinge when the effector is centered
+
+# Planner module configuration : Look-ahead and acceleration configuration
+planner_queue_size 64 # Size of the planning queue, must be a power of 2. 128 seems to be the maximum.
+acceleration 3000 # Acceleration in mm/second/second.
+acceleration_ticks_per_second 1000 # Number of times per second the speed is updated
+junction_deviation 0.05 # Similar to the old "max_jerk", in millimeters, see : https://github.com/grbl/grbl/blob/master/planner.c#L409
+ # and https://github.com/grbl/grbl/wiki/Configuring-Grbl-v0.8 . Lower values mean being more careful, higher values means being faster and have more jerk
+
+# Stepper module configuration
+microseconds_per_step_pulse 1 # Duration of step pulses to stepper drivers, in microseconds
+minimum_steps_per_minute 1200 # Never step slower than this
+base_stepping_frequency 100000 # Base frequency for stepping, higher gives smoother movement
+
+# Stepper module pins ( ports, and pin numbers, appending "!" to the number will invert a pin )
+alpha_step_pin 2.0 # Pin for alpha stepper step signal
+alpha_dir_pin 0.5 # Pin for alpha stepper direction
+alpha_en_pin 0.4 # Pin for alpha enable pin
+alpha_current 1.5 # X stepper motor current
+x_axis_max_speed 30000 # mm/min
+
+beta_step_pin 2.1 # Pin for beta stepper step signal
+beta_dir_pin 0.11 # Pin for beta stepper direction
+beta_en_pin 0.10 # Pin for beta enable
+beta_current 1.5 # Y stepper motor current
+y_axis_max_speed 30000 # mm/min
+
+gamma_step_pin 2.2 # Pin for gamma stepper step signal
+gamma_dir_pin 0.20 # Pin for gamma stepper direction
+gamma_en_pin 0.19 # Pin for gamma enable
+gamma_current 1.5 # Z stepper motor current
+z_axis_max_speed 30000 # mm/min
+
+# Serial communications configuration ( baud rate default to 9600 if undefined )
+uart0.baud_rate 115200 # Baud rate for the default serial port
+
+# Extruder module configuration
+extruder_module_enable true # Whether to activate the extruder module at all. All configuration is ignored if false
+extruder_steps_per_mm 140 # Steps per mm for extruder stepper
+extruder_default_feed_rate 600 # Default rate ( mm/minute ) for moves where only the extruder moves
+extruder_acceleration 50 # Acceleration for the stepper motor, as of 0.6, arbitrary ratio
+extruder_max_speed 1000 # mm^3/s
+
+extruder_step_pin 2.3 # Pin for extruder step signal
+extruder_dir_pin 0.22 # Pin for extruder dir signal
+extruder_en_pin 0.21 # Pin for extruder enable signal
+delta_current 1.5 # Extruder stepper motor current
+
+# Laser module configuration
+laser_module_enable false # Whether to activate the laser module at all. All configuration is ignored if false.
+
+# Hotend temperature control configuration
+temperature_control.hotend.enable true # Whether to activate this ( "hotend" ) module at all. All configuration is ignored if false.
+temperature_control.hotend.thermistor_pin 0.23 # Pin for the thermistor to read
+temperature_control.hotend.heater_pin 2.7 # Pin that controls the heater
+temperature_control.hotend.thermistor EPCOS100K # see src/modules/tools/temperaturecontrol/TemperatureControl.cpp:64 for a list of valid thermistor names
+temperature_control.hotend.set_m_code 104 #
+temperature_control.hotend.set_and_wait_m_code 109 #
+temperature_control.hotend.designator T #
+
+temperature_control.bed.enable true #
+temperature_control.bed.thermistor_pin 0.24 #
+temperature_control.bed.heater_pin 2.5 #
+temperature_control.bed.thermistor Honeywell100K # see src/modules/tools/temperaturecontrol/TemperatureControl.cpp:64 for a list of valid thermistor names
+temperature_control.bed.set_m_code 140 #
+temperature_control.bed.set_and_wait_m_code 190 #
+temperature_control.bed.designator B #
+
+# Switch module for fan control
+switch.fan.enable true #
+switch.fan.on_m_code 106 #
+switch.fan.off_m_code 107 #
+switch.fan.output_pin 2.6 #
+
+switch.misc.enable true #
+switch.misc.on_m_code 42 #
+switch.misc.off_m_code 43 #
+switch.misc.output_pin 2.4 #
+
+# Switch module for spindle control
+switch.spindle.enable false #
+
+# Endstops
+alpha_min_endstop 1.24 #
+alpha_max_endstop 1.25 #
+beta_min_endstop 1.26 #
+beta_max_endstop 1.27 #
+gamma_min_endstop 1.28 #
+gamma_max_endstop 1.29 #
+
+# Panel
+panel.enable false #
+panel.up_button_pin 0.1! #
+panel.down_button_pin 0.0! #
+panel.click_button_pin 0.18! #
+panel.encoder_a_pin 0.15! #
+panel.encoder_b_pin 0.17! #
+
+# Only needed on a smoothieboard
+currentcontrol_module_enable true #
@@ -19,6 +19,7 @@ using std::string;
#include "../communication/utils/Gcode.h"
#include "arm_solutions/BaseSolution.h"
#include "arm_solutions/CartesianSolution.h"
+#include "arm_solutions/RostockSolution.h"
Robot::Robot(){
this->inch_mode = false;
@@ -48,7 +49,23 @@ void Robot::on_module_loaded() {
void Robot::on_config_reload(void* argument){
if (this->arm_solution) delete this->arm_solution;
- this->arm_solution = new CartesianSolution(this->kernel->config);
+ int solution_checksum = get_checksum(this->kernel->config->value(arm_solution_checksum)->by_default("cartesian")->as_string());
+
+ // Note checksums are not const expressions when in debug mode, so don't use switch
+ if(solution_checksum == rostock_checksum) {
+ this->arm_solution = new RostockSolution(this->kernel->config);
+
+ }else if(solution_checksum == delta_checksum) {
+ // place holder for now
+ this->arm_solution = new RostockSolution(this->kernel->config);
+
+ }else if(solution_checksum == cartesian_checksum) {
+ this->arm_solution = new CartesianSolution(this->kernel->config);
+
+ }else{
+ this->arm_solution = new CartesianSolution(this->kernel->config);
+ }
+
this->feed_rate = this->kernel->config->value(default_feed_rate_checksum )->by_default(100 )->as_number() / 60;
this->seek_rate = this->kernel->config->value(default_seek_rate_checksum )->by_default(100 )->as_number() / 60;
@@ -27,6 +27,10 @@ using std::string;
#define x_axis_max_speed_checksum CHECKSUM("x_axis_max_speed")
#define y_axis_max_speed_checksum CHECKSUM("y_axis_max_speed")
#define z_axis_max_speed_checksum CHECKSUM("z_axis_max_speed")
+#define arm_solution_checksum CHECKSUM("arm_solution")
+#define cartesian_checksum CHECKSUM("cartesian")
+#define rostock_checksum CHECKSUM("rostock")
+#define delta_checksum CHECKSUM("delta")
#define NEXT_ACTION_DEFAULT 0
#define NEXT_ACTION_DWELL 1
@@ -0,0 +1,72 @@
+#include "RostockSolution.h"
+#include <math.h>
+
+#define PIOVER180 0.01745329251994329576923690768489
+
+RostockSolution::RostockSolution(Config* passed_config) : config(passed_config){
+ this->alpha_steps_per_mm = this->config->value(alpha_steps_per_mm_checksum)->as_number();
+ this->beta_steps_per_mm = this->config->value( beta_steps_per_mm_checksum)->as_number();
+ this->gamma_steps_per_mm = this->config->value(gamma_steps_per_mm_checksum)->as_number();
+
+ double alpha_angle = PIOVER180 * this->config->value(alpha_angle_checksum)->by_default(0.0)->as_number();
+ this->sin_alpha = sin(alpha_angle);
+ this->cos_alpha = cos(alpha_angle);
+ double beta_angle = PIOVER180 * this->config->value( beta_relative_angle_checksum)->by_default(120.0)->as_number();
+ this->sin_beta = sin(beta_angle);
+ this->cos_beta = cos(beta_angle);
+ double gamma_angle = PIOVER180 * this->config->value(gamma_relative_angle_checksum)->by_default(240.0)->as_number();
+ this->sin_gamma = sin(gamma_angle);
+ this->cos_gamma = cos(gamma_angle);
+
+ // arm_length is the length of the arm from hinge to hinge
+ this->arm_length = this->config->value(arm_length_checksum)->by_default(430.0)->as_number();
+ // arm_radius is the horizontal distance from hinge to hinge when the effector is centered
+ this->arm_radius = this->config->value(arm_radius_checksum)->by_default(220.675)->as_number();
+
+ this->arm_length_squared = pow(this->arm_length, 2);
+}
+
+void RostockSolution::millimeters_to_steps( double millimeters[], int steps[] ){
+ double alpha_rotated[3], rotated[3];
+ if( this->sin_alpha == 0 && this->cos_alpha == 1){
+ alpha_rotated[0] = millimeters[0];
+ alpha_rotated[1] = millimeters[1];
+ alpha_rotated[2] = millimeters[2];
+ }else{
+ rotate( millimeters, alpha_rotated, sin_alpha, cos_alpha );
+ }
+ steps[ALPHA_STEPPER] = lround( solve_arm( alpha_rotated ) * this->alpha_steps_per_mm );
+
+ rotate( alpha_rotated, rotated, sin_beta, cos_beta );
+ steps[BETA_STEPPER ] = lround( solve_arm( rotated ) * this->beta_steps_per_mm );
+
+ rotate( alpha_rotated, rotated, sin_gamma, cos_gamma );
+ steps[GAMMA_STEPPER] = lround( solve_arm( rotated ) * this->gamma_steps_per_mm );
+}
+
+void RostockSolution::steps_to_millimeters( int steps[], double millimeters[] ){}
+
+double RostockSolution::solve_arm( double millimeters[]) {
+ return sqrt(arm_length_squared - pow(millimeters[X_AXIS] - this->arm_radius, 2) - pow(millimeters[Y_AXIS], 2)) + millimeters[Z_AXIS];
+}
+
+void RostockSolution::rotate(double in[], double out[], double sin, double cos ){
+ out[X_AXIS] = cos * in[X_AXIS] - sin * in[Y_AXIS];
+ out[Y_AXIS] = sin * in[X_AXIS] + cos * in[Y_AXIS];
+ out[Z_AXIS] = in[Z_AXIS];
+}
+
+void RostockSolution::set_steps_per_millimeter( double steps[] )
+{
+ this->alpha_steps_per_mm = steps[0];
+ this->beta_steps_per_mm = steps[1];
+ this->gamma_steps_per_mm = steps[2];
+}
+
+void RostockSolution::get_steps_per_millimeter( double steps[] )
+{
+ steps[0] = this->alpha_steps_per_mm;
+ steps[1] = this->beta_steps_per_mm;
+ steps[2] = this->gamma_steps_per_mm;
+}
+
@@ -0,0 +1,55 @@
+#ifndef ROSTOCKSOLUTION_H
+#define ROSTOCKSOLUTION_H
+#include "libs/Module.h"
+#include "libs/Kernel.h"
+#include "BaseSolution.h"
+#include "libs/nuts_bolts.h"
+
+#include "libs/Config.h"
+
+#define alpha_steps_per_mm_checksum CHECKSUM("alpha_steps_per_mm")
+#define beta_steps_per_mm_checksum CHECKSUM("beta_steps_per_mm")
+#define gamma_steps_per_mm_checksum CHECKSUM("gamma_steps_per_mm")
+
+#define arm_length_checksum CHECKSUM("arm_length")
+#define arm_radius_checksum CHECKSUM("arm_radius")
+
+#define alpha_angle_checksum CHECKSUM("alpha_angle")
+#define beta_relative_angle_checksum CHECKSUM("beta_relative_angle")
+#define gamma_relative_angle_checksum CHECKSUM("gamma_relative_angle")
+
+class RostockSolution : public BaseSolution {
+ public:
+ RostockSolution(Config* passed_config);
+ void millimeters_to_steps( double millimeters[], int steps[] );
+ void steps_to_millimeters( int steps[], double millimeters[] );
+
+ void set_steps_per_millimeter( double steps[] );
+ void get_steps_per_millimeter( double steps[] );
+
+ double solve_arm( double millimeters[] );
+ void rotate( double in[], double out[], double sin, double cos );
+
+ Config* config;
+ double alpha_steps_per_mm;
+ double beta_steps_per_mm;
+ double gamma_steps_per_mm;
+
+ double arm_length;
+ double arm_radius;
+ double arm_length_squared;
+
+ double sin_alpha;
+ double cos_alpha;
+ double sin_beta;
+ double cos_beta;
+ double sin_gamma;
+ double cos_gamma;
+};
+
+
+
+
+
+
+#endif // ROSTOCKSOLUTION_H