mirror of
https://github.com/synthetos/g2.git
synced 2026-09-24 05:44:25 +08:00
Fixed bug caused by length_square vector being uninitialized; moved base application settings from hardware.h to g2core.h (still need to do all the hardware.h’s); some cosmetic changes
This commit is contained in:
@@ -64,12 +64,12 @@ stat_t hardware_periodic()
|
||||
|
||||
void hw_hard_reset(void)
|
||||
{
|
||||
Motate::System::reset(/*boootloader: */ false); // arg=0 resets the system
|
||||
Motate::System::reset(/*bootloader: */ false); // arg=0 resets the system
|
||||
}
|
||||
|
||||
void hw_flash_loader(void)
|
||||
{
|
||||
Motate::System::reset(/*boootloader: */ true); // arg=1 erases FLASH and enters FLASH loader
|
||||
Motate::System::reset(/*bootloader: */ true); // arg=1 erases FLASH and enters FLASH loader
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -40,24 +40,28 @@
|
||||
#define G2CORE_HARDWARE_PLATFORM "g2v9"
|
||||
#define G2CORE_HARDWARE_VERSION "k"
|
||||
|
||||
/***** Axes, motors & PWM channels used by the application *****/
|
||||
// Axes, motors & PWM channels must be defines (not enums) so expressions like this:
|
||||
/***** Motors & PWM channels supported by this hardware *****/
|
||||
// These must be defines (not enums) so expressions like this:
|
||||
// #if (MOTORS >= 6) will work
|
||||
|
||||
#define AXES 9 // number of axes supported in this version
|
||||
#define HOMING_AXES 4 // number of axes that can be homed (assumes Zxyabc sequence)
|
||||
#define MOTORS 4 // number of motors on the board
|
||||
#define COORDS 6 // number of supported coordinate systems (index starts at 1)
|
||||
#define PWMS 2 // number of supported PWM channels
|
||||
#define TOOLS 32 // number of entries in tool table (index starts at 1)
|
||||
#define MOTORS 4 // number of motors supported the hardware
|
||||
#define PWMS 2 // number of PWM channels supported the hardware
|
||||
|
||||
/*************************
|
||||
* Global System Defines *
|
||||
*************************/
|
||||
|
||||
#define MILLISECONDS_PER_TICK 1 // MS for system tick (systick * N)
|
||||
#define SYS_ID_DIGITS 16 // actual digits in system ID (up to 16)
|
||||
#define SYS_ID_LEN 24 // total length including dashes and NUL
|
||||
|
||||
/*************************
|
||||
* Motate Setup *
|
||||
*************************/
|
||||
|
||||
#include "MotatePins.h"
|
||||
#include "MotateTimers.h" // for TimerChanel<> and related...
|
||||
#include "MotateServiceCall.h" // for ServiceCall<>
|
||||
#include "MotateTimers.h" // for TimerChanel<> and related...
|
||||
#include "MotateServiceCall.h" // for ServiceCall<>
|
||||
|
||||
using Motate::TimerChannel;
|
||||
using Motate::ServiceCall;
|
||||
@@ -67,14 +71,6 @@ using Motate::Pin;
|
||||
using Motate::PWMOutputPin;
|
||||
using Motate::OutputPin;
|
||||
|
||||
/*************************
|
||||
* Global System Defines *
|
||||
*************************/
|
||||
|
||||
#define MILLISECONDS_PER_TICK 1 // MS for system tick (systick * N)
|
||||
#define SYS_ID_DIGITS 16 // actual digits in system ID (up to 16)
|
||||
#define SYS_ID_LEN 24 // total length including dashes and NUL
|
||||
|
||||
/************************************************************************************
|
||||
**** ARM SAM3X8E SPECIFIC HARDWARE *************************************************
|
||||
************************************************************************************/
|
||||
|
||||
@@ -362,8 +362,8 @@ static void _motion_end_callback(float* vect, bool* flag)
|
||||
}
|
||||
|
||||
static stat_t _homing_axis_move(int8_t axis, float target, float velocity) {
|
||||
float vect[] = {0,0,0,0,0,0};
|
||||
bool flags[] = {0,0,0,0,0,0};
|
||||
float vect[] = INIT_AXES_ZEROES;
|
||||
bool flags[] = INIT_AXES_ZEROES;
|
||||
|
||||
hm.waiting_for_motion_end = true;
|
||||
|
||||
|
||||
@@ -60,6 +60,11 @@ typedef uint16_t magic_t; // magic number size
|
||||
|
||||
// Note: If you change COORDS you must adjust the entries in cfgArray table in config.c
|
||||
|
||||
#define AXES 9 // number of axes supported in this version
|
||||
#define HOMING_AXES 4 // number of axes that can be homed (assumes Zxyabc sequence)
|
||||
#define COORDS 6 // number of supported coordinate systems (index starts at 1)
|
||||
#define TOOLS 32 // number of entries in tool table (index starts at 1)
|
||||
|
||||
typedef enum {
|
||||
AXIS_X = 0,
|
||||
AXIS_Y,
|
||||
|
||||
+2
-3
@@ -33,15 +33,14 @@
|
||||
*/
|
||||
//--- change as required for board and switch hardware ---//
|
||||
|
||||
#define INPUT_LOCKOUT_MS 10 // milliseconds to go dead after input firing
|
||||
|
||||
#define D_IN_CHANNELS 9 // v9 // number of digital inputs supported
|
||||
//#define D_OUT_CHANNELS 13 // number of digital outputs supported
|
||||
#define D_OUT_CHANNELS 9 // number of digital outputs supported
|
||||
#define A_IN_CHANNELS 0 // number of analog inputs supported
|
||||
#define A_OUT_CHANNELS 0 // number of analog outputs supported
|
||||
|
||||
//#define INPUT_LOCKOUT_MS 50 // milliseconds to go dead after input firing
|
||||
#define INPUT_LOCKOUT_MS 10 // milliseconds to go dead after input firing
|
||||
|
||||
//--- do not change from here down ---//
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -143,10 +143,11 @@ bool mp_runtime_is_idle() { return (!st_runtime_isbusy()); }
|
||||
|
||||
stat_t mp_aline(GCodeState_t* _gm)
|
||||
{
|
||||
float target_rotated[AXES]; // all these arrays initialize to all zeroes by compiler settings
|
||||
float axis_square[AXES];
|
||||
float axis_length[AXES];
|
||||
bool flags[AXES];
|
||||
float target_rotated[] = INIT_AXES_ZEROES;
|
||||
float axis_square[] = INIT_AXES_ZEROES;
|
||||
float axis_length[] = INIT_AXES_ZEROES;
|
||||
bool flags[] = INIT_AXES_FALSE;
|
||||
|
||||
float length_square = 0;
|
||||
float length;
|
||||
|
||||
@@ -199,6 +200,7 @@ stat_t mp_aline(GCodeState_t* _gm)
|
||||
length_square += axis_square[axis];
|
||||
} else {
|
||||
axis_length[axis] = 0; // make it truly zero if it was tiny
|
||||
axis_square[axis] = 0; // Fix bug that can kill feedholds by corrupting block_time in _calculate_times
|
||||
}
|
||||
}
|
||||
length = sqrt(length_square);
|
||||
@@ -650,7 +652,7 @@ static void _calculate_vmaxes(mpBuf_t* bf, const float axis_length[], const floa
|
||||
if (bf->axis_flags[axis]) {
|
||||
if (bf->gm.motion_mode == MOTION_MODE_STRAIGHT_TRAVERSE) {
|
||||
tmp_time = fabs(axis_length[axis]) / cm->a[axis].velocity_max;
|
||||
} else { // gm.motion_mode == MOTION_MODE_STRAIGHT_FEED
|
||||
} else {// gm.motion_mode == MOTION_MODE_STRAIGHT_FEED
|
||||
tmp_time = fabs(axis_length[axis]) / cm->a[axis].feedrate_max;
|
||||
}
|
||||
max_time = max(max_time, tmp_time);
|
||||
|
||||
@@ -127,7 +127,7 @@ stat_t mp_calculate_ramps(mpBlockRuntimeBuf_t* block, mpBuf_t* bf, const float e
|
||||
}
|
||||
debug_trap_if_zero(bf->length, "mp_calculate_ramps() - got L=0");
|
||||
debug_trap_if_zero(bf->cruise_velocity, "mp_calculate_ramps() - got Vc=0");
|
||||
|
||||
|
||||
// Timings from *here*
|
||||
|
||||
// initialize parameters to know values
|
||||
|
||||
@@ -54,9 +54,9 @@
|
||||
#define FEEDHOLD_Z_LIFT 3 // mm to lift Z on feedhold
|
||||
#define PROBE_REPORT_ENABLE true
|
||||
|
||||
// WARNING: Older Othermill machines use a 15deg can stack for their Z axis.
|
||||
// new machines use a stepper which has the same config as the other axis.
|
||||
#define HAS_CANSTACK_Z_AXIS 0
|
||||
// WARNING: Very old, pre-release Othermills may have a 15deg can stack for their Z axis.
|
||||
// All other machines use a stepper which has the same config as the other axis.
|
||||
#define HAS_CANSTACK_Z_AXIS false
|
||||
/*
|
||||
// Switch definitions for interlock & E-stop
|
||||
#define ENABLE_INTERLOCK_AND_ESTOP
|
||||
@@ -218,61 +218,6 @@
|
||||
#define Z_LATCH_BACKOFF 2
|
||||
#define Z_ZERO_BACKOFF 0.4
|
||||
|
||||
|
||||
/*
|
||||
#define JERK_MAX 500 // 500 million mm/(min^3)
|
||||
#define JERK_HIGH_SPEED 1000 // 1000 million mm/(min^3) // Jerk during homing needs to stop *fast*
|
||||
#define VELOCITY_MAX 1500
|
||||
#define SEARCH_VELOCITY (VELOCITY_MAX / 3)
|
||||
#define LATCH_VELOCITY 25 // reeeeally slow for accuracy
|
||||
|
||||
#define X_AXIS_MODE AXIS_STANDARD // xam see canonical_machine.h cmAxisMode for valid values
|
||||
#define X_VELOCITY_MAX VELOCITY_MAX // xvm G0 max velocity in mm/min
|
||||
#define X_FEEDRATE_MAX X_VELOCITY_MAX // xfr G1 max feed rate in mm/min
|
||||
#define X_TRAVEL_MIN 0 // xtn minimum travel for soft limits
|
||||
#define X_TRAVEL_MAX 145.6 // xtr travel between switches or crashes
|
||||
#define X_JERK_MAX JERK_MAX // xjm
|
||||
#define X_JERK_HIGH_SPEED JERK_HIGH_SPEED // xjh
|
||||
#define X_HOMING_INPUT 1 // xhi input used for homing or 0 to disable
|
||||
#define X_HOMING_DIRECTION 0 // xhd 0=search moves negative, 1= search moves positive
|
||||
#define X_SEARCH_VELOCITY SEARCH_VELOCITY // xsv
|
||||
#define X_LATCH_VELOCITY LATCH_VELOCITY // xlv mm/min
|
||||
#define X_LATCH_BACKOFF 1 // xlb mm
|
||||
#define X_ZERO_BACKOFF 0.4 // xzb mm
|
||||
|
||||
#define Y_AXIS_MODE AXIS_STANDARD
|
||||
#define Y_VELOCITY_MAX VELOCITY_MAX
|
||||
#define Y_FEEDRATE_MAX Y_VELOCITY_MAX
|
||||
#define Y_TRAVEL_MIN 0
|
||||
#define Y_TRAVEL_MAX 119.1
|
||||
#define Y_JERK_MAX JERK_MAX
|
||||
#define Y_JERK_HIGH_SPEED JERK_HIGH_SPEED
|
||||
#define Y_HOMING_INPUT 3
|
||||
#define Y_HOMING_DIRECTION 0
|
||||
#define Y_SEARCH_VELOCITY SEARCH_VELOCITY
|
||||
#define Y_LATCH_VELOCITY LATCH_VELOCITY
|
||||
#define Y_LATCH_BACKOFF 1
|
||||
#define Y_ZERO_BACKOFF 0.4
|
||||
|
||||
#define Z_AXIS_MODE AXIS_STANDARD
|
||||
#if HAS_CANSTACK_Z_AXIS
|
||||
#define Z_VELOCITY_MAX 1000
|
||||
#else
|
||||
#define Z_VELOCITY_MAX VELOCITY_MAX
|
||||
#endif
|
||||
#define Z_FEEDRATE_MAX Z_VELOCITY_MAX
|
||||
#define Z_TRAVEL_MIN -60.1
|
||||
#define Z_TRAVEL_MAX 0
|
||||
#define Z_JERK_MAX JERK_MAX
|
||||
#define Z_JERK_HIGH_SPEED JERK_HIGH_SPEED
|
||||
#define Z_HOMING_INPUT 6
|
||||
#define Z_HOMING_DIRECTION 1
|
||||
#define Z_SEARCH_VELOCITY SEARCH_VELOCITY
|
||||
#define Z_LATCH_VELOCITY LATCH_VELOCITY
|
||||
#define Z_LATCH_BACKOFF 1
|
||||
#define Z_ZERO_BACKOFF 0.4
|
||||
*/
|
||||
|
||||
//*** Input / output settings ***
|
||||
/*
|
||||
See gpio.h GPIO defines for options
|
||||
@@ -356,10 +301,3 @@
|
||||
#define P1_CCW_PHASE_HI 0.1
|
||||
#define P1_PWM_PHASE_OFF 0.1
|
||||
|
||||
/*
|
||||
#define P1_USE_MAPPING_CUBIC
|
||||
#define P1_MAPPING_CUBIC_X3 2.1225328766717546e-013
|
||||
#define P1_MAPPING_CUBIC_X2 -7.2900167282605129e-009
|
||||
#define P1_MAPPING_CUBIC_X1 8.5854646785876479e-005
|
||||
#define P1_MAPPING_CUBIC_X0 -2.1301489219406905e-001
|
||||
*/
|
||||
@@ -74,6 +74,16 @@ uint8_t vector_equal(const float a[], const float b[]);
|
||||
float *set_vector(float x, float y, float z, float a, float b, float c);
|
||||
float *set_vector_by_axis(float value, uint8_t axis);
|
||||
|
||||
// *** canned initializers ***
|
||||
|
||||
#if (AXES == 9)
|
||||
#define INIT_AXES_ZEROES {0,0,0,0,0,0,0,0,0}
|
||||
#define INIT_AXES_TRUE {1,1,1,1,1,1,1,1,1}
|
||||
#define INIT_AXES_FALSE INIT_AXES_ZEROES
|
||||
#else
|
||||
#warning UNSUPPORTED AXES SETTING!
|
||||
#endif
|
||||
|
||||
//*** math utilities ***
|
||||
|
||||
float min3(float x1, float x2, float x3);
|
||||
|
||||
Reference in New Issue
Block a user