$140, $141, $142 current control
This commit is contained in:
parent
b32be3d2c1
commit
6b1e180e66
@ -21,6 +21,11 @@ Usage notes:
|
||||
* Hard limits not yet ported
|
||||
* Control inputs not yet ported (e.g. Cycle Start and Safety Door switches)
|
||||
|
||||
New configuration settings
|
||||
* $140, $141, $142 are X, Y, Z current (amps)
|
||||
* Default to 0.0 A to avoid burning out your motors
|
||||
* Your motors will likely stall if you don't set these!
|
||||
|
||||
Build notes:
|
||||
* Include ```make``` and the ```arm-none-eabi-*``` tools in your path.
|
||||
* Make produces 2 files:
|
||||
|
@ -24,6 +24,10 @@
|
||||
#include "grbl.h"
|
||||
#include "Driver_I2C.h"
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef CURRENT_I2C
|
||||
extern ARM_DRIVER_I2C CURRENT_I2C;
|
||||
static const uint8_t wiperRegs[] = CURRENT_WIPERS;
|
||||
@ -48,9 +52,9 @@ void current_init()
|
||||
;
|
||||
#endif
|
||||
|
||||
set_current(0, DEFAULT_X_CURRENT);
|
||||
set_current(1, DEFAULT_Y_CURRENT);
|
||||
set_current(2, DEFAULT_Z_CURRENT);
|
||||
set_current(0, settings.current[0]);
|
||||
set_current(1, settings.current[1]);
|
||||
set_current(2, settings.current[2]);
|
||||
set_current(3, DEFAULT_A_CURRENT);
|
||||
#endif
|
||||
}
|
||||
@ -60,7 +64,7 @@ void set_current(uint8_t motor, float amps)
|
||||
#if defined(CURRENT_I2C) && defined(CURRENT_MCP44XX_ADDR)
|
||||
uint8_t command[] = {
|
||||
uint8_t(wiperRegs[motor] << 4),
|
||||
uint8_t(std::round(amps * CURRENT_FACTOR)),
|
||||
uint8_t(std::min(255.0, std::max(0.0, std::round(amps * CURRENT_FACTOR)))),
|
||||
};
|
||||
CURRENT_I2C.MasterTransmit(CURRENT_MCP44XX_ADDR, command, sizeof(command), false);
|
||||
while (CURRENT_I2C.GetStatus().busy)
|
||||
|
@ -731,8 +731,8 @@
|
||||
#define DEFAULT_X_ACCELERATION (5000.0*60*60) // 5000*60*60 mm/min^2 = 5000 mm/sec^2
|
||||
#define DEFAULT_Y_ACCELERATION (5000.0*60*60) // 5000*60*60 mm/min^2 = 5000 mm/sec^2
|
||||
#define DEFAULT_Z_ACCELERATION (5000.0*60*60) // 5000*60*60 mm/min^2 = 5000 mm/sec^2
|
||||
#define DEFAULT_X_CURRENT 0.4 // amps
|
||||
#define DEFAULT_Y_CURRENT 1.5 // amps
|
||||
#define DEFAULT_X_CURRENT 0.0 // amps
|
||||
#define DEFAULT_Y_CURRENT 0.0 // amps
|
||||
#define DEFAULT_Z_CURRENT 0.0 // amps
|
||||
#define DEFAULT_A_CURRENT 0.0 // amps
|
||||
#define DEFAULT_X_MAX_TRAVEL 200.0 // mm
|
||||
|
@ -62,6 +62,7 @@
|
||||
#include "spindle_control.h"
|
||||
#include "stepper.h"
|
||||
#include "jog.h"
|
||||
#include "current_control.h"
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:
|
||||
|
@ -20,7 +20,6 @@
|
||||
*/
|
||||
|
||||
#include "grbl.h"
|
||||
#include "current_control.h"
|
||||
|
||||
void isr_init();
|
||||
|
||||
|
@ -218,6 +218,7 @@ void report_grbl_settings() {
|
||||
case 1: report_util_float_setting(val+idx,settings.max_rate[idx],N_DECIMAL_SETTINGVALUE); break;
|
||||
case 2: report_util_float_setting(val+idx,settings.acceleration[idx]/(60*60),N_DECIMAL_SETTINGVALUE); break;
|
||||
case 3: report_util_float_setting(val+idx,-settings.max_travel[idx],N_DECIMAL_SETTINGVALUE); break;
|
||||
case 4: report_util_float_setting(val+idx,settings.current[idx],N_DECIMAL_SETTINGVALUE); break;
|
||||
}
|
||||
}
|
||||
val += AXIS_SETTINGS_INCREMENT;
|
||||
|
@ -117,6 +117,9 @@ void settings_restore(uint8_t restore_flag) {
|
||||
settings.max_travel[X_AXIS] = (-DEFAULT_X_MAX_TRAVEL);
|
||||
settings.max_travel[Y_AXIS] = (-DEFAULT_Y_MAX_TRAVEL);
|
||||
settings.max_travel[Z_AXIS] = (-DEFAULT_Z_MAX_TRAVEL);
|
||||
settings.current[X_AXIS] = DEFAULT_X_CURRENT;
|
||||
settings.current[Y_AXIS] = DEFAULT_Y_CURRENT;
|
||||
settings.current[Z_AXIS] = DEFAULT_Z_CURRENT;
|
||||
|
||||
write_global_settings(false);
|
||||
}
|
||||
@ -231,6 +234,10 @@ uint8_t settings_store_global_setting(uint8_t parameter, float value) {
|
||||
break;
|
||||
case 2: settings.acceleration[parameter] = value*60*60; break; // Convert to mm/min^2 for grbl internal use.
|
||||
case 3: settings.max_travel[parameter] = -value; break; // Store as negative for grbl internal use.
|
||||
case 4:
|
||||
settings.current[parameter] = value;
|
||||
set_current(parameter, settings.current[parameter]);
|
||||
break;
|
||||
}
|
||||
break; // Exit while-loop after setting has been configured and proceed to the EEPROM write call.
|
||||
} else {
|
||||
|
@ -70,7 +70,7 @@
|
||||
// #define SETTING_INDEX_G92 N_COORDINATE_SYSTEM+2 // Coordinate offset (G92.2,G92.3 not supported)
|
||||
|
||||
// Define Grbl axis settings numbering scheme. Starts at START_VAL, every INCREMENT, over N_SETTINGS.
|
||||
#define AXIS_N_SETTINGS 4
|
||||
#define AXIS_N_SETTINGS 5
|
||||
#define AXIS_SETTINGS_START_VAL 100 // NOTE: Reserving settings values >= 100 for axis settings. Up to 255.
|
||||
#define AXIS_SETTINGS_INCREMENT 10 // Must be greater than the number of axis settings
|
||||
|
||||
@ -81,6 +81,7 @@ typedef struct {
|
||||
float max_rate[N_AXIS];
|
||||
float acceleration[N_AXIS];
|
||||
float max_travel[N_AXIS];
|
||||
float current[N_AXIS];
|
||||
|
||||
// Remaining Grbl settings
|
||||
uint8_t pulse_microseconds;
|
||||
|
Loading…
Reference in New Issue
Block a user