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
diff options
context:
space:
mode:
-rw-r--r--GCodes.h9
-rw-r--r--GCodes.ino96
-rw-r--r--Heat.h12
-rw-r--r--Heat.ino30
-rw-r--r--Platform.h18
-rw-r--r--Platform.ino1
-rw-r--r--RepRapFirmware.ino2
7 files changed, 130 insertions, 38 deletions
diff --git a/GCodes.h b/GCodes.h
index 65199c97..fd1913dc 100644
--- a/GCodes.h
+++ b/GCodes.h
@@ -22,6 +22,8 @@ Licence: GPL
#ifndef GCODES_H
#define GCODES_H
+#define STACK 5
+
// Small class to hold an individual GCode
@@ -65,11 +67,14 @@ class GCodes
private:
+ boolean AllMovesAreFinishedAndMoveBufferIsLoaded();
boolean ActOnGcode(GCodeBuffer* gb);
boolean SetUpMove(GCodeBuffer* gb);
boolean DoDwell(GCodeBuffer *gb);
boolean DoHome();
boolean NoHome();
+ boolean Push();
+ boolean Pop();
Platform* platform;
boolean active;
Webserver* webserver;
@@ -85,6 +90,10 @@ class GCodes
boolean checkEndStops;
boolean drivesRelative; // All except X, Y and Z
boolean axesRelative; // X, Y and Z
+ boolean drivesRelativeStack[STACK];
+ boolean axesRelativeStack[STACK];
+ float feedrateStack[STACK];
+ int8_t stackPointer;
char gCodeLetters[DRIVES + 1]; // Extra is for F
float lastPos[DRIVES - AXES]; // Just needed for relative moves.
float distanceScale;
diff --git a/GCodes.ino b/GCodes.ino
index 7bcf1936..d94033fa 100644
--- a/GCodes.ino
+++ b/GCodes.ino
@@ -60,6 +60,7 @@ void GCodes::Init()
homeYQueued = false;
homeZQueued = false;
dwellWaiting = false;
+ stackPointer = 0;
dwellTime = platform->Time();
}
@@ -104,6 +105,76 @@ void GCodes::Spin()
}
}
+boolean GCodes::AllMovesAreFinishedAndMoveBufferIsLoaded()
+{
+ // Last one gone?
+
+ if(moveAvailable)
+ return false;
+
+ // Wait for all the queued moves to stop so we get the actual last position and feedrate
+
+ if(!reprap.GetMove()->AllMovesAreFinished())
+ return false;
+ reprap.GetMove()->ResumeMoving();
+
+ // Load the last position; If Move can't accept more, return false - should never happen
+
+ if(!reprap.GetMove()->GetCurrentState(moveBuffer))
+ return false;
+
+ return true;
+}
+
+boolean GCodes::Push()
+{
+ if(stackPointer >= STACK)
+ {
+ platform->Message(HOST_MESSAGE, "Push(): stack overflow!\n");
+ return true;
+ }
+
+ if(!AllMovesAreFinishedAndMoveBufferIsLoaded())
+ return false;
+
+ drivesRelativeStack[stackPointer] = drivesRelative;
+ axesRelativeStack[stackPointer] = axesRelative;
+ feedrateStack[stackPointer] = moveBuffer[DRIVES];
+ stackPointer++;
+
+ return true;
+}
+
+boolean GCodes::Pop()
+{
+ if(stackPointer <= 0)
+ {
+ platform->Message(HOST_MESSAGE, "Push(): stack underflow!\n");
+ return true;
+ }
+
+ if(!AllMovesAreFinishedAndMoveBufferIsLoaded())
+ return false;
+
+ stackPointer--;
+ drivesRelative = drivesRelativeStack[stackPointer];
+ axesRelative = axesRelativeStack[stackPointer];
+
+ // Remember for next time if we have just been switched
+ // to absolute drive moves
+
+ for(int8_t i = AXES; i < DRIVES; i++)
+ lastPos[i - AXES] = moveBuffer[i];
+
+ // Do a null move to set the correct feedrate
+
+ moveBuffer[DRIVES] = feedrateStack[stackPointer];
+
+ checkEndStops = false;
+ moveAvailable = true;
+ return true;
+}
+
// Move expects all axis movements to be absolute, and all
// extruder drive moves to be relative. This function serves that.
// If the Move class can't receive the move (i.e. things have to wait)
@@ -158,7 +229,6 @@ boolean GCodes::SetUpMove(GCodeBuffer *gb)
lastPos[i - AXES] = moveBuffer[i];
checkEndStops = false;
-
moveAvailable = true;
return true;
}
@@ -186,23 +256,9 @@ boolean GCodes::DoHome()
// Treat more or less like any other move
// Do one axis at a time, starting with X.
- // Last one gone yet?
-
- if(moveAvailable)
+ if(!AllMovesAreFinishedAndMoveBufferIsLoaded())
return false;
- // Wait for all the queued moves to stop
-
- if(!reprap.GetMove()->AllMovesAreFinished())
- return false;
- reprap.GetMove()->ResumeMoving();
-
- // Load the last position; If Move can't accept more, return false - should never happen
-
- if(!reprap.GetMove()->GetCurrentState(moveBuffer))
- return false;
-
-
if(homeX)
{
if(homeXQueued)
@@ -437,6 +493,14 @@ boolean GCodes::ActOnGcode(GCodeBuffer *gb)
if(gb->Seen('S'))
reprap.debug(gb->GetIValue());
break;
+
+ case 120:
+ result = Push();
+ break;
+
+ case 121:
+ result = Pop();
+ break;
case 126: // Valve open
platform->Message(HOST_MESSAGE, "M126 - valves not yet implemented\n");
diff --git a/Heat.h b/Heat.h
index d2410789..b26fa019 100644
--- a/Heat.h
+++ b/Heat.h
@@ -25,18 +25,15 @@ class PID
{
public:
- PID(int8_t h);
- void Init(float st, float p, float i, float d, float w);
+ PID(Platform* p, int8_t h);
+ void Init();
void Spin();
void SetTemperature(float t);
private:
+ Platform* platform;
float temperature;
- float kp;
- float ki;
- float kd;
- float kw;
int8_t heater;
};
@@ -47,7 +44,7 @@ class Heat
Heat(Platform* p, GCodes* g);
void Spin();
- void Init(float st);
+ void Init();
void Exit();
private:
@@ -57,7 +54,6 @@ class Heat
boolean active;
PID* pids[HEATERS];
float lastTime;
- float sampleTime;
};
diff --git a/Heat.ino b/Heat.ino
index 3a694eaa..7eba0a47 100644
--- a/Heat.ino
+++ b/Heat.ino
@@ -25,18 +25,16 @@ Heat::Heat(Platform* p, GCodes* g)
platform = p;
gCodes = g;
for(int8_t heater=0; heater < HEATERS; heater++)
- pids[heater] = new PID(heater);
+ pids[heater] = new PID(platform, heater);
active = false;
}
-void Heat::Init(float st)
+void Heat::Init()
{
- sampleTime = st;
-
for(int8_t heater=0; heater < HEATERS; heater++)
{
platform->SetHeater(heater, -1);
-// pids[heater]->Init();
+ pids[heater]->Init();
}
lastTime = platform->Time();
active = true;
@@ -53,19 +51,27 @@ void Heat::Spin()
return;
unsigned long t = platform->Time();
- if(t - lastTime < sampleTime)
+ if(t - lastTime < platform->HeatSampleTime())
return;
lastTime = t;
+ for(int8_t heater=0; heater < HEATERS; heater++)
+ pids[heater]->Spin();
}
//******************************************************************************************************
-PID::PID(int8_t h)
+PID::PID(Platform* p, int8_t h)
{
+ platform = p;
heater = h;
}
- /*
- kp = p;
- ki = i;
- kd = d;
- kw = w;*/
+
+void PID::Init()
+{
+
+}
+
+void PID::Spin()
+{
+
+}
diff --git a/Platform.h b/Platform.h
index 19bdcaf5..65d52d8d 100644
--- a/Platform.h
+++ b/Platform.h
@@ -253,6 +253,12 @@ class Platform
float GetTemperature(int8_t heater); // Result is in degrees celsius
void SetHeater(int8_t heater, const float& power); // power is a fraction in [0,1]
+ float pidKp(int8_t heater);
+ float pidKi(int8_t heater);
+ float pidKd(int8_t heater);
+ float pidKw(int8_t heater);
+ boolean pidBangBang(int8_t heater);
+ float HeatSampleTime();
//-------------------------------------------------------------------------------------------------------
@@ -304,6 +310,7 @@ class Platform
float pidKds[HEATERS];
float pidKps[HEATERS];
float pidILimits[HEATERS];
+ float heatSampleTime;
// Files
@@ -369,7 +376,7 @@ inline char* Platform::GetTempDir()
//*****************************************************************************************************************
-// Drive the RepRap machine
+// Drive the RepRap machine - Movement
inline float Platform::DriveStepsPerUnit(int8_t drive)
{
@@ -423,11 +430,20 @@ inline float Platform::AxisLength(int8_t drive)
return axisLengths[drive];
}
+//********************************************************************************************************
+
+// Drive the RepRap machine - Heat and temperature
+
inline int Platform::GetRawTemperature(byte heater)
{
return analogRead(tempSensePins[heater]);
}
+inline float Platform::HeatSampleTime()
+{
+ return heatSampleTime;
+}
+
//*********************************************************************************************************
// Interrupts
diff --git a/Platform.ino b/Platform.ino
index e20f469c..945edaa3 100644
--- a/Platform.ino
+++ b/Platform.ino
@@ -107,6 +107,7 @@ void Platform::Init()
gcodeDir = GCODE_DIR;
sysDir = SYS_DIR;
tempDir = TEMP_DIR;
+ heatSampleTime = HEAT_SAMPLE_TIME;
}
for(i = 0; i < DRIVES; i++)
diff --git a/RepRapFirmware.ino b/RepRapFirmware.ino
index fed45307..5cf9eaf8 100644
--- a/RepRapFirmware.ino
+++ b/RepRapFirmware.ino
@@ -172,7 +172,7 @@ void RepRap::Init()
gCodes->Init();
webserver->Init();
move->Init();
- heat->Init(HEAT_SAMPLE_TIME);
+ heat->Init();
dbg = false;
platform->Message(HOST_MESSAGE, "RepRapPro RepRap Firmware (Re)Started\n");
active = true;