Fixed cooling fan support (M106 command)
Fixed M106 command so that the cooling fan is controllably by PWM and works the right way round (0 = off, 1 = on). Also added optional P parameter to specify the value that corresponds to maximum PWM.
This commit is contained in:
parent
2b7b9fc505
commit
2305dc27c9
5 changed files with 18 additions and 5 deletions
|
@ -24,7 +24,7 @@ Licence: GPL
|
|||
#define CONFIGURATION_H
|
||||
|
||||
#define NAME "RepRapFirmware"
|
||||
#define VERSION "0.57p-dc42"
|
||||
#define VERSION "0.57q-dc42"
|
||||
#define DATE "2014-02-24"
|
||||
#define LAST_AUTHOR "dc42"
|
||||
|
||||
|
|
13
GCodes.cpp
13
GCodes.cpp
|
@ -59,7 +59,9 @@ void GCodes::Init()
|
|||
gCodeLetters = GCODE_LETTERS;
|
||||
distanceScale = 1.0;
|
||||
for (int8_t i = 0; i < DRIVES - AXES; i++)
|
||||
{
|
||||
lastPos[i] = 0.0;
|
||||
}
|
||||
fileBeingPrinted = NULL;
|
||||
fileToPrint = NULL;
|
||||
fileBeingWritten = NULL;
|
||||
|
@ -85,6 +87,7 @@ void GCodes::Init()
|
|||
longWait = platform->Time();
|
||||
dwellTime = longWait;
|
||||
axisIsHomed[X_AXIS] = axisIsHomed[Y_AXIS] = axisIsHomed[Z_AXIS] = false;
|
||||
fanMaxPwm = 1.0;
|
||||
}
|
||||
|
||||
void GCodes::doFilePrint(GCodeBuffer* gb)
|
||||
|
@ -1580,8 +1583,16 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
|
|||
break;
|
||||
|
||||
case 106: // Fan on or off
|
||||
if (gb->Seen('P'))
|
||||
{
|
||||
// slic3r and Cura expect PWM values to go from 0 to 255, but we expect PWM value to go from 0.0 to 1.0.
|
||||
// So I've added a P parameter to allow the top end of the range to be set, so we can be compatible with those programs.
|
||||
fanMaxPwm = fmax(gb->GetFValue(), 1.0);
|
||||
}
|
||||
if (gb->Seen('S'))
|
||||
platform->CoolingFan(gb->GetFValue());
|
||||
{
|
||||
platform->CoolingFan(fmax(gb->GetFValue(), 0.0)/fanMaxPwm);
|
||||
}
|
||||
break;
|
||||
|
||||
case 107: // Fan off - deprecated
|
||||
|
|
3
GCodes.h
3
GCodes.h
|
@ -118,8 +118,8 @@ class GCodes
|
|||
bool SendConfigToLine();
|
||||
void WriteHTMLToFile(char b, GCodeBuffer *gb);
|
||||
bool OffsetAxes(GCodeBuffer *gb);
|
||||
|
||||
int8_t Heater(int8_t head) const;
|
||||
|
||||
Platform* platform;
|
||||
bool active;
|
||||
Webserver* webserver;
|
||||
|
@ -166,6 +166,7 @@ class GCodes
|
|||
bool zProbesSet;
|
||||
float longWait;
|
||||
bool axisIsHomed[3]; // these record which of the axes have been homed
|
||||
float fanMaxPwm; // the M106 S value that represents 100% fan speed
|
||||
};
|
||||
|
||||
//*****************************************************************************************************
|
||||
|
|
|
@ -133,7 +133,7 @@ Licence: GPL
|
|||
#define TEMP_INTERVAL 0.122 // secs - check and control temperatures this often
|
||||
#define STANDBY_TEMPERATURES {ABS_ZERO, ABS_ZERO} // We specify one for the bed, though it's not needed
|
||||
#define ACTIVE_TEMPERATURES {ABS_ZERO, ABS_ZERO}
|
||||
#define COOLING_FAN_PIN 34
|
||||
#define COOLING_FAN_PIN X6
|
||||
#define HEAT_ON 0 // 0 for inverted heater (eg Duet v0.6) 1 for not (e.g. Duet v0.4)
|
||||
|
||||
#define AD_RANGE 1023.0//16383 // The A->D converter that measures temperatures gives an int this big as its max value
|
||||
|
@ -899,7 +899,8 @@ inline void Platform::CoolingFan(float speed)
|
|||
{
|
||||
if(coolingFanPin < 0)
|
||||
return;
|
||||
analogWrite(coolingFanPin, (uint8_t)(speed*255.0));
|
||||
// The cooling fan output pin gets inverted
|
||||
analogWriteNonDue(coolingFanPin, (uint32_t)((1.0 - speed)*255.0));
|
||||
}
|
||||
|
||||
//inline void Platform::SetHeatOn(int8_t ho)
|
||||
|
|
BIN
Release/RepRapFirmware-057q-dc42.bin
Normal file
BIN
Release/RepRapFirmware-057q-dc42.bin
Normal file
Binary file not shown.
Reference in a new issue