Config file cleanup, support for M301 code.

master
Martin 2018-11-30 20:03:21 +01:00
rodzic 0f6a458717
commit caee3af9d1
4 zmienionych plików z 70 dodań i 57 usunięć

Wyświetl plik

@ -19,6 +19,23 @@ Most of the configuration is described and is in *config.h* file.
To disable simulavr info sections, launch make with variable set `SIMULFLAGS= `
Example command for flashing Arduino UNO: `make flash MCU=atmega328p SIMULFLAGS= UPLOAD_PORT=/dev/ttyACM0`, assuming that configuration is complete. Makefile contains paths configuration to arduino core or mighty core, they need to be set up correctly. Project does not use arduino libraries at all, it is just compatible with Arduio IDE which should be capable of whole compilation and memory programming task, just open the *.ino* file.
## List of supported G-codes
For now parser is kept simple and not so proof for sophisticated errors in code syntax.
- **G0 X? Y? F?** - liner move - jump, F is an feedrate
- **G1 X? Y? F?** - linear move - stitch
- **G28** - home axes
- **G90** - set to absolute positioning
- **G91** - set to relative positioning
- **M0** - unconditional stop of all movement in progress
- **M112** - kill, stops everything and requires reset
- **M114** - get current position info
- **M119** - get endstop triggers status
- **M222 S?** - sets the motor max speed limit in SPM
- **M301 S? P? I?** - set the kP and kI values, S sets the current motor speed for tuning purposes
## Source files description
Code is written in pure C.

Wyświetl plik

@ -23,7 +23,7 @@
#define KINEMATICS_COREXY
/** \def X_MIN X_MAX Y_MIN Y_MAX Z_MIN Z_MAX
/** \def X_MIN X_MAX Y_MIN Y_MAX
Soft axis limits. Define them to your machine's size relative to what your
G-code considers to be the origin.
@ -44,11 +44,8 @@
#define Y_MIN 0.0
#define Y_MAX 280.0
//#define Z_MIN 0.0
//#define Z_MAX 140.0
/** \def STEPS_PER_M_X STEPS_PER_M_Y STEPS_PER_M_Z STEPS_PER_M_E
/** \def STEPS_PER_M_X STEPS_PER_M_Y
Steps per meter ( = steps per mm * 1000 ), calculate these values
appropriate for your machine.
@ -61,25 +58,20 @@
**/
#define STEPS_PER_M_X 87575
#define STEPS_PER_M_Y 87575
/*#define STEPS_PER_M_Z 1280000
#define STEPS_PER_M_E 96271
*/
/** \def SEARCH_FEEDRATE_X SEARCH_FEEDRATE_Y SEARCH_FEEDRATE_Z
/** \def SEARCH_FEEDRATE_X SEARCH_FEEDRATE_Y
Used when doing precision endstop search and as default feedrate.
(mm / min) 60 mm / min = 1 mm/sec
*/
#define SEARCH_FEEDRATE_X 10000
#define SEARCH_FEEDRATE_Y 10000
//#define SEARCH_FEEDRATE_Z 400
/** \def MAXIMUM_FEEDRATE_X MAXIMUM_FEEDRATE_Y MAXIMUM_FEEDRATE_Z MAXIMUM_FEEDRATE_E
/** \def MAXIMUM_FEEDRATE_X MAXIMUM_FEEDRATE_Y
Used for G0 rapid moves and as a cap for all other feedrates. (mm / min)
*/
#define MAXIMUM_FEEDRATE_X 33000
#define MAXIMUM_FEEDRATE_Y 33000
/*#define MAXIMUM_FEEDRATE_Z 6000
#define MAXIMUM_FEEDRATE_E 20000
*/
/** \def ACCELERATION
How fast to accelerate when using ACCELERATION_RAMPING. Start with 10 for
milling (high precision) or 1000 for printing.
@ -145,7 +137,8 @@
*/
//#define LOOKAHEAD
/** \def MAX_JERK_X MAX_JERK_Y MAX_JERK_Z MAX_JERK_E
/** \def MAX_JERK_X MAX_JERK_Y
Not used for embroidery, with lookahead disabled.
When performing look-ahead, we need to decide what an acceptable jerk to the
mechanics is. Look-ahead attempts to instantly change direction at movement
crossings, which means instant changes in the speed of the axes participating
@ -169,8 +162,6 @@
*/
#define MAX_JERK_X 400
#define MAX_JERK_Y 400
/*#define MAX_JERK_Z 0
#define MAX_JERK_E 200*/
/** \def BAUD
@ -202,71 +193,51 @@
* Here you can setup pin functions, depending on board configuration.
* Comment board define above to enable this customizable config.
**/
#ifndef MOTHERBOARD
#define MOTHERBOARD
// X AXIS
#define X_STEP_PIN PC3
// 19 PC3
#define X_DIR_PIN PC2
// 18 PC2
#define X_MIN_PIN PA5
//35 PA5
//#define X_MAX_PIN DIO2
//#define X_MIN_PIN PA5
#define X_MAX_PIN PA5
#define X_ENABLE_PIN PC4
// 20 PC4
#define X_INVERT_DIR
#define X_INVERT_MIN
#define X_INVERT_MAX
#define X_INVERT_ENABLE
// Y AXIS
#define Y_STEP_PIN DIO9
//22 PC6
#define Y_DIR_PIN PC5
//21 PC5
// 16 PD2
#define Y_MIN_PIN PA6
//#define Y_MAX_PIN DIO7
//#define Y_MIN_PIN PA6
#define Y_MAX_PIN PA6
#define Y_ENABLE_PIN DIO10
//23 PC7
#define Y_INVERT_DIR
#define Y_INVERT_MIN
#define Y_INVERT_MAX
#define Y_INVERT_ENABLE
/*#define Z_STEP_PIN DIO11
#define Z_DIR_PIN DIO12
#define Z_MIN_PIN DIO13
#define Z_MAX_PIN DIO14
#define Z_ENABLE_PIN DIO15
#define Z_INVERT_DIR
#define Z_INVERT_MIN
#define Z_INVERT_MAX
#define Z_INVERT_ENABLE
#define E_STEP_PIN DIO23
#define E_DIR_PIN DIO0
#define E_ENABLE_PIN DIO22
#define E_INVERT_DIR
#define E_INVERT_ENABLE
*/
#define PWR_OUT1_PIN PD4
#define PWR_OUT2_PIN PD5
#define ANALOG_IN_PIN 33
#define SWITCH1_PIN 34
#define SWITCH2_PIN 35
#define SWITCH3_PIN PD2
/** \def ENCODER_PIN
* ENCODER_PIN_A must be connected to INT1 pin for external interrupt to work!
* ENCODER_PIN_A must be INT1 digital pin for external interrupt to work!
* Motor encoder needs INT0 pin.
**/
#define ENCODER_PIN_A PD3
#define ENCODER_PIN_B PA4
/** \def INVERT_DIRECTION_ENCODER
* Enable or disable these if the steppers movement is triggered when
* the needle moves downwards instead of when upwards.
**/
#define INVERT_DIRECTION_ENCODER
#endif
//#define FAST_PWM
/** \def PULSES_PER_TURN
* Motor encoder pulses per one machine shaft revolution.
* If encoder wheel is mounted on motor pulley for better resolution,
@ -323,7 +294,7 @@
Sane values: 5 to 16
Valid range: 1 to 200
**/
#define MAX_JUMP_LENGTH 12
#define MAX_JUMP_LENGTH 16
/** \def JUMP_MOTOR_SPEED_DIFF_MAX
* This parameter tells motor speed planner to try keep maximal possible

Wyświetl plik

@ -9,7 +9,9 @@
GCODE_PARAM BSS gcode_params[8];
static volatile uint8_t current_parameter = 0;
uint8_t option_all_relative = 0;
int16_t parameter_1 = 0;
int16_t parameter_0 = -1;
int32_t parameter_1 = -1, parameter_2 = -1;
TARGET BSS next_target;
// Parser is implemented as a finite state automata (DFA)
@ -95,8 +97,14 @@ uint8_t process_command()
next_target.F = decfloat_to_int(gcode_params[i].value, gcode_params[i].exponent, gcode_params[i].is_negative, 1);
break;
case 'S':
parameter_0 = decfloat_to_int(gcode_params[i].value, gcode_params[i].exponent, gcode_params[i].is_negative, 1);
break;
case 'P':
parameter_1 = decfloat_to_int(gcode_params[i].value, gcode_params[i].exponent, gcode_params[i].is_negative, 1);
break;
case 'I':
parameter_2 = decfloat_to_int(gcode_params[i].value, gcode_params[i].exponent, gcode_params[i].is_negative, 1);
break;
}
}
// convert relative to absolute
@ -150,6 +158,7 @@ uint8_t process_command()
//? Example: M0
//?
//? Stop or unconditional stop
desired_speed = 0;
ATOMIC_START
dda = queue_current_movement();
if (dda != NULL)
@ -175,6 +184,7 @@ uint8_t process_command()
//? restart is to press the reset button on the master microcontroller.
//? See also M0.
//?
desired_speed = 0;
timer_stop();
queue_flush();
cli();
@ -215,7 +225,21 @@ uint8_t process_command()
//? Example: M222 S400
//?
//? Set dc motor max speed
set_dc_motor_speed_margin(parameter_1);
set_dc_motor_speed_margin(parameter_0);
parameter_0 = -1;
break;
case 301:
//? Example: M301 S0 P40000 I2000
//?
//? Set dc motor kP and kI controller parameters, S is a speed
if(parameter_0 >= 0)
desired_speed = parameter_0;
if(parameter_1 >= 0)
kp = parameter_1;
if(parameter_2 >= 0)
ki = parameter_2;
sersendf_P(PSTR("S:%d,P:%ld,I:%ld\n"),
desired_speed, kp, ki);
break;
default:
result = STATE_ERROR;

Wyświetl plik

@ -12,6 +12,7 @@
extern int16_t desired_speed;
extern int16_t margin_max_speed;
extern int32_t kp, ki;
void stop_dc_motor(uint8_t);
#ifdef __cplusplus