Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2022-01-17 22:19:15 +0300
committerDavid Crocker <dcrocker@eschertech.com>2022-01-17 22:19:15 +0300
commita7f8d8aca37084c93803836f1dc627c3a274f36a (patch)
treee745410ab9e69e7147072c0fa08e748b574d9379 /src
parente92b3cd7e4f94fde394231ec82e2268de19e5831 (diff)
More work on MB6XD step generation
Also removed some obsolete Duet 085, RADDs and Alligator code
Diffstat (limited to 'src')
-rw-r--r--src/Config/Pins_Duet3_MB6XD.h9
-rw-r--r--src/Heating/Sensors/Thermistor.cpp8
-rw-r--r--src/ObjectModel/ObjectModel.cpp2
-rw-r--r--src/Platform/Platform.cpp138
-rw-r--r--src/Platform/Platform.h24
-rw-r--r--src/RepRapFirmware.h4
6 files changed, 86 insertions, 99 deletions
diff --git a/src/Config/Pins_Duet3_MB6XD.h b/src/Config/Pins_Duet3_MB6XD.h
index 11e9324d..730a26b7 100644
--- a/src/Config/Pins_Duet3_MB6XD.h
+++ b/src/Config/Pins_Duet3_MB6XD.h
@@ -3,10 +3,10 @@
#include <PinDescription.h>
-#define BOARD_SHORT_NAME "MB6HC"
-#define BOARD_NAME "Duet 3 MB6HC"
+#define BOARD_SHORT_NAME "MB6XD"
+#define BOARD_NAME "Duet 3 MB6XD"
#define DEFAULT_BOARD_TYPE BoardType::Auto
-#define FIRMWARE_NAME "RepRapFirmware for Duet 3 MB6HC"
+#define FIRMWARE_NAME "RepRapFirmware for Duet 3 MB6XD"
#define IAP_FIRMWARE_FILE "Duet3Firmware_" BOARD_SHORT_NAME ".bin"
#define IAP_UPDATE_FILE "Duet3_SDiap32_" BOARD_SHORT_NAME ".bin"
@@ -103,7 +103,8 @@ constexpr Pin DRIVER_ERR_PINS[NumDirectDrivers] = { PortDPin(29), PortCPin(17),
constexpr Pin StepGatePin = PortDPin(22);
constexpr GpioPinFunction StepGatePinFunction = GpioPinFunction::C; // TIOB11
-#define STEP_GATE_TC (TC3)
+#define STEP_GATE_TC (TC3) // TC11 is really TC3 channel 2
+#define STEP_GATE_TC_ID (ID_TC11) // ID for peripheral clock and interrupt
#define STEP_GATE_TC_CHAN (2)
// Thermistor/PT1000 inputs
diff --git a/src/Heating/Sensors/Thermistor.cpp b/src/Heating/Sensors/Thermistor.cpp
index caa0abd2..fbca1e12 100644
--- a/src/Heating/Sensors/Thermistor.cpp
+++ b/src/Heating/Sensors/Thermistor.cpp
@@ -77,10 +77,10 @@ bool Thermistor::ConfigureHParam(int hVal, const StringRef& reply) noexcept
if (valid)
{
int32_t vrefReading = reprap.GetPlatform().GetAdcFilter(VrefFilterIndex).GetSum();
-# ifdef DUET3
+# ifdef DUET3_MB6HC
// Duet 3 MB6HC board revisions 0.6 and 1.0 have the series resistor connected to VrefP, not VrefMon, so extrapolate the VrefMon reading to estimate VrefP.
// Version 1.01 and later boards have the series resistors connected to VrefMon.
- if (reprap.GetPlatform().GetBoardType() == BoardType::Duet3_v06_100)
+ if (reprap.GetPlatform().GetBoardType() == BoardType::Duet3_6HC_v06_100)
{
const int32_t vssaReading = reprap.GetPlatform().GetAdcFilter(VssaFilterIndex).GetSum();
vrefReading = vssaReading + lrintf((vrefReading - vssaReading) * (4715.0/4700.0));
@@ -367,10 +367,10 @@ void Thermistor::Poll() noexcept
const int32_t rawAveragedVssaReading = vssaFilter.GetSum()/(vssaFilter.NumAveraged() >> AdcOversampleBits);
const int32_t rawAveragedVrefReading = vrefFilter.GetSum()/(vrefFilter.NumAveraged() >> AdcOversampleBits);
const int32_t averagedVssaReading = rawAveragedVssaReading + (adcLowOffset * (1 << (AdcBits + AdcOversampleBits - 13)));
-# ifdef DUET3
+# ifdef DUET3_MB6HC
// Duet 3 MB6HC board revisions 0.6 and 1.0 have the series resistor connected to VrefP, not VrefMon, so extrapolate the VrefMon reading to estimate VrefP.
// Version 1.01 and later boards have the series resistors connected to VrefMon.
- const int32_t correctedVrefReading = (reprap.GetPlatform().GetBoardType() == BoardType::Duet3_v06_100)
+ const int32_t correctedVrefReading = (reprap.GetPlatform().GetBoardType() == BoardType::Duet3_6HC_v06_100)
? rawAveragedVssaReading + lrintf((rawAveragedVrefReading - rawAveragedVssaReading) * (4715.0/4700.0))
: rawAveragedVrefReading;
const int32_t averagedVrefReading = correctedVrefReading + (adcHighOffset * (1 << (AdcBits + AdcOversampleBits - 13)));
diff --git a/src/ObjectModel/ObjectModel.cpp b/src/ObjectModel/ObjectModel.cpp
index db00a77c..4d3f7ef5 100644
--- a/src/ObjectModel/ObjectModel.cpp
+++ b/src/ObjectModel/ObjectModel.cpp
@@ -1125,7 +1125,7 @@ decrease(strlen(idString)) // recursion variant
}
break;
-#ifdef DUET3
+#if defined(DUET3) || defined(DUET3MINI)
case TypeCode::CanExpansionBoardDetails:
if (*idString == 0)
{
diff --git a/src/Platform/Platform.cpp b/src/Platform/Platform.cpp
index c4877c96..0ae91ba1 100644
--- a/src/Platform/Platform.cpp
+++ b/src/Platform/Platform.cpp
@@ -49,6 +49,7 @@
# include <AnalogIn.h>
# include <DmacManager.h>
using LegacyAnalogIn::AdcBits;
+# include <pmc/pmc.h>
# if SAME70
static_assert(NumDmaChannelsUsed <= NumDmaChannelsSupported, "Need more DMA channels in CoreNG");
# endif
@@ -58,9 +59,6 @@ static_assert(NumDmaChannelsUsed <= NumDmaChannelsSupported, "Need more DMA chan
using AnalogIn::AdcBits; // for compatibility with CoreNG, which doesn't have the AnalogIn namespace
#elif defined(__LPC17xx__)
# include "LPC/BoardConfig.h"
-#else
-# include "sam/drivers/tc/tc.h"
-# include "sam/drivers/hsmci/hsmci.h"
#endif
#include <Libraries/sd_mmc/sd_mmc.h>
@@ -684,6 +682,16 @@ void Platform::Init() noexcept
#ifdef DUET3_MB6XD
driverErrPinsActiveLow = (numErrorHighDrivers >= NumDirectDrivers/2); // determine the error signal polarity by assuming most drivers are not in the error state
+
+ // Set up the step gate timer
+ pmc_enable_periph_clk(STEP_GATE_TC_ID);
+ STEP_GATE_TC->TC_CHANNEL[STEP_GATE_TC_CHAN].TC_CMR = TC_CMR_BSWTRG_SET // software trigger sets TIOB
+ | TC_CMR_BCPC_CLEAR // RC compare clears TIOB
+ | TC_CMR_WAVE // waveform mode
+ | TC_CMR_WAVSEL_UP // count up
+ | TC_CMR_CPCSTOP // counter clock is stopped when counter reaches RC
+ | TC_CMR_TCCLKS_TIMER_CLOCK2; // divide MCLK (150MHz) by 8 = 18.75MHz
+ SetPinFunction(StepGatePin, StepGatePinFunction);
#endif
// Set up the axis+extruder arrays
@@ -2780,6 +2788,44 @@ GCodeResult Platform::SetMotorCurrent(size_t axisOrExtruder, float currentOrPerc
#endif
}
+#ifdef DUET3_MB6XD
+
+// Fetch the worst (longest) timings of any driver, set up the step pulse width timer, and convert the other timings from microseconds to step clocks
+void Platform::UpdateDriverTimings()
+{
+ float worstTimings[4];
+ memcpyf(worstTimings, driverTimingMicroseconds[0], 4);
+ for (size_t driver = 1; driver < NumDirectDrivers; ++driver)
+ {
+ for (size_t i = 0; i < 4; ++i)
+ {
+ if (driverTimingMicroseconds[driver][i] > worstTimings[i])
+ {
+ worstTimings[i] = driverTimingMicroseconds[driver][i];
+ }
+ }
+ }
+
+ // Convert the step pulse width to clocks of the step pulse gate timer. First define some constants.
+ constexpr uint32_t StepGateTcClockFrequency = (SystemCoreClockFreq/2)/8;
+ constexpr float StepGateClocksPerMicrosecond = (float)StepGateTcClockFrequency/1.0e6;
+ constexpr float MicrosecondsPerStepGateClock = 1.0e6/(float)StepGateTcClockFrequency;
+
+ const float fclocks = ceilf(worstTimings[0] * StepGateClocksPerMicrosecond);
+ const uint32_t gateClocks = (uint32_t)fclocks;
+ STEP_GATE_TC->TC_CHANNEL[STEP_GATE_TC_CHAN].TC_RC = gateClocks;
+
+ // Convert the quantised step pulse width back to microseconds
+ const float actualStepPulseMicroseconds = fclocks * MicrosecondsPerStepGateClock;
+
+ // Now convert the other values from microseconds to step clocks
+ stepPulseMinimumPeriodClocks = MicrosecondsToStepClocks(worstTimings[1] + actualStepPulseMicroseconds);
+ directionSetupClocks = MicrosecondsToStepClocks(worstTimings[2]);
+ directionHoldClocksFromLeadingEdge = MicrosecondsToStepClocks(worstTimings[3] + actualStepPulseMicroseconds);
+}
+
+#endif
+
// This must not be called from an ISR, or with interrupts disabled.
void Platform::UpdateMotorCurrent(size_t driver, float current) noexcept
{
@@ -2790,46 +2836,6 @@ void Platform::UpdateMotorCurrent(size_t driver, float current) noexcept
{
SmartDrivers::SetCurrent(driver, current);
}
-#elif defined (DUET_06_085)
- const uint16_t pot = (unsigned short)((0.256*current*8.0*senseResistor + maxStepperDigipotVoltage/2)/maxStepperDigipotVoltage);
- if (driver < 4)
- {
- mcpDuet.setNonVolatileWiper(potWipes[driver], pot);
- mcpDuet.setVolatileWiper(potWipes[driver], pot);
- }
- else
- {
- if (board == BoardType::Duet_085)
- {
- // Extruder 0 is on DAC channel 0
- if (driver == 4)
- {
- const float dacVoltage = max<float>(current * 0.008 * senseResistor + stepperDacVoltageOffset, 0.0); // the voltage we want from the DAC relative to its minimum
- const float dac = dacVoltage/stepperDacVoltageRange;
- AnalogOut(DAC0, dac);
- }
- else
- {
- mcpExpansion.setNonVolatileWiper(potWipes[driver-1], pot);
- mcpExpansion.setVolatileWiper(potWipes[driver-1], pot);
- }
- }
- else if (driver < 8) // on a Duet 0.6 we have a maximum of 8 drives
- {
- mcpExpansion.setNonVolatileWiper(potWipes[driver], pot);
- mcpExpansion.setVolatileWiper(potWipes[driver], pot);
- }
- }
-#elif defined(__ALLIGATOR__)
- // Alligator SPI DAC current
- if (driver < 4) // Onboard DAC
- {
- dacAlligator.setChannel(3-driver, current * 0.102);
- }
- else // Piggy module DAC
- {
- dacPiggy.setChannel(7-driver, current * 0.102);
- }
#elif defined(__LPC17xx__)
if (hasDriverCurrentControl)
{
@@ -3103,8 +3109,8 @@ void Platform::SetDriverStepTiming(size_t driver, const float microseconds[4]) n
{
if (microseconds[i] > MinStepPulseTiming)
{
- slowDriversBitmap |= StepPins::CalcDriverBitmap(driver); // this drive does need extended timing
- const uint32_t clocks = (uint32_t)(((float)StepClockRate * microseconds[i] * 0.000001) + 0.99); // convert microseconds to step clocks, rounding up
+ slowDriversBitmap |= StepPins::CalcDriverBitmap(driver); // this drive does need extended timing
+ const uint32_t clocks = MicrosecondsToStepClocks(microseconds[i]); // convert microseconds to step clocks, rounding up
if (clocks > slowDriverStepTimingClocks[i])
{
slowDriverStepTimingClocks[i] = clocks;
@@ -3770,11 +3776,13 @@ void Platform::SetBoardType(BoardType bt) noexcept
board = (digitalRead(DIRECTION_PINS[1])) // if SAME54P20A
? BoardType::Duet3Mini_WiFi
: BoardType::Duet3Mini_Ethernet;
-#elif defined(DUET3)
+#elif defined(DUET3_MB6HC)
// Driver 0 direction has a pulldown resistor on v0.6 and v1.0 boards, but won't on v1.01 boards
pinMode(DIRECTION_PINS[0], INPUT_PULLUP);
delayMicroseconds(20); // give the pullup resistor time to work
- board = (digitalRead(DIRECTION_PINS[0])) ? BoardType::Duet3_v101 : BoardType::Duet3_v06_100;
+ board = (digitalRead(DIRECTION_PINS[0])) ? BoardType::Duet3_6HC_v101 : BoardType::Duet3_6HC_v06_100;
+#elif defined(DUET3_MB6XD)
+ board = BoardType::Duet3_6XD;
#elif defined(SAME70XPLD)
board = BoardType::SAME70XPLD_0;
#elif defined(DUET_NG)
@@ -3848,9 +3856,11 @@ const char *_ecv_array Platform::GetElectronicsString() const noexcept
case BoardType::Duet3Mini_Unknown: return "Duet 3 " BOARD_SHORT_NAME " unknown variant";
case BoardType::Duet3Mini_WiFi: return "Duet 3 " BOARD_SHORT_NAME " WiFi";
case BoardType::Duet3Mini_Ethernet: return "Duet 3 " BOARD_SHORT_NAME " Ethernet";
-#elif defined(DUET3)
- case BoardType::Duet3_v06_100: return "Duet 3 " BOARD_SHORT_NAME " v0.6 or 1.0";
- case BoardType::Duet3_v101: return "Duet 3 " BOARD_SHORT_NAME " v1.01 or later";
+#elif defined(DUET3_MB6HC)
+ case BoardType::Duet3_6HC_v06_100: return "Duet 3 " BOARD_SHORT_NAME " v0.6 or 1.0";
+ case BoardType::Duet3_6HC_v101: return "Duet 3 " BOARD_SHORT_NAME " v1.01 or later";
+#elif defined(DUET3_MB6XD)
+ case BoardType::Duet3_6XD: return "Duet 3 " BOARD_SHORT_NAME; // we have only one version at present
#elif defined(SAME70XPLD)
case BoardType::SAME70XPLD_0: return "SAME70-XPLD";
#elif defined(DUET_NG)
@@ -3863,18 +3873,8 @@ const char *_ecv_array Platform::GetElectronicsString() const noexcept
case BoardType::Duet2SBC_102: return "Duet 2 + SBC 1.02 or later";
#elif defined(DUET_M)
case BoardType::DuetM_10: return "Duet Maestro 1.0";
-#elif defined(DUET_06_085)
- case BoardType::Duet_06: return "Duet 0.6";
- case BoardType::Duet_07: return "Duet 0.7";
- case BoardType::Duet_085: return "Duet 0.85";
-#elif defined(__RADDS__)
- case BoardType::RADDS_15: return "RADDS 1.5";
-#elif defined(__ALLIGATOR__)
- case BoardType::Alligator_2: return "Alligator r2";
#elif defined(PCCB_10)
case BoardType::PCCB_v10: return "PC001373";
-#elif defined(PCCB_08) || defined(PCCB_08_X5)
- case BoardType::PCCB_v08: return "PCCB 0.8";
#elif defined(__LPC17xx__)
case BoardType::Lpc: return LPC_ELECTRONICS_STRING;
#else
@@ -3893,9 +3893,11 @@ const char *_ecv_array Platform::GetBoardString() const noexcept
case BoardType::Duet3Mini_Unknown: return "duet5lcunknown";
case BoardType::Duet3Mini_WiFi: return "duet5lcwifi";
case BoardType::Duet3Mini_Ethernet: return "duet5lcethernet";
-#elif defined(DUET3)
- case BoardType::Duet3_v06_100: return "duet3mb6hc100";
- case BoardType::Duet3_v101: return "duet3mb6hc101";
+#elif defined(DUET3_MB6HC)
+ case BoardType::Duet3_6HC_v06_100: return "duet3mb6hc100";
+ case BoardType::Duet3_6HC_v101: return "duet3mb6hc101";
+#elif defined(DUET3_MB6XD)
+ case BoardType::Duet3_6XD: return "duet3mb6xd"; // we have only one version at present
#elif defined(SAME70XPLD)
case BoardType::SAME70XPLD_0: return "same70xpld";
#elif defined(DUET_NG)
@@ -3907,18 +3909,8 @@ const char *_ecv_array Platform::GetBoardString() const noexcept
case BoardType::Duet2SBC_102: return "duet2sbc102";
#elif defined(DUET_M)
case BoardType::DuetM_10: return "duetmaestro100";
-#elif defined(DUET_06_085)
- case BoardType::Duet_06: return "duet06";
- case BoardType::Duet_07: return "duet07";
- case BoardType::Duet_085: return "duet085";
-#elif defined(__RADDS__)
- case BoardType::RADDS_15: return "radds15";
-#elif defined(__ALLIGATOR__)
- case BoardType::Alligator_2: return "alligator2";
#elif defined(PCCB_10)
case BoardType::PCCB_v10: return "pc001373";
-#elif defined(PCCB_08) || defined(PCCB_08_X5)
- case BoardType::PCCB_v08: return "pccb08";
#elif defined(__LPC17xx__)
case BoardType::Lpc: return LPC_BOARD_STRING;
#else
diff --git a/src/Platform/Platform.h b/src/Platform/Platform.h
index ac82fcd4..b1d80221 100644
--- a/src/Platform/Platform.h
+++ b/src/Platform/Platform.h
@@ -123,9 +123,11 @@ enum class BoardType : uint8_t
Duet3Mini_Unknown,
Duet3Mini_WiFi,
Duet3Mini_Ethernet,
-#elif defined(DUET3)
- Duet3_v06_100 = 1,
- Duet3_v101 = 2,
+#elif defined(DUET3_MB6HC)
+ Duet3_6HC_v06_100 = 1,
+ Duet3_6HC_v101 = 2,
+#elif defined(DUET3_MB6XD)
+ Duet3_6XD = 1,
#elif defined(SAME70XPLD)
SAME70XPLD_0 = 1
#elif defined(DUET_NG)
@@ -137,18 +139,8 @@ enum class BoardType : uint8_t
Duet2SBC_102 = 6,
#elif defined(DUET_M)
DuetM_10 = 1,
-#elif defined(DUET_06_085)
- Duet_06 = 1,
- Duet_07 = 2,
- Duet_085 = 3
-#elif defined(__RADDS__)
- RADDS_15 = 1
#elif defined(PCCB_10)
PCCB_v10 = 1
-#elif defined(PCCB_08) || defined(PCCB_08_X5)
- PCCB_v08 = 1
-#elif defined(DUET3MINI)
- Duet_5LC = 1
#elif defined(__LPC17xx__)
Lpc = 1
#else
@@ -704,6 +696,12 @@ private:
void ReportDrivers(MessageType mt, DriversBitmap& whichDrivers, const char *_ecv_array text, bool& reported) noexcept;
#endif
+ // Convert microseconds to step clocks, rounding up to the next step clock
+ static constexpr uint32_t MicrosecondsToStepClocks(float us) noexcept
+ {
+ return (uint32_t)(((float)StepClockRate * 0.000001 * us) + 0.99);
+ }
+
#ifdef DUET3_MB6XD
void UpdateDriverTimings();
#endif
diff --git a/src/RepRapFirmware.h b/src/RepRapFirmware.h
index a6c743f4..e956dd50 100644
--- a/src/RepRapFirmware.h
+++ b/src/RepRapFirmware.h
@@ -329,11 +329,7 @@ typedef Bitmap<uint32_t> DriversBitmap; // Type of a bitmap representing a set
typedef Bitmap<uint32_t> FansBitmap; // Type of a bitmap representing a set of fan numbers
typedef Bitmap<uint32_t> HeatersBitmap; // Type of a bitmap representing a set of heater numbers
typedef Bitmap<uint16_t> DriverChannelsBitmap; // Type of a bitmap representing a set of drivers that typically have a common cooling fan
-#if defined(DUET3) || defined(DUET_NG)
typedef Bitmap<uint32_t> InputPortsBitmap; // Type of a bitmap representing a set of input ports
-#else
-typedef Bitmap<uint16_t> InputPortsBitmap; // Type of a bitmap representing a set of input ports
-#endif
typedef Bitmap<uint32_t> TriggerNumbersBitmap; // Type of a bitmap representing a set of trigger numbers
#if defined(DUET3) || defined(DUET3MINI)