Version 1.16beta3

Added stub for DueX5 support
Fixed bugs with homing and position reporting of U,V,W axes
This commit is contained in:
David Crocker 2016-10-21 11:33:55 +01:00
parent ef4f962afa
commit fe7f857b78
11 changed files with 121 additions and 59 deletions

View file

@ -26,11 +26,11 @@ Licence: GPL
// Firmware name is now defined in the Pins file
#ifndef VERSION
# define VERSION "1.16beta2"
# define VERSION "1.16beta3"
#endif
#ifndef DATE
# define DATE "2016-10-19"
# define DATE "2016-10-20"
#endif
#define AUTHORS "reprappro, dc42, zpl, t3p3, dnewman"

36
src/DuetNG/SX1509B.cpp Normal file
View file

@ -0,0 +1,36 @@
/*
* SX1509B.cpp
*
* Created on: 19 Oct 2016
* Author: David
*/
#include "SX1509B.h"
const uint8_t DueXnAddress = 0x3E; // address of the SX1509B on the DueX0/DueX2/DueX5
// Initialise the device and identify which expansion board (if any) is attached
ExpansionBoardType SX1509B::Init()
{
Wire.begin(); // initialise TWI as master
Wire.beginTransmission(DueXnAddress); // start a block
// Return codes from Wire.endTransmission are:
// 0: success
// 1: data too long to fit in transmit buffer
// 2: received NACK on transmit of address
// 3: received NACK on transmit of data
// 4: other error
// We assume that any return code other than 0 means the device was not found.
if (Wire.endTransmission() != 0)
{
// No device found at that address, or a serious error
return ExpansionBoardType::none;
}
return ExpansionBoardType::none; //TODO
}
// End

27
src/DuetNG/SX1509B.h Normal file
View file

@ -0,0 +1,27 @@
/*
* SX1509B.h
*
* Created on: 19 Oct 2016
* Author: David
*/
#ifndef SRC_DUETNG_SX1509B_H_
#define SRC_DUETNG_SX1509B_H_
#include "Wire.h"
enum class ExpansionBoardType : uint8_t
{
none,
DueX0,
DueX2,
DueX5
};
class SX1509B
{
public:
ExpansionBoardType Init(); // Initialise the device and identify which expansion board (if any) is attached
};
#endif /* SRC_DUETNG_SX1509B_H_ */

View file

