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

Fix some noises when using mk25 (12v) #81

Open
wants to merge 10 commits 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
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
dist: trusty
before_install:
- sudo apt-get install -y ninja-build
- sudo apt-get install -y srecord
script:
- git fetch --unshallow || if [ $? -eq 128 ]; then true; else false; fi
- git rev-list --count HEAD
- bash -x test.sh
- bash -x build.sh
- wget https://github.com/prusa3d/caterina/releases/download/V4/Caterina-prusa_mm_control.hex
- srec_cat ../MM-control-01-build/MM-control-01.hex.tmp -Intel Caterina-prusa_mm_control.hex -Intel -Output MM-control-01_with_bootloader.hex -Intel
deploy:
provider: releases
api_key: $ACCESS_TOKEN
file: ../MM-control-01-build/MM-control-01.hex
file:
- ../MM-control-01-build/MM-control-01.hex
- MM-control-01_with_bootloader.hex
skip_cleanup: true
on:
tags: true
23 changes: 17 additions & 6 deletions MM-control-01/MM-control-01.vcxproj

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions MM-control-01/MM-control-01.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@
<ClInclude Include="__vm\.MM-Control.vsarduino.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="dirty.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="permanent_storage.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="timeout.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="version.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stepper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pins.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="abtn3.c">
Expand All @@ -80,9 +98,6 @@
<ClCompile Include="shr16.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="spi.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="tmc2130.c">
<Filter>Source Files</Filter>
</ClCompile>
Expand All @@ -98,5 +113,11 @@
<ClCompile Include="Buttons.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="permanent_storage.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stepper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
8 changes: 8 additions & 0 deletions MM-control-01/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,14 @@ void process_commands(FILE* inout)
state = S::Wait;
}
}
else if (sscanf_P(line, PSTR("K%d"), &value) > 0)
{
if ((value >= 0) && (value < EXTRUDERS)) //! K<nr.> cut filament
{
mmctl_cut_filament(value);
fprintf_P(inout, PSTR("ok\n"));
}
}
}
else
{ //nothing received
Expand Down
45 changes: 41 additions & 4 deletions MM-control-01/mmctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
#include "config.h"

int active_extruder = 0;
int previous_extruder = -1;
bool isFilamentLoaded = false;

static const int eject_steps = 2500;
static const int cut_steps_pre = 700;
static const int cut_steps_post = 150;

bool feed_filament()
void feed_filament()
{
bool _feed = true;
bool _loaded = false;
Expand Down Expand Up @@ -64,7 +65,6 @@ bool feed_filament()
tmc2130_disable_axis(AX_PUL, tmc2130_mode);
motion_disengage_idler();
shr16_set_led(1 << 2 * (4 - active_extruder));
return true;
}

//! @brief Change filament
Expand Down Expand Up @@ -116,6 +116,42 @@ void select_extruder(int new_extruder)
shr16_set_led(0x000);
shr16_set_led(1 << 2 * (4 - active_extruder));
}
//! @brief cut filament
//! @par filament filament 0 to 4
void mmctl_cut_filament(uint8_t filament)
{
active_extruder = filament;

if (isFilamentLoaded) unload_filament_withSensor();

feed_filament();
tmc2130_init_axis(AX_PUL, tmc2130_mode);

motion_set_idler_selector(filament, filament + 1);

motion_engage_idler();
set_pulley_dir_push();

for (int steps = 0; steps < cut_steps_pre; ++steps)
{
do_pulley_step();
steps++;
delayMicroseconds(1500);
}
motion_set_idler_selector(filament, 0);
set_pulley_dir_pull();

for (int steps = 0; steps < cut_steps_post; ++steps)
{
do_pulley_step();
steps++;
delayMicroseconds(1500);
}
motion_set_idler_selector(filament, 5);
motion_set_idler_selector(filament, 0);
motion_set_idler_selector(filament, filament);
feed_filament();
}

//! @brief eject filament
//! Move selector sideways and push filament forward little bit, so user can catch it,
Expand All @@ -124,6 +160,7 @@ void select_extruder(int new_extruder)
//! If we are want to eject fil 0-2, move selector to position 4 (right),
//! if we want to eject filament 3 - 4, move selector to position 0 (left)
//! maybe we can also move selector to service position in the future?
//! @par filament filament 0 to 4
void eject_filament(uint8_t filament)
{
active_extruder = filament;
Expand Down Expand Up @@ -502,7 +539,7 @@ void unload_filament_withSensor()

} while (!_continue);

shr16_set_led(1 << 2 * (4 - previous_extruder));
shr16_set_led(1 << 2 * (4 - active_extruder));
motion_engage_idler();
}
else
Expand Down
4 changes: 2 additions & 2 deletions MM-control-01/mmctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
#include <inttypes.h>

extern int active_extruder;
extern int previous_extruder;
extern bool isFilamentLoaded;

void switch_extruder_withSensor(int new_extruder);
void select_extruder(int new_extruder);
bool feed_filament();
void feed_filament();
void load_filament_withSensor();
void load_filament_inPrinter();
void unload_filament_withSensor();
void eject_filament(uint8_t filament);
void recover_after_eject();
void mmctl_cut_filament(uint8_t filament);
bool mmctl_IsOk();

#endif //_MMCTL_H
4 changes: 2 additions & 2 deletions MM-control-01/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static void unload_to_finda()
if (_unloadSteps < _first_point && _speed < 2500) _speed = _speed + 2;
if (_unloadSteps < _second_point && _unloadSteps > 5000)
{
if (_speed > 550) _speed = _speed - 1;
if (_speed > 750) _speed = _speed - 1;
if (_speed > 250 && (NORMAL_MODE == tmc2130_mode)) _speed = _speed - 1;
}

Expand Down Expand Up @@ -163,7 +163,7 @@ void motion_feed_to_bondtech()
{
if (_speed > 2600) _speed = _speed - 4;
if (_speed > 1300) _speed = _speed - 2;
if (_speed > 650) _speed = _speed - 1;
if (_speed > 750) _speed = _speed - 1;
if (_speed > 350 && (NORMAL_MODE == tmc2130_mode) && s_has_door_sensor) _speed = _speed - 1;
}
if (i > (steps - 800) && _speed < 2600) _speed = _speed + 10;
Expand Down
2 changes: 1 addition & 1 deletion MM-control-01/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef VERSION_H_
#define VERSION_H_

static const uint16_t fw_version = 105; //!< example: 103 means version 1.0.3
static const uint16_t fw_version = 106; //!< example: 103 means version 1.0.3
static const uint16_t fw_buildnr = ${GIT_PARENT_COMMITS}; //!< number of commits preceeding current HEAD
#define FW_HASH "${GIT_COMMIT_HASH}"

Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if [ ! -f "MM-build-env-Linux64-$BUILD_ENV.zip" ]; then
fi

if [ ! -d "../../MM-build-env-$BUILD_ENV" ]; then
unzip MM-build-env-Linux64-$BUILD_ENV.zip -d ../../MM-build-env-$BUILD_ENV || exit 4
unzip -q MM-build-env-Linux64-$BUILD_ENV.zip -d ../../MM-build-env-$BUILD_ENV || exit 4
fi

cd ../../MM-build-env-$BUILD_ENV || exit 5
Expand Down