Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added optional arguments to the F command giving load/unload speed #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion MM-control-01/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ void process_commands(FILE* inout)
}
int value = 0;
int value0 = 0;
int value1 = 0;
int value2 = 0;
int nr; // number of matched items

if ((count > 0) && (c == 0))
{
Expand Down Expand Up @@ -530,12 +533,24 @@ void process_commands(FILE* inout)
fprintf_P(inout, PSTR("%dok\n"), DriveError::get());
}
//! F<nr.> \<type\> filament type. <nr.> filament number, \<type\> 0, 1 or 2. Does nothing.
else if (sscanf_P(line, PSTR("F%d %d"), &value, &value0) > 0)
else if ((nr = sscanf_P(line, PSTR("F%d %d %d %d"),
&value, &value0,
&value1, &value2)) > 0)
{
if (((value >= 0) && (value < EXTRUDERS)) &&
((value0 >= 0) && (value0 <= 2)))
{
filament_type[value] = value0;
if (nr == 4)
{
filament_load_speed[value] = value1 / 256.0;
filament_unload_speed[value] = value2 / 256.0;
}
else
{
filament_load_speed[value] = 1.0;
filament_unload_speed[value] = 1.0;
}
fprintf_P(inout, PSTR("ok\n"));
}
}
Expand Down
19 changes: 13 additions & 6 deletions MM-control-01/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "config.h"
#include "tmc2130.h"
#include "shr16.h"
#include "mmctl.h"

static uint8_t s_idler = 0;
static uint8_t s_selector = 0;
Expand Down Expand Up @@ -115,6 +116,8 @@ void motion_disengage_idler()
static void unload_to_finda()
{
int delay = 2000; //microstep period in microseconds
int min_delay_stealth = round (550 / filament_unload_speed[active_extruder]);
int min_delay_normal = round (330 / filament_unload_speed[active_extruder]);
const int _first_point = 1800;

uint8_t _endstop_hit = 0;
Expand All @@ -133,8 +136,8 @@ static void unload_to_finda()
if (_unloadSteps < _first_point && delay < 2500) delay += 2;
if (_unloadSteps < _second_point && _unloadSteps > 5000)
{
if (delay > 550) delay -= 1;
if (delay > 330 && (NORMAL_MODE == tmc2130_mode)) delay -= 1;
if (delay > min_delay_stealth) delay -= 1;
if (delay > min_delay_normal && (NORMAL_MODE == tmc2130_mode)) delay -= 1;
}

delayMicroseconds(delay);
Expand All @@ -153,6 +156,8 @@ void motion_feed_to_bondtech()
{
set_pulley_dir_push();
unsigned long delay = 4500;
int min_delay_stealth = round (650 / filament_load_speed[active_extruder]);
int min_delay_normal = round (350 / filament_load_speed[active_extruder]);;

for (uint16_t i = 0; i < steps; i++)
{
Expand All @@ -161,10 +166,12 @@ void motion_feed_to_bondtech()

if (i < 4000)
{
if (stepPeriod > 2600) stepPeriod -= 4;
if (stepPeriod > 1300) stepPeriod -= 2;
if (stepPeriod > 650) stepPeriod -= 1;
if (stepPeriod > 350 && (NORMAL_MODE == tmc2130_mode) && s_has_door_sensor) stepPeriod -= 1;
if (min_delay_stealth < 2600 && stepPeriod > 2600)
stepPeriod -= 4;
if (min_delay_stealth < 1300 && stepPeriod > 1300)
stepPeriod -= 2;
if (stepPeriod > min_delay_stealth) stepPeriod -= 1;
if (stepPeriod > min_delay_normal && (NORMAL_MODE == tmc2130_mode) && s_has_door_sensor) stepPeriod -= 1;
}
if (i > (steps - 800) && stepPeriod < 2600) stepPeriod += 10;
if ('A' == getc(uart_com))
Expand Down
2 changes: 2 additions & 0 deletions MM-control-01/stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "tmc2130.h"

int8_t filament_type[EXTRUDERS] = {-1, -1, -1, -1, -1};
float filament_load_speed[EXTRUDERS] = {1.0, 1.0, 1.0, 1.0, 1.0};
float filament_unload_speed[EXTRUDERS] = {1.0, 1.0, 1.0, 1.0, 1.0};
static bool isIdlerParked = false;

static const int selector_steps_after_homing = -3700;
Expand Down
2 changes: 2 additions & 0 deletions MM-control-01/stepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <inttypes.h>

extern int8_t filament_type[EXTRUDERS];
extern float filament_load_speed[EXTRUDERS];
extern float filament_unload_speed[EXTRUDERS];

void home();
bool home_idler();
Expand Down