@ -3244,7 +3244,7 @@ bool GCodes::HandleMcode(GCodeBuffer* gb, StringRef& reply)
reply.copy("Steps/mm: ");
for (size_t axis = 0; axis < numAxes; ++axis)
{
reply.catf("%c: %.3f, ", platform->DriveStepsPerUnit(axis));
reply.catf("%c: %.3f, ", axisLetters[axis], platform->DriveStepsPerUnit(axis));
}
reply.catf("E: ");
for (size_t drive = numAxes; drive < DRIVES; drive++)
@ -3846,8 +3846,9 @@ bool GCodes::HandleMcode(GCodeBuffer* gb, StringRef& reply)
reply.printf("Accelerations: ");
for (size_t axis = 0; axis < numAxes; ++axis)
{
reply.catf("%c: %.1f, ", platform->Acceleration(axis) / distanceScale);
reply.catf("%c: %.1f, ", axisLetters[axis], platform->Acceleration(axis) / distanceScale);
}
reply.cat("E: ");
for (size_t drive = numAxes; drive < DRIVES; drive++)
{
reply.catf("%.1f", platform->Acceleration(drive) / distanceScale);
@ -3864,7 +3865,7 @@ bool GCodes::HandleMcode(GCodeBuffer* gb, StringRef& reply)
case 203: // Set/print maximum feedrates
{
bool seen = false;
for (size_t axis = 0; axis < numAxes; axis++)
for (size_t axis = 0; axis < numAxes; ++axis)
{
if (gb->Seen(axisLetters[axis]))
{
@ -3888,9 +3889,9 @@ bool GCodes::HandleMcode(GCodeBuffer* gb, StringRef& reply)
if (!seen)
{
reply.copy("Maximum feedrates: ");
for (size_t axis = 0; axis < numAxes; axis++)
for (size_t axis = 0; axis < numAxes; ++axis)
{
reply.catf("%c: %.1f, ", platform->MaxFeedrate(axis) / (distanceScale * secondsToMinutes));
reply.catf("%c: %.1f, ", axisLetters[axis], platform->MaxFeedrate(axis) / (distanceScale * secondsToMinutes));
}
reply.cat("E: ");
for (size_t drive = numAxes; drive < DRIVES; drive++)
@ -4697,7 +4698,7 @@ bool GCodes::HandleMcode(GCodeBuffer* gb, StringRef& reply)
reply.copy("Maximum jerk rates: ");
for (size_t axis = 0; axis < numAxes; ++axis)
{
reply.catf("%c: %.1f, ", platform->ConfiguredInstantDv(axis) / (distanceScale * secondsToMinutes));
reply.catf("%c: %.1f, ", axisLetters[axis], platform->ConfiguredInstantDv(axis) / (distanceScale * secondsToMinutes));
}
reply.cat("E:");
char sep = ' ';
@ -5170,6 +5171,10 @@ bool GCodes::HandleMcode(GCodeBuffer* gb, StringRef& reply)
break;
case 584: // Set axis/extruder to stepper driver(s) mapping
if (!AllMovesAreFinishedAndMoveBufferIsLoaded()) // we also rely on this to retrieve the current motor positions to moveBuffer
{
return false;
}
{
bool seen = false, badDrive = false;
for (size_t drive = 0; drive < MAX_AXES; ++drive)
@ -5204,9 +5209,10 @@ bool GCodes::HandleMcode(GCodeBuffer* gb, StringRef& reply)
{
while (numAxes <= drive)
{
moveBuffer.coords[numAxes] = 0.0; // user has defined a new axis
moveBuffer.coords[numAxes] = 0.0; // user has defined a new axis, so set its position
++numAxes;
}
SetPositions(moveBuffer.coords); // tell the Move system where any new axes are
platform->SetAxisDriversConfig(drive, config);
}
}

View file

@ -633,7 +633,8 @@ bool DDA::FetchEndPosition(volatile int32_t ep[DRIVES], volatile float endCoords
}
if (endCoordinatesValid)
{
for (size_t axis = 0; axis < MAX_AXES; ++axis)
const size_t numAxes = reprap.GetGCodes()->GetNumAxes();
for (size_t axis = 0; axis < numAxes; ++axis)
{
endCoords[axis] = endCoordinates[axis];
}
@ -654,7 +655,7 @@ void DDA::SetPositions(const float move[DRIVES], size_t numDrives)
// Get a Cartesian end coordinate from this move
float DDA::GetEndCoordinate(size_t drive, bool disableDeltaMapping)
pre(disableDeltaMapping || drive < AXES)
pre(disableDeltaMapping || drive < MAX_AXES)
{
if (disableDeltaMapping)
{

View file

@ -527,8 +527,8 @@ void Move::MachineToEndPoint(const int32_t motorPos[], float machinePos[], size_
}
}
// Convert the extruders
for (size_t drive = reprap.GetGCodes()->GetNumAxes(); drive < numDrives; ++drive)
// Convert any additional axes and the extruders
for (size_t drive = MIN_AXES; drive < numDrives; ++drive)
{
machinePos[drive] = motorPos[drive]/stepsPerUnit[drive];
}
@ -1220,18 +1220,7 @@ void Move::HitLowStop(size_t axis, DDA* hitDDA)
{
if (axis < reprap.GetGCodes()->GetNumAxes() && !IsDeltaMode()) // should always be true
{
float hitPoint;
if (axis == Z_AXIS)
{
// Special case of doing a G1 S1 Z move on a Cartesian printer. This is not how we normally home the Z axis, we use G30 instead.
// But I think it used to work, so let's not break it.
hitPoint = reprap.GetPlatform()->ZProbeStopHeight();
}
else
{
hitPoint = reprap.GetPlatform()->AxisMinimum(axis);
}
JustHomed(axis, hitPoint, hitDDA);
JustHomed(axis, reprap.GetPlatform()->AxisMinimum(axis), hitDDA);
}
}
@ -1323,7 +1312,7 @@ void Move::GetCurrentUserPosition(float m[DRIVES], uint8_t moveType) const
// Interrupts are assumed enabled on entry, so do not call this from an ISR
void Move::LiveCoordinates(float m[DRIVES])
{
// The live coordinates and live endpoints are modified by the ISR, to be careful to get a self-consistent set of them
// The live coordinates and live endpoints are modified by the ISR, so be careful to get a self-consistent set of them
cpu_irq_disable();
if (liveCoordinatesValid)
{

View file

@ -26,8 +26,8 @@
#include "sam/drivers/hsmci/hsmci.h"
#include "sd_mmc.h"
#if defined(DUET_NG) && !defined(PROTOTYPE_1)
# include <TMC2660.h>
#if defined(DUET_NG)
# include "TMC2660.h"
#endif
#ifdef DUET_NG
@ -213,7 +213,7 @@ void Platform::Init()
fileStructureInitialised = true;
#if !defined(DUET_NG) || defined(PROTOTYPE_1)
#if !defined(DUET_NG)
mcpDuet.begin(); // only call begin once in the entire execution, this begins the I2C comms on that channel for all objects
mcpExpansion.setMCP4461Address(0x2E); // not required for mcpDuet, as this uses the default address
#endif
@ -237,7 +237,7 @@ void Platform::Init()
ARRAY_INIT(driveStepsPerUnit, DRIVE_STEPS_PER_UNIT);
ARRAY_INIT(instantDvs, INSTANT_DVS);
#if !defined(DUET_NG) || defined(PROTOTYPE_1)
#if !defined(DUET_NG)
ARRAY_INIT(potWipes, POT_WIPES);
senseResistor = SENSE_RESISTOR;
maxStepperDigipotVoltage = MAX_STEPPER_DIGIPOT_VOLTAGE;
@ -337,7 +337,24 @@ void Platform::Init()
slowDrivers = 0; // assume no drivers need extended step pulse timing
#ifdef DUET_NG
numTMC2660Drivers = 5; // until we have the DueX5 expansion board, assume that additional drivers are dumb enable/step/dir ones
// Test for presence of a DueX2 or DueX5 expansion board and work out how many TMC2660 drivers we have
ExpansionBoardType et = expansion.Init();
switch (et)
{
case ExpansionBoardType::DueX2:
numTMC2660Drivers = 7;
break;
case ExpansionBoardType::DueX5:
numTMC2660Drivers = 10;
break;
case ExpansionBoardType::none:
case ExpansionBoardType::DueX0:
default:
numTMC2660Drivers = 5; // assume that additional drivers are dumb enable/step/dir ones
break;
}
// Initialise TMC2660 drivers
driversPowered = false;
TMC2660::Init(ENABLE_PINS, numTMC2660Drivers);
#endif
@ -1781,7 +1798,7 @@ void Platform::EnableDriver(size_t driver)
driverState[driver] = DriverStatus::enabled;
UpdateMotorCurrent(driver); // the current may have been reduced by the idle timeout
#if defined(DUET_NG) && !defined(PROTOTYPE_1)
#if defined(DUET_NG)
if (driver < numTMC2660Drivers)
{
TMC2660::EnableDrive(driver, true);
@ -1790,7 +1807,7 @@ void Platform::EnableDriver(size_t driver)
{
#endif
digitalWrite(ENABLE_PINS[driver], enableValues[driver]);
#if defined(DUET_NG) && !defined(PROTOTYPE_1)
#if defined(DUET_NG)
}
#endif
}
@ -1801,7 +1818,7 @@ void Platform::DisableDriver(size_t driver)
{
if (driver < DRIVES)
{
#if defined(DUET_NG) && !defined(PROTOTYPE_1)
#if defined(DUET_NG)
if (driver < numTMC2660Drivers)
{
TMC2660::EnableDrive(driver, false);
@ -1810,7 +1827,7 @@ void Platform::DisableDriver(size_t driver)
{
#endif
digitalWrite(ENABLE_PINS[driver], !enableValues[driver]);
#if defined(DUET_NG) && !defined(PROTOTYPE_1)
#if defined(DUET_NG)
}
#endif
driverState[driver] = DriverStatus::disabled;
@ -1915,7 +1932,7 @@ void Platform::UpdateMotorCurrent(size_t driver)
current *= motorCurrentFraction[driver];
}
#if defined(DUET_NG) && !defined(PROTOTYPE_1)
#if defined(DUET_NG)
if (driver < numTMC2660Drivers)
{
TMC2660::SetCurrent(driver, current);
@ -1999,7 +2016,7 @@ bool Platform::SetDriverMicrostepping(size_t driver, int microsteps, int mode)
{
if (driver < DRIVES)
{
#if defined(DUET_NG) && !defined(PROTOTYPE_1)
#if defined(DUET_NG)
if (driver < numTMC2660Drivers)
{
return TMC2660::SetMicrostepping(driver, microsteps, mode);
@ -2010,7 +2027,7 @@ bool Platform::SetDriverMicrostepping(size_t driver, int microsteps, int mode)
// Other drivers only support x16 microstepping.
// We ignore the interpolation on/off parameter so that e.g. M350 I1 E16:128 won't give an error if E1 supports interpolation but E0 doesn't.
return microsteps == 16;
#if defined(DUET_NG) && !defined(PROTOTYPE_1)
#if defined(DUET_NG)
}
#endif
}
@ -2040,7 +2057,7 @@ bool Platform::SetMicrostepping(size_t drive, int microsteps, int mode)
// Get the microstepping for a driver
unsigned int Platform::GetDriverMicrostepping(size_t driver, bool& interpolation) const
{
#if defined(DUET_NG) && !defined(PROTOTYPE_1)
#if defined(DUET_NG)
if (driver < numTMC2660Drivers)
{
return TMC2660::GetMicrostepping(driver, interpolation);
@ -2537,11 +2554,7 @@ void Platform::SetBoardType(BoardType bt)
if (bt == BoardType::Auto)
{
#ifdef DUET_NG
# ifdef PROTOTYPE_1
board = BoardType::DuetWiFi_06;
# else
board = BoardType::DuetWiFi_10;
# endif
#elif defined(__RADDS__)
board = BoardType::RADDS_15;
#else
@ -2572,11 +2585,7 @@ const char* Platform::GetElectronicsString() const
switch (board)
{
#ifdef DUET_NG
# ifdef PROTOTYPE_1
case BoardType::DuetWiFi_06: return "Duet WiFi 0.6";
# else
case BoardType::DuetWiFi_10: return "Duet WiFi 1.0";
# endif
#elif defined(__RADDS__)
case BoardType::RADDS_15: return "RADDS 1.5";
#else
@ -2594,11 +2603,7 @@ const char* Platform::GetBoardString() const
switch (board)
{
#ifdef DUET_NG
# ifdef PROTOTYPE_1
case BoardType::DuetWiFi_06: return "duetwifi06";
# else
case BoardType::DuetWiFi_10: return "duetwifi10";
# endif
#elif defined(__RADDS__)
case BoardType::RADDS_15: return "radds15";
#else

View file

@ -50,7 +50,9 @@ Licence: GPL
#include "OutputMemory.h"
#include "Libraries/Fatfs/ff.h"
#if !defined(DUET_NG) || defined(PROTOTYPE_1)
#if defined(DUET_NG)
# include "SX1509B.h"
#else
# include "Libraries/MCP4461/MCP4461.h"
#endif
@ -186,11 +188,7 @@ enum class BoardType : uint8_t
{
Auto = 0,
#ifdef DUET_NG
# ifdef PROTOTYPE_1
DuetWiFi_06 = 1
# else
DuetWiFi_10 = 1
# endif
#elif defined(__RADDS__)
RADDS_15 = 1
#else
@ -757,11 +755,11 @@ private:
float idleCurrentFactor;
float maxAverageAcceleration;
// Digipots
#if defined(DUET_NG) && !defined(PROTOTYPE_1)
#if defined(DUET_NG)
SX1509B expansion; // I/O expander on DueXn board
size_t numTMC2660Drivers; // the number of TMC2660 drivers we have, the remaining are simple enable/step/dir drivers
#else
// Digipots
MCP4461 mcpDuet;
MCP4461 mcpExpansion;
Pin potWipes[8]; // we have only 8 digipots, on the Duet 0.8.5 we use the DAC for the 9th