Fsensor synchronization and triggering improved

Watchdog implemented (4s interval, triggered from manage_heater)
Stallguard sensitivity for XY decreased by 1
Extruder current adjusted to 5.5kg force
Build number = 111
This commit is contained in:
Robert Pelnar 2017-11-24 21:53:35 +01:00
parent 213ee43cc9
commit f2e9bdef24
8 changed files with 15790 additions and 21 deletions

View File

@ -9,7 +9,7 @@
// Firmware version
#define FW_version "3.0.12-RC2"
#define FW_build 110
#define FW_build 111
//#define FW_build --BUILD-NUMBER--
#define FW_version_build FW_version " b" STR(FW_build)

View File

@ -105,6 +105,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
//#define DEBUG_BLINK_ACTIVE
#endif
/*------------------------------------
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_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_THRS_X 2 // stallguard sensitivity for X axis
#define TMC2130_SG_THRS_Y 3 // stallguard sensitivity for Y axis
#define TMC2130_SG_THRS_X 3 // stallguard sensitivity for X 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_E 3 // stallguard sensitivity for E axis
#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)
#define TMC2130_CURRENTS_H {13, 20, 20, 40} // default holding currents for all axes
#define TMC2130_CURRENTS_R {13, 20, 20, 40} // default running 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, 35} // default running currents for all axes
//#define TMC2130_DEBUG
//#define TMC2130_DEBUG_WR

View File

@ -97,6 +97,13 @@ int parse_hex(char* hex, uint8_t* data, int count)
return parsed;
}
void dcode__1()
{
printf("D-1 - Endless loop\n");
cli();
while (1);
}
void dcode_0()
{
if (*(strchr_pointer + 1) == 0) return;

View File

@ -1,6 +1,8 @@
#ifndef 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_1(); //D1 - Clear EEPROM
extern void dcode_2(); //D2 - Read/Write RAM

View File

@ -1162,6 +1162,7 @@ void setup()
}
KEEPALIVE_STATE(NOT_BUSY);
wdt_enable(WDTO_4S);
}
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())
{
case -1: // D-1 - Endless loop
dcode__1(); break;
case 0: // D0 - Reset
dcode_0(); break;
case 1: // D1 - Clear EEPROM

File diff suppressed because it is too large Load Diff

View File

@ -5,13 +5,15 @@
#include "fsensor.h"
#include "pat9125.h"
#include "planner.h"
#include "fastio.h"
//#include "LiquidCrystal.h"
//extern LiquidCrystal lcd;
#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_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);
@ -28,14 +30,15 @@ void fsensor_restore_print_and_continue()
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;
bool fsensor_enabled = true;
//bool fsensor_ignore_error = true;
bool fsensor_M600 = false;
uint8_t fsensor_err_cnt = 0;
int16_t fsensor_st_cnt = 0;
uint8_t fsensor_log = 0;
uint8_t fsensor_log = 1;
void fsensor_enable()
@ -66,23 +69,30 @@ void pciSetup(byte pin)
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);
digitalWrite(fsensor_int_pin, HIGH);
pinMode(FSENSOR_INT_PIN, OUTPUT);
digitalWrite(FSENSOR_INT_PIN, LOW);
fsensor_int_pin_old = 0;
pciSetup(fsensor_int_pin);
pciSetup(FSENSOR_INT_PIN);
}
ISR(PCINT2_vect)
{
// return;
if (!((fsensor_int_pin_old ^ PINK) & FSENSOR_INT_PIN_MSK)) return;
// puts("PCINT2\n");
// return;
int st_cnt = fsensor_st_cnt;
fsensor_st_cnt = 0;
sei();
*digitalPinToPCMSK(fsensor_int_pin) &= ~bit(digitalPinToPCMSKbit(fsensor_int_pin));
/* *digitalPinToPCMSK(fsensor_int_pin) &= ~bit(digitalPinToPCMSKbit(fsensor_int_pin));
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();
if (st_cnt != 0)
{
@ -138,10 +148,14 @@ ISR(PCINT2_vect)
void fsensor_st_block_begin(block_t* bl)
{
if (!fsensor_enabled) return;
if ((fsensor_st_cnt > 0) && (bl->direction_bits & 0x8))
digitalWrite(fsensor_int_pin, LOW);
if ((fsensor_st_cnt < 0) && !(bl->direction_bits & 0x8))
digitalWrite(fsensor_int_pin, LOW);
if (((fsensor_st_cnt > 0) && (bl->direction_bits & 0x8)) ||
((fsensor_st_cnt < 0) && !(bl->direction_bits & 0x8)))
{
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)
@ -149,7 +163,12 @@ void fsensor_st_block_chunk(block_t* bl, int cnt)
if (!fsensor_enabled) return;
fsensor_st_cnt += (bl->direction_bits & 0x8)?-cnt:cnt;
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()

View File

@ -37,6 +37,8 @@
#include "Sd2PinMap.h"
#include <avr/wdt.h>
//===========================================================================
//=============================public variables============================
@ -573,6 +575,8 @@ void checkExtruderAutoFans()
void manage_heater()
{
wdt_reset();
float pid_input;
float pid_output;