Merge pull request #100 from XPila/MK3
Fsensor synchronization and triggering improved
This commit is contained in:
commit
25b0b0b381
8 changed files with 15790 additions and 21 deletions
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
// Firmware version
|
// Firmware version
|
||||||
#define FW_version "3.0.12-RC2"
|
#define FW_version "3.0.12-RC2"
|
||||||
#define FW_build 110
|
#define FW_build 111
|
||||||
//#define FW_build --BUILD-NUMBER--
|
//#define FW_build --BUILD-NUMBER--
|
||||||
#define FW_version_build FW_version " b" STR(FW_build)
|
#define FW_version_build FW_version " b" STR(FW_build)
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
|
||||||
//#define DEBUG_BLINK_ACTIVE
|
//#define DEBUG_BLINK_ACTIVE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------
|
/*------------------------------------
|
||||||
TMC2130 default settings
|
TMC2130 default settings
|
||||||
*------------------------------------*/
|
*------------------------------------*/
|
||||||
|
@ -156,15 +157,15 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
|
||||||
#define TMC2130_SG_HOMING 1 // stallguard homing
|
#define TMC2130_SG_HOMING 1 // stallguard homing
|
||||||
//#define TMC2130_SG_HOMING_SW_XY 1 // stallguard "software" homing for XY axes
|
//#define TMC2130_SG_HOMING_SW_XY 1 // stallguard "software" homing for XY axes
|
||||||
#define TMC2130_SG_HOMING_SW_Z 1 // stallguard "software" homing for Z axis
|
#define TMC2130_SG_HOMING_SW_Z 1 // stallguard "software" homing for Z axis
|
||||||
#define TMC2130_SG_THRS_X 2 // stallguard sensitivity for X axis
|
#define TMC2130_SG_THRS_X 3 // stallguard sensitivity for X axis
|
||||||
#define TMC2130_SG_THRS_Y 3 // stallguard sensitivity for Y axis
|
#define TMC2130_SG_THRS_Y 4 // stallguard sensitivity for Y axis
|
||||||
#define TMC2130_SG_THRS_Z 3 // stallguard sensitivity for Z axis
|
#define TMC2130_SG_THRS_Z 3 // stallguard sensitivity for Z axis
|
||||||
#define TMC2130_SG_THRS_E 3 // stallguard sensitivity for E axis
|
#define TMC2130_SG_THRS_E 3 // stallguard sensitivity for E axis
|
||||||
#define TMC2130_SG_DELTA 128 // stallguard delta [usteps] (minimum usteps before stallguard readed - SW homing)
|
#define TMC2130_SG_DELTA 128 // stallguard delta [usteps] (minimum usteps before stallguard readed - SW homing)
|
||||||
|
|
||||||
//new settings is possible for vsense = 1, running current value > 31 set vsense to zero and shift both currents by 1 bit right (Z axis only)
|
//new settings is possible for vsense = 1, running current value > 31 set vsense to zero and shift both currents by 1 bit right (Z axis only)
|
||||||
#define TMC2130_CURRENTS_H {13, 20, 20, 40} // default holding currents for all axes
|
#define TMC2130_CURRENTS_H {13, 20, 20, 35} // default holding currents for all axes
|
||||||
#define TMC2130_CURRENTS_R {13, 20, 20, 40} // default running currents for all axes
|
#define TMC2130_CURRENTS_R {13, 20, 20, 35} // default running currents for all axes
|
||||||
|
|
||||||
//#define TMC2130_DEBUG
|
//#define TMC2130_DEBUG
|
||||||
//#define TMC2130_DEBUG_WR
|
//#define TMC2130_DEBUG_WR
|
||||||
|
|
|
@ -97,6 +97,13 @@ int parse_hex(char* hex, uint8_t* data, int count)
|
||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dcode__1()
|
||||||
|
{
|
||||||
|
printf("D-1 - Endless loop\n");
|
||||||
|
cli();
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
|
||||||
void dcode_0()
|
void dcode_0()
|
||||||
{
|
{
|
||||||
if (*(strchr_pointer + 1) == 0) return;
|
if (*(strchr_pointer + 1) == 0) return;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef DCODES_H
|
#ifndef DCODES_H
|
||||||
#define DCODES_H
|
#define DCODES_H
|
||||||
|
|
||||||
|
extern void dcode__1(); //D-1 - Endless loop (to simulate deadlock)
|
||||||
|
|
||||||
extern void dcode_0(); //D0 - Reset
|
extern void dcode_0(); //D0 - Reset
|
||||||
extern void dcode_1(); //D1 - Clear EEPROM
|
extern void dcode_1(); //D1 - Clear EEPROM
|
||||||
extern void dcode_2(); //D2 - Read/Write RAM
|
extern void dcode_2(); //D2 - Read/Write RAM
|
||||||
|
|
|
@ -1162,6 +1162,7 @@ void setup()
|
||||||
|
|
||||||
}
|
}
|
||||||
KEEPALIVE_STATE(NOT_BUSY);
|
KEEPALIVE_STATE(NOT_BUSY);
|
||||||
|
wdt_enable(WDTO_4S);
|
||||||
}
|
}
|
||||||
|
|
||||||
void trace();
|
void trace();
|
||||||
|
@ -5931,6 +5932,8 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
|
||||||
{
|
{
|
||||||
switch((int)code_value())
|
switch((int)code_value())
|
||||||
{
|
{
|
||||||
|
case -1: // D-1 - Endless loop
|
||||||
|
dcode__1(); break;
|
||||||
case 0: // D0 - Reset
|
case 0: // D0 - Reset
|
||||||
dcode_0(); break;
|
dcode_0(); break;
|
||||||
case 1: // D1 - Clear EEPROM
|
case 1: // D1 - Clear EEPROM
|
||||||
|
|
15733
Firmware/builds/1_75mm_MK3-EINY04-E3Dv6full/Firmware.ino.rambo_b111.hex
Normal file
15733
Firmware/builds/1_75mm_MK3-EINY04-E3Dv6full/Firmware.ino.rambo_b111.hex
Normal file
File diff suppressed because it is too large
Load diff
|
@ -5,14 +5,16 @@
|
||||||
#include "fsensor.h"
|
#include "fsensor.h"
|
||||||
#include "pat9125.h"
|
#include "pat9125.h"
|
||||||
#include "planner.h"
|
#include "planner.h"
|
||||||
|
#include "fastio.h"
|
||||||
|
|
||||||
//#include "LiquidCrystal.h"
|
//#include "LiquidCrystal.h"
|
||||||
//extern LiquidCrystal lcd;
|
//extern LiquidCrystal lcd;
|
||||||
|
|
||||||
|
|
||||||
#define FSENSOR_ERR_MAX 5 //filament sensor max error count
|
#define FSENSOR_ERR_MAX 5 //filament sensor max error count
|
||||||
#define FSENSOR_INT_PIN 63 //filament sensor interrupt pin
|
#define FSENSOR_INT_PIN 63 //filament sensor interrupt pin PK1
|
||||||
#define FSENSOR_CHUNK_LEN 560 //filament sensor chunk length in steps
|
#define FSENSOR_INT_PIN_MSK 0x02 //filament sensor interrupt pin mask (bit1)
|
||||||
|
#define FSENSOR_CHUNK_LEN 560 //filament sensor chunk length in steps
|
||||||
|
|
||||||
extern void stop_and_save_print_to_ram(float z_move, float e_move);
|
extern void stop_and_save_print_to_ram(float z_move, float e_move);
|
||||||
extern void restore_print_from_ram_and_continue(float e_move);
|
extern void restore_print_from_ram_and_continue(float e_move);
|
||||||
|
@ -28,14 +30,15 @@ void fsensor_restore_print_and_continue()
|
||||||
restore_print_from_ram_and_continue(0); //XYZ = orig, E - no change
|
restore_print_from_ram_and_continue(0); //XYZ = orig, E - no change
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t fsensor_int_pin = FSENSOR_INT_PIN;
|
//uint8_t fsensor_int_pin = FSENSOR_INT_PIN;
|
||||||
|
uint8_t fsensor_int_pin_old = 0;
|
||||||
int16_t fsensor_chunk_len = FSENSOR_CHUNK_LEN;
|
int16_t fsensor_chunk_len = FSENSOR_CHUNK_LEN;
|
||||||
bool fsensor_enabled = true;
|
bool fsensor_enabled = true;
|
||||||
//bool fsensor_ignore_error = true;
|
//bool fsensor_ignore_error = true;
|
||||||
bool fsensor_M600 = false;
|
bool fsensor_M600 = false;
|
||||||
uint8_t fsensor_err_cnt = 0;
|
uint8_t fsensor_err_cnt = 0;
|
||||||
int16_t fsensor_st_cnt = 0;
|
int16_t fsensor_st_cnt = 0;
|
||||||
uint8_t fsensor_log = 0;
|
uint8_t fsensor_log = 1;
|
||||||
|
|
||||||
|
|
||||||
void fsensor_enable()
|
void fsensor_enable()
|
||||||
|
@ -66,23 +69,30 @@ void pciSetup(byte pin)
|
||||||
|
|
||||||
void fsensor_setup_interrupt()
|
void fsensor_setup_interrupt()
|
||||||
{
|
{
|
||||||
uint8_t fsensor_int_pin = 63;
|
// uint8_t fsensor_int_pin = FSENSOR_INT_PIN;
|
||||||
|
// uint8_t fsensor_int_pcmsk = digitalPinToPCMSKbit(pin);
|
||||||
|
// uint8_t fsensor_int_pcicr = digitalPinToPCICRbit(pin);
|
||||||
|
|
||||||
pinMode(fsensor_int_pin, OUTPUT);
|
pinMode(FSENSOR_INT_PIN, OUTPUT);
|
||||||
digitalWrite(fsensor_int_pin, HIGH);
|
digitalWrite(FSENSOR_INT_PIN, LOW);
|
||||||
|
fsensor_int_pin_old = 0;
|
||||||
|
|
||||||
pciSetup(fsensor_int_pin);
|
pciSetup(FSENSOR_INT_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
ISR(PCINT2_vect)
|
ISR(PCINT2_vect)
|
||||||
{
|
{
|
||||||
// return;
|
// return;
|
||||||
|
if (!((fsensor_int_pin_old ^ PINK) & FSENSOR_INT_PIN_MSK)) return;
|
||||||
|
// puts("PCINT2\n");
|
||||||
|
// return;
|
||||||
|
|
||||||
int st_cnt = fsensor_st_cnt;
|
int st_cnt = fsensor_st_cnt;
|
||||||
fsensor_st_cnt = 0;
|
fsensor_st_cnt = 0;
|
||||||
sei();
|
sei();
|
||||||
*digitalPinToPCMSK(fsensor_int_pin) &= ~bit(digitalPinToPCMSKbit(fsensor_int_pin));
|
/* *digitalPinToPCMSK(fsensor_int_pin) &= ~bit(digitalPinToPCMSKbit(fsensor_int_pin));
|
||||||
digitalWrite(fsensor_int_pin, HIGH);
|
digitalWrite(fsensor_int_pin, HIGH);
|
||||||
*digitalPinToPCMSK(fsensor_int_pin) |= bit(digitalPinToPCMSKbit(fsensor_int_pin));
|
*digitalPinToPCMSK(fsensor_int_pin) |= bit(digitalPinToPCMSKbit(fsensor_int_pin));*/
|
||||||
pat9125_update_y();
|
pat9125_update_y();
|
||||||
if (st_cnt != 0)
|
if (st_cnt != 0)
|
||||||
{
|
{
|
||||||
|
@ -138,10 +148,14 @@ ISR(PCINT2_vect)
|
||||||
void fsensor_st_block_begin(block_t* bl)
|
void fsensor_st_block_begin(block_t* bl)
|
||||||
{
|
{
|
||||||
if (!fsensor_enabled) return;
|
if (!fsensor_enabled) return;
|
||||||
if ((fsensor_st_cnt > 0) && (bl->direction_bits & 0x8))
|
if (((fsensor_st_cnt > 0) && (bl->direction_bits & 0x8)) ||
|
||||||
digitalWrite(fsensor_int_pin, LOW);
|
((fsensor_st_cnt < 0) && !(bl->direction_bits & 0x8)))
|
||||||
if ((fsensor_st_cnt < 0) && !(bl->direction_bits & 0x8))
|
{
|
||||||
digitalWrite(fsensor_int_pin, LOW);
|
if (_READ(63)) _WRITE(63, LOW);
|
||||||
|
else _WRITE(63, HIGH);
|
||||||
|
}
|
||||||
|
// PINK |= FSENSOR_INT_PIN_MSK; //toggle pin
|
||||||
|
// _WRITE(fsensor_int_pin, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fsensor_st_block_chunk(block_t* bl, int cnt)
|
void fsensor_st_block_chunk(block_t* bl, int cnt)
|
||||||
|
@ -149,7 +163,12 @@ void fsensor_st_block_chunk(block_t* bl, int cnt)
|
||||||
if (!fsensor_enabled) return;
|
if (!fsensor_enabled) return;
|
||||||
fsensor_st_cnt += (bl->direction_bits & 0x8)?-cnt:cnt;
|
fsensor_st_cnt += (bl->direction_bits & 0x8)?-cnt:cnt;
|
||||||
if ((fsensor_st_cnt >= fsensor_chunk_len) || (fsensor_st_cnt <= -fsensor_chunk_len))
|
if ((fsensor_st_cnt >= fsensor_chunk_len) || (fsensor_st_cnt <= -fsensor_chunk_len))
|
||||||
digitalWrite(fsensor_int_pin, LOW);
|
{
|
||||||
|
if (_READ(63)) _WRITE(63, LOW);
|
||||||
|
else _WRITE(63, HIGH);
|
||||||
|
}
|
||||||
|
// PINK |= FSENSOR_INT_PIN_MSK; //toggle pin
|
||||||
|
// _WRITE(fsensor_int_pin, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fsensor_update()
|
void fsensor_update()
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
|
|
||||||
#include "Sd2PinMap.h"
|
#include "Sd2PinMap.h"
|
||||||
|
|
||||||
|
#include <avr/wdt.h>
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//=============================public variables============================
|
//=============================public variables============================
|
||||||
|
@ -573,6 +575,8 @@ void checkExtruderAutoFans()
|
||||||
|
|
||||||
void manage_heater()
|
void manage_heater()
|
||||||
{
|
{
|
||||||
|
wdt_reset();
|
||||||
|
|
||||||
float pid_input;
|
float pid_input;
|
||||||
float pid_output;
|
float pid_output;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue