Commit ac418efe authored by MagoKimbra's avatar MagoKimbra

Add new movement for DELTA

parent 3460f29a
......@@ -385,12 +385,16 @@
// Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
//#define LCD_I2C_VIKI
// SSD1306 OLED generic display support
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib
//#define U8GLIB_SSD1306
// Shift register panels
// ---------------------
// 2 wire Non-latching LCD SR from:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
// LCD configuration: http://reprap.org/wiki/SAV_3D_LCD
//#define SAV_3DLCD
// option for invert rotary switch
......@@ -450,7 +454,6 @@
//========================== EXTRA SETTINGS ON SD ===========================
// Uncomment SD SETTINGS to enable the firmware to write some configuration, that require frequent update, on the SD card.
// ATTENTION NOT FUNCTION WIDTH OCTOPRINT
//#define SD_SETTINGS
#define SD_CFG_SECONDS 300 //seconds between update
#define CFG_SD_FILE "INFO.CFG" //name of the configuration file
......
......@@ -9,7 +9,9 @@
// Make delta curves from many straight lines (linear interpolation).
// This is a trade-off between visible corners (not enough segments)
// and processor overload (too many expensive sqrt calls).
#define DELTA_SEGMENTS_PER_SECOND 200
// The new function do not use segments per second but segments per mm
// if you want use new function comment this (using // at the start of the line)
#define DELTA_SEGMENTS_PER_SECOND 150
// Center-to-center distance of the holes in the diagonal push rods.
#define DEFAULT_DELTA_DIAGONAL_ROD 217.0 // mm
......
......@@ -351,7 +351,6 @@ unsigned long printer_usage_seconds;
float delta_radius; // = DEFAULT_delta_radius;
float delta_diagonal_rod; // = DEFAULT_DELTA_DIAGONAL_ROD;
float delta_diagonal_rod_2;
float delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
float ac_prec = AUTOCALIBRATION_PRECISION;
float bed_radius = PRINTER_RADIUS;
float delta_tower1_x, delta_tower1_y;
......@@ -399,11 +398,16 @@ unsigned long printer_usage_seconds;
#endif // DELTA
#ifdef SCARA
float delta_segments_per_second = SCARA_SEGMENTS_PER_SECOND;
static float delta[3] = { 0 };
float axis_scaling[3] = { 1, 1, 1 }; // Build size scaling, default to 1
#endif
#if defined (DELTA_SEGMENTS_PER_SECOND)
float delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
#elif defined (SCARA_SEGMENTS_PER_SECOND)
float delta_segments_per_second = SCARA_SEGMENTS_PER_SECOND;
#endif
#if HAS_FILAMENT_SENSOR
//Variables for Filament Sensor input
float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404
......@@ -1981,8 +1985,8 @@ static void setup_for_endstop_move() {
// Adjust print surface height by linear interpolation over the bed_level array.
void adjust_delta(float cartesian[3]) {
float grid_x = max(-2.999, min(2.999, cartesian[X_AXIS] / AUTOLEVEL_GRID));
float grid_y = max(-2.999, min(2.999, cartesian[Y_AXIS] / AUTOLEVEL_GRID));
float grid_x = max(-2.999, min(2.999, cartesian[X_AXIS] * AUTOLEVEL_GRID_MULTI));
float grid_y = max(-2.999, min(2.999, cartesian[Y_AXIS] * AUTOLEVEL_GRID_MULTI));
int floor_x = floor(grid_x);
int floor_y = floor(grid_y);
float ratio_x = grid_x - floor_x;
......@@ -6545,13 +6549,13 @@ void ok_to_send() {
ECHO_S(OK);
#ifdef ADVANCED_OK
ECHO_MV("N", gcode_LastN);
ECHO_MV(" P", (int)(BLOCK_BUFFER_SIZE - movesplanned() - 1));
ECHO_MV(" P", (int(BLOCK_BUFFER_SIZE - movesplanned() - 1)));
ECHO_MV(" B", BUFSIZE - commands_in_queue);
#endif
ECHO_E;
}
void clamp_to_software_endstops(float target[3]) {
FORCE_INLINE void clamp_to_software_endstops(float target[3]) {
if (min_software_endstops) {
NOLESS(target[X_AXIS], min_pos[X_AXIS]);
NOLESS(target[Y_AXIS], min_pos[Y_AXIS]);
......@@ -6573,7 +6577,7 @@ void clamp_to_software_endstops(float target[3]) {
#ifdef PREVENT_DANGEROUS_EXTRUDE
inline void prevent_dangerous_extrude(float &curr_e, float &dest_e) {
FORCE_INLINE void prevent_dangerous_extrude(float &curr_e, float &dest_e) {
float de = dest_e - curr_e;
if (debugLevel & DEBUG_DRYRUN) return;
if (de) {
......@@ -6594,38 +6598,93 @@ void clamp_to_software_endstops(float target[3]) {
#if defined(DELTA) || defined(SCARA)
inline bool prepare_move_delta() {
FORCE_INLINE bool prepare_move_delta() {
float difference[NUM_AXIS];
float addDistance[NUM_AXIS];
float fractions[NUM_AXIS];
float frfm = feedrate/60*feedrate_multiplier/100.0;
for (int8_t i = 0; i < NUM_AXIS; i++) difference[i] = destination[i] - current_position[i];
float cartesian_mm = sqrt(sq(difference[X_AXIS]) + sq(difference[Y_AXIS]) + sq(difference[Z_AXIS]));
if (cartesian_mm < 0.000001) cartesian_mm = abs(difference[E_AXIS]);
if (cartesian_mm < 0.000001) return false;
float seconds = 6000 * cartesian_mm / feedrate / feedrate_multiplier;
int steps = max(1, int(delta_segments_per_second * seconds));
// ECHO_SMV(DB, "mm =", cartesian_mm);
// ECHO_MV(" seconds =", seconds);
// ECHOEMV(" steps =", steps);
for (int s = 1; s <= steps; s++) {
#if defined(DELTA_SEGMENTS_PER_SECOND) || defined(SCARA_SEGMENTS_PER_SECOND)
float seconds = 6000 * cartesian_mm / feedrate / feedrate_multiplier;
int steps = max(1, int(delta_segments_per_second * seconds));
#else
float fTemp = cartesian_mm * 5;
int steps = (int)fTemp;
float fraction = float(s) / float(steps);
if (steps == 0) {
steps = 1;
for (int8_t i=0; i < NUM_AXIS; i++) fractions[i] = difference[i];
}
else {
fTemp = 1 / float(steps);
for (int8_t i=0; i < NUM_AXIS; i++) fractions[i] = difference[i] * fTemp;
}
for (int8_t i = 0; i < NUM_AXIS; i++)
destination[i] = current_position[i] + difference[i] * fraction;
// For number of steps, for each step add one fraction
// First, set initial destination to current position
for (int8_t i=0; i < NUM_AXIS; i++) addDistance[i] = 0.0;
#endif
calculate_delta(destination);
adjust_delta(destination);
for (int s = 1; s <= steps; s++) {
//ECHO_LMV(DB, "destination[X_AXIS]=", destination[X_AXIS]);
//ECHO_LMV(DB, "destination[Y_AXIS]="); SERIAL_ECHOLN(destination[Y_AXIS]);
//ECHO_LMV(DB, "destination[Z_AXIS]="); SERIAL_ECHOLN(destination[Z_AXIS]);
//ECHO_LMV(DB, "delta[X_AXIS]=", delta[X_AXIS]);
//ECHO_LMV(DB, "delta[Y_AXIS]=", delta[Y_AXIS]);
//ECHO_LMV(DB, "delta[Z_AXIS]=", delta[Z_AXIS]);
#if defined(DELTA_SEGMENTS_PER_SECOND) || defined(SCARA_SEGMENTS_PER_SECOND)
float fraction = float(s) / float(steps);
for (int8_t i = 0; i < NUM_AXIS; i++)
destination[i] = current_position[i] + difference[i] * fraction;
#else
for (int8_t i=0; i < NUM_AXIS; i++) {
addDistance[i] += fractions[i];
destination[i] = current_position[i] + addDistance[i];
}
#endif
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate/60*feedrate_multiplier/100.0, active_extruder, active_driver);
//calculate_delta(destination);
delta[X_AXIS] = sqrt(delta_diagonal_rod_2
- sq(delta_tower1_x-destination[X_AXIS])
- sq(delta_tower1_y-destination[Y_AXIS])
) + destination[Z_AXIS];
delta[Y_AXIS] = sqrt(delta_diagonal_rod_2
- sq(delta_tower2_x-destination[X_AXIS])
- sq(delta_tower2_y-destination[Y_AXIS])
) + destination[Z_AXIS];
delta[Z_AXIS] = sqrt(delta_diagonal_rod_2
- sq(delta_tower3_x-destination[X_AXIS])
- sq(delta_tower3_y-destination[Y_AXIS])
) + destination[Z_AXIS];
//adjust_delta(destination);
float grid_x = destination[X_AXIS] * AUTOLEVEL_GRID_MULTI;
if (2.999 < grid_x) grid_x = 2.999;
else if (-2.999 > grid_x) grid_x = -2.999;
float grid_y = destination[Y_AXIS] * AUTOLEVEL_GRID_MULTI;
if (2.999 < grid_y) grid_y = 2.999;
else if (-2.999 > grid_y) grid_y = -2.999;
int floor_x = floor(grid_x);
int floor_y = floor(grid_y);
float ratio_x = grid_x - floor_x;
float ratio_y = grid_y - floor_y;
float z1 = bed_level[floor_x+3][floor_y+3];
float z2 = bed_level[floor_x+3][floor_y+4];
float z3 = bed_level[floor_x+4][floor_y+3];
float z4 = bed_level[floor_x+4][floor_y+4];
float left = (1-ratio_y)*z1 + ratio_y*z2;
float right = (1-ratio_y)*z3 + ratio_y*z4;
float offset = (1-ratio_x)*left + ratio_x*right;
delta[X_AXIS] += offset;
delta[Y_AXIS] += offset;
delta[Z_AXIS] += offset;
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], frfm, active_extruder, active_driver);
}
return true;
}
......
......@@ -37,6 +37,12 @@
#define ENCODER_STEPS_PER_MENU_ITEM 1
#endif
// Generic support for SSD1306 OLED based LCDs.
#if defined(U8GLIB_SSD1306)
#define ULTRA_LCD //general LCD support, also 16x2
#define DOGLCD // Support for I2C LCD 128x64 (Controller SSD1306 graphic Display Family)
#endif
#ifdef PANEL_ONE
#define SDSUPPORT
#define ULTIMAKERCONTROLLER
......@@ -202,6 +208,9 @@
#ifdef U8GLIB_ST7920
#undef HAS_LCD_CONTRAST
#endif
#ifdef U8GLIB_SSD1306
#undef HAS_LCD_CONTRAST
#endif
#endif
/**
......@@ -320,6 +329,7 @@
*/
#ifdef DELTA
#undef SLOWDOWN //DELTA not needs SLOWDOWN
#define AUTOLEVEL_GRID_MULTI 1/AUTOLEVEL_GRID
// DELTA must have same valour for 3 axis endstop hits
#undef Y_HOME_BUMP_MM
#undef Z_HOME_BUMP_MM
......
......@@ -35,7 +35,7 @@
#include "ultralcd_st7920_u8glib_rrd.h"
#include "Configuration.h"
#if defined(MAPPER_C2C3) && defined(MAPPER_NON) && defined(USE_BIG_EDIT_FONT)
#if !defined(MAPPER_C2C3) && !defined(MAPPER_NON) && defined(USE_BIG_EDIT_FONT)
#undef USE_BIG_EDIT_FONT
#endif
......@@ -125,6 +125,9 @@
#elif defined(U8GLIB_LM6059_AF)
// Based on the Adafruit ST7565 (http://www.adafruit.com/products/250)
U8GLIB_LM6059 u8g(DOGLCD_CS, DOGLCD_A0);
#elif defined U8GLIB_SSD1306
// Generic support for SSD1306 OLED I2C LCDs
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);
#else
// for regular DOGM128 display with HW-SPI
U8GLIB_DOGM128 u8g(DOGLCD_CS, DOGLCD_A0); // HW-SPI Com: CS, A0
......@@ -344,19 +347,28 @@ static void lcd_implementation_status_screen() {
u8g.drawPixel(8,XYZ_BASELINE - 5);
u8g.drawPixel(8,XYZ_BASELINE - 3);
u8g.setPrintPos(10,XYZ_BASELINE);
lcd_print(ftostr31ns(current_position[X_AXIS]));
if (axis_known_position[X_AXIS])
lcd_print(ftostr31ns(current_position[X_AXIS]));
else
lcd_printPGM(PSTR("---"));
u8g.setPrintPos(43,XYZ_BASELINE);
lcd_print('Y');
u8g.drawPixel(49,XYZ_BASELINE - 5);
u8g.drawPixel(49,XYZ_BASELINE - 3);
u8g.setPrintPos(51,XYZ_BASELINE);
lcd_print(ftostr31ns(current_position[Y_AXIS]));
if (axis_known_position[Y_AXIS])
lcd_print(ftostr31ns(current_position[Y_AXIS]));
else
lcd_printPGM(PSTR("---"));
u8g.setPrintPos(83,XYZ_BASELINE);
lcd_print('Z');
u8g.drawPixel(89,XYZ_BASELINE - 5);
u8g.drawPixel(89,XYZ_BASELINE - 3);
u8g.setPrintPos(91,XYZ_BASELINE);
lcd_print(ftostr31(current_position[Z_AXIS]));
if (axis_known_position[Z_AXIS])
lcd_print(ftostr32sp(current_position[Z_AXIS]));
else
lcd_printPGM(PSTR("---.--"));
u8g.setColorIndex(1); // black on white
// Feedrate
......
......@@ -558,8 +558,8 @@ ISR(TIMER1_COMPA_vect) {
if (z_test && current_block->steps[Z_AXIS] > 0) { // z_test = Z_MIN || Z2_MIN
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
endstop_hit_bits |= BIT(Z_MIN);
if (!performing_homing || (performing_homing && !((~z_test) & 0x3))) //if not performing home or if both endstops were trigged during homing...
step_events_completed = current_block->step_event_count; //!((~z_test) & 0x3) = Z_MIN && Z2_MIN
if (!performing_homing || (z_test == 0x3)) //if not performing home or if both endstops were trigged during homing...
step_events_completed = current_block->step_event_count;
}
#else // !Z_DUAL_ENDSTOPS
......@@ -569,7 +569,6 @@ ISR(TIMER1_COMPA_vect) {
#ifdef Z_PROBE_ENDSTOP
UPDATE_ENDSTOP(Z, PROBE);
SET_ENDSTOP_BIT(Z, PROBE);
if (TEST_ENDSTOP(Z_PROBE)) {
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
......@@ -594,8 +593,8 @@ ISR(TIMER1_COMPA_vect) {
if (z_test && current_block->steps[Z_AXIS] > 0) { // t_test = Z_MAX || Z2_MAX
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
endstop_hit_bits |= BIT(Z_MIN);
if (!performing_homing || (performing_homing && !((~z_test) & 0x3))) //if not performing home or if both endstops were trigged during homing...
step_events_completed = current_block->step_event_count; //!((~z_test) & 0x3) = Z_MAX && Z2_MAX
if (!performing_homing || (z_test == 0x3)) //if not performing home or if both endstops were trigged during homing...
step_events_completed = current_block->step_event_count;
}
#else // !Z_DUAL_ENDSTOPS
......
......@@ -1246,7 +1246,7 @@ static void lcd_control_volumetric_menu() {
* "Control" > "Contrast" submenu
*
*/
#if HAS_LCD_CONTRAST
#ifdef HAS_LCD_CONTRAST
static void lcd_set_contrast() {
if (encoderPosition != 0) {
#ifdef U8GLIB_LM6059_AF
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment