Skip to content

Commit

Permalink
Fix MMU2 qurks (#363)
Browse files Browse the repository at this point in the history
* Fix idler travel, add secondary board debug hook
* Fix bug with inverted motor direction init
  • Loading branch information
vintagepc authored Jun 13, 2022
1 parent a4215fa commit 41b23ee
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 5 deletions.
8 changes: 8 additions & 0 deletions MK404.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ int main(int argc, char *argv[])
ValuesConstraint<string> vcSizes(vstrSizes);
ValueArg<string> argImgSize("","image-size","Specify a size for a new SD image. You must specify an image with --sdimage",false,"256M",&vcSizes,cmd);
SwitchArg argGDB("","gdb","Enable SimAVR's GDB support",cmd);
SwitchArg argGDB2("","gdb2","Enable SimAVR's GDB support on the MMU/secondary board",cmd);
std::vector<string> vstrGfx = {"none","lite","fancy", "bear"};
ValuesConstraint<string> vcGfxAllowed(vstrGfx);
ValueArg<string> argGfx("g","graphics","Whether to enable fancy (advanced) or lite (minimal advanced) visuals. If not specified, only the basic 2D visuals are shown.",false,"lite",&vcGfxAllowed, cmd);
Expand Down Expand Up @@ -403,6 +404,12 @@ int main(int argc, char *argv[])
return 0; // pragma: LCOV_EXCL_LINE - returns don't always get correctly marked as covered due to optimization
}

if (argGDB2.isSet() && argGDB.isSet())
{
std::cerr <<"Cannot enable both GDB connections at the same time!\n"; // pragma: LCOV_EXCL_LINE - Silly to test.
exit(1); // pragma: LCOV_EXCL_LINE
}

// Handle the convenience synonyms:
// Longer term it'd be neat to have a synonym handler in TCLAP....
bool bArgHacks = argNoHacks.isSet() || argKlipper.isSet() || argMarlin.isSet();
Expand Down Expand Up @@ -435,6 +442,7 @@ int main(int argc, char *argv[])
Config::Get().SetExtrusionMode(PrintVisualType::GetNameToType().at(argExtrusion.getValue()));
Config::Get().SetColourE(argColourE.isSet());
Config::Get().SetFW2(argFW2.getValue());
Config::Get().SetGDB2(argGDB2.isSet());

TelemetryHost::GetHost().SetCategories(argVCD.getValue());

Expand Down
9 changes: 5 additions & 4 deletions parts/boards/MM_Control_01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ namespace Boards
m_Extr.SetSimple(true);


cfg.uiFullStepsPerMM = 400*16;
cfg.iMaxMM = 70;
cfg.uiFullStepsPerMM = 200*32;
cfg.iMaxMM = 76;
cfg.fStartPos = 10;
cfg.bInverted = true;
cfg.bHasNoEndStops = false;
m_Sel.SetConfig(cfg);
Expand All @@ -81,8 +82,8 @@ namespace Boards
m_Sel.ConnectFrom(m_shift.GetIRQ(HC595::BIT2), TMC2130::DIR_IN);
m_Sel.ConnectFrom(m_shift.GetIRQ(HC595::BIT3), TMC2130::ENABLE_IN);

cfg.uiFullStepsPerMM = 8*16;
cfg.iMaxMM = 200;
cfg.uiFullStepsPerMM = 9*16;
cfg.iMaxMM = 225;
m_Idl.SetConfig(cfg);
AddHardware(m_Idl);
TryConnect(I_TMC2130_CS,&m_Idl,TMC2130::SPI_CSEL);
Expand Down
2 changes: 1 addition & 1 deletion parts/components/MMU2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ MMU2::MMU2(bool bCreate):IKeyClient(),MM_Control_01()
SetBoardName("MMU2");
if (bCreate)
{
CreateBoard(Config::Get().GetFW2(),0, false, 100,"");
CreateBoard(Config::Get().GetFW2(),0, Config::Get().GetGDB2(), 100,"");
}
RegisterKeyHandler('F',"Toggle the FINDA");
RegisterKeyHandler('A', "Resumes full-auto MMU mode.");
Expand Down
1 change: 1 addition & 0 deletions parts/components/TMC2130.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ void TMC2130::SetConfig(TMC2130_cfg_t cfgIn)
m_iMaxPos = PosToStep(cfg.iMaxMM);
m_fCurPos = cfg.fStartPos;
m_fEnd = StepToPos(m_iMaxPos);
m_bDir = cfg.bInverted;
m_bConfigured = true;
}

Expand Down
Binary file modified scripts/tests/snaps/ext1/IPCMMU2_start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified scripts/tests/snaps/ext1/MK3MMU202.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified scripts/tests/snaps/ext1/MK3SMMU202.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified scripts/tests/snaps/ext1/MK3SMMU203.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified scripts/tests/snaps/ext1/MK3SMMU204.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified scripts/tests/snaps/ext1/MMU2_start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions utility/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class Config
inline void SetFW2(std::string strName){ m_strSecFW = std::move(strName);}
inline const std::string GetFW2(){ return m_strSecFW;}

// GDB on secondary board
inline void SetGDB2(bool bVal){ m_bGDB2 = bVal;}
inline const bool GetGDB2(){ return m_bGDB2;}

private:
unsigned int m_iExtrusion = false;
bool m_bColorExtrusion = false;
Expand All @@ -68,4 +72,5 @@ class Config
bool m_bDebugCore = false;
std::string m_strSecFW = "MM-control-01.hex";
EnabledType::Type_t m_SoftPWM = EnabledType::Type_t::NotSet;
bool m_bGDB2 = false;
};

0 comments on commit 41b23ee

Please sign in to comment.