Skip to content

Commit

Permalink
Merge branch 'ver_3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
FarMcKon committed Nov 9, 2011
2 parents 73c29c4 + 76a8a00 commit 2db7bd0
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 35 deletions.
2 changes: 1 addition & 1 deletion firmware/current_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.00
3.1
14 changes: 11 additions & 3 deletions firmware/src/Extruder/Host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,15 @@ bool processQueryPacket(const InPacket& from_host, OutPacket& to_host) {
to_host.append8(RC_OK);
return true;
case SLAVE_CMD_GET_TEMP:
{
to_host.append8(RC_OK);
to_host.append16(board.getExtruderHeater().get_current_temperature());
to_host.append16(board.get_current_temperature());
//was board.ExtruderHeater().get_current_temperature(););
return true;
}
case SLAVE_CMD_SET_TEMP:
board.getExtruderHeater().set_target_temperature(from_host.read16(2));
board.set_target_temperature(from_host.read16(2));
//getExtruderHeater().set_target_temperature(from_host.read16(2));
to_host.append8(RC_OK);
return true;
case SLAVE_CMD_READ_FROM_EEPROM:
Expand Down Expand Up @@ -133,7 +137,7 @@ bool processQueryPacket(const InPacket& from_host, OutPacket& to_host) {
to_host.append8(RC_OK);
return true;
case SLAVE_CMD_TOGGLE_FAN:
board.setFan((from_host.read8(2) & 0x01) != 0);
board.setFanRunning((from_host.read8(2) & 0x01) != 0);
to_host.append8(RC_OK);
return true;
case SLAVE_CMD_TOGGLE_VALVE:
Expand Down Expand Up @@ -230,6 +234,10 @@ bool processQueryPacket(const InPacket& from_host, OutPacket& to_host) {
to_host.append8(RC_OK);
board.lightIndicatorLED();
return true;
case SLAVE_CMD_TOGGLE_ABP:
board.setAutomatedBuildPlatformRunning((from_host.read8(2) & 0x01) != 0);
to_host.append8(RC_OK);

}
}
return false;
Expand Down
20 changes: 18 additions & 2 deletions firmware/src/Extruder/boards/ecv22/ExtruderBoard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@ void ExtruderBoard::runExtruderSlice() {
}
}

int ExtruderBoard::get_current_temperature()
{
return extruder_heater.get_current_temperature();
}

void ExtruderBoard::set_target_temperature(int temp )
{
return extruder_heater.set_target_temperature(temp);
}


void ExtruderBoard::setMotorSpeed(int16_t speed) {
setExtruderMotor(speed);
}
Expand Down Expand Up @@ -260,8 +271,13 @@ void setChannel(ChannelChoice c, uint8_t value, bool binary) {
}
}

void ExtruderBoard::setFan(bool on) {
setChannel(abp_channel,on?255:0,true);
void ExtruderBoard::setFanRunning(bool state)
{ // The Goggles, they do nothing!
// on these board, there is no toggle fan. This is vestigle
}

void ExtruderBoard::setAutomatedBuildPlatformRunning(bool state) {
setChannel(abp_channel,state?255:0,true);
}

// When using as a valve driver, always use channel A, regardless of
Expand Down
6 changes: 5 additions & 1 deletion firmware/src/Extruder/boards/ecv22/ExtruderBoard.hh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public:
uint8_t getResetFlags();


int get_current_temperature();
void set_target_temperature(int);

Heater& getExtruderHeater() { return extruder_heater; }
Heater& getPlatformHeater() { return platform_heater; }

Expand All @@ -97,7 +100,8 @@ public:
// Stops/starts the motor while holding torque
void setMotorOn(bool on);
#endif
void setFan(bool on);
void setFanRunning(bool state);
void setAutomatedBuildPlatformRunning(bool state);
void setValve(bool on);
UART& getHostUART() { return UART::getHostUART(); }

Expand Down
22 changes: 20 additions & 2 deletions firmware/src/Extruder/boards/ecv34/ExtruderBoard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,17 @@ void ExtruderBoard::runExtruderSlice() {
coolingFan.manageCoolingFan();
}

int ExtruderBoard::get_current_temperature()
{
return extruder_heater.get_current_temperature();
}

void ExtruderBoard::set_target_temperature(int temp )
{
return extruder_heater.set_target_temperature(temp);
}


void ExtruderBoard::setMotorSpeed(int16_t speed) {
// Since the motor and regulated cooling fan share an output, only one can be enabled at a time.
// Therefore, we should override the motor speed command if the cooling fan is activated.
Expand Down Expand Up @@ -230,12 +241,19 @@ void ExtruderBoard::doInterrupt() {
}
}

void ExtruderBoard::setFan(bool on) {
//runs the AutoBuildPlatform (connected to 'Extra' screw terms on ECv3.x )
void ExtruderBoard::setAutomatedBuildPlatformRunning(bool state)
{
CHANNEL_A.setValue(state);
}

//runs the Extruder Cooling Fan (connected to 'A1/B1' screw term on ECv3.x)
void ExtruderBoard::setFanRunning(bool state) {
//CHANNEL_A.setValue(on);
MOTOR_DIR_PIN.setDirection(true);
MOTOR_DIR_PIN.setValue(true);
MOTOR_ENABLE_PIN.setDirection(true);
MOTOR_ENABLE_PIN.setValue(on);
MOTOR_ENABLE_PIN.setValue(state);
}

void ExtruderBoard::setValve(bool on) {
Expand Down
13 changes: 11 additions & 2 deletions firmware/src/Extruder/boards/ecv34/ExtruderBoard.hh
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,16 @@ private:
public:
void reset(uint8_t resetFlags);

void runExtruderSlice();
void runExtruderSlice();

// Return the processor's reset status flags. These are useful
// for diagnosing what might have triggered the last processor
// reset.
uint8_t getResetFlags();

int get_current_temperature();
void set_target_temperature(int);

Heater& getExtruderHeater() { return extruder_heater; }
Heater& getPlatformHeater() { return platform_heater; }

Expand All @@ -96,7 +99,13 @@ public:
void setMotorSpeed(int16_t speed);
void setMotorSpeedRPM(uint32_t speed, bool direction) {} // Unsupported on 3.4

void setFan(bool on);
/// Enable/Disable the extruder cooling fan
void setFanRunning(bool state);

/// Enable/Disable the automatic build platform motor
void setAutomatedBuildPlatformRunning(bool state);


void setValve(bool on);
UART& getHostUART() { return UART::getHostUART(); }

Expand Down
11 changes: 8 additions & 3 deletions firmware/src/Motherboard/Host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,16 @@ bool void handleVersion2(uint16 host_driver_version) {
// puts fw version into a reply packet, and send it back
inline void handleVersion(const InPacket& from_host, OutPacket& to_host) {

// Case to give an error on Replicator G versions older than 0025. See footnote 1
if(from_host.read16(1) <= 25 ) {
// Case to give an error on Replicator G versions older than 0027.
// See footnote 1, footnote 2
if(from_host.read16(1) <= 26 ) {
to_host.append8(RC_OK);
to_host.append16(0x0000);
}
else {
to_host.append8(RC_OK);
to_host.append16(firmware_version);
}

}

inline void handleGetBuildName(const InPacket& from_host, OutPacket& to_host) {
Expand Down Expand Up @@ -587,3 +587,8 @@ void stopBuild() {
* lie, and reply with firmware 0.00 to case ReplicatorG to display a 'null version' error
* so users will know to upgrade.
*/
/* footnote 2: due to an overlap in control between Automated Build Platform, and
* fan control, firmware 3.01 and newer only works with replicatorG 0027 or newer.
* Long story short, some fw 2.8 -> fw 3.0 refactoring did not work as expected, and
* broke running ABP and Mk6/Mk7 extruder Fan on the same machine
*/
6 changes: 3 additions & 3 deletions firmware/src/Motherboard/Host.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

// TODO: Make this a class.
/// Functions in the host namespace deal with communications to the host
/// computer. The host also implents a simple state machine, because it is
/// also responsable for handling prints from SD card.
/// computer. The host also implements a simple state machine, because it is
/// also responsible for handling prints from SD card.
namespace host {

const int MAX_MACHINE_NAME_LEN = 32;
Expand All @@ -34,7 +34,7 @@ const int MAX_FILE_LEN = MAX_PACKET_PAYLOAD-1;
enum HostState {
HOST_STATE_READY = 0,
HOST_STATE_BUILDING = 1,
HOST_STATE_BUILDING_FROM_SD = 2,
HOST_STATE_BUILDING_FROM_SD = 2,
HOST_STATE_ERROR = 3
};

Expand Down
1 change: 1 addition & 0 deletions firmware/src/shared/Commands.hh
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
#define SLAVE_CMD_ABORT 24
#define SLAVE_CMD_READ_FROM_EEPROM 25
#define SLAVE_CMD_WRITE_TO_EEPROM 26
#define SLAVE_CMD_TOGGLE_ABP 27

#define SLAVE_CMD_GET_PLATFORM_TEMP 30
#define SLAVE_CMD_SET_PLATFORM_TEMP 31
Expand Down
23 changes: 9 additions & 14 deletions firmware/src/shared/CoolingFan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
//#include "ExtruderMotor.hh"
#include "Eeprom.hh"
#include "EepromMap.hh"

#ifdef IS_EXTRUDER_BOARD
#include "ExtruderBoard.hh"
#include "ExtruderBoard.hh"
#endif

#define FAN_ENABLED 1
Expand Down Expand Up @@ -49,34 +50,28 @@ void CoolingFan::enable() {

void CoolingFan::disable() {
enabled = false;
disableFan();
setFanRunning(false);
}

void CoolingFan::manageCoolingFan() {
// TODO: only change the state if necessary
if (enabled) {
if (heater.get_current_temperature() > setPoint) {
enableFan();
setFanRunning(true);
}
else {
disableFan();
setFanRunning(false);
}
}
}

void CoolingFan::enableFan() {
void CoolingFan::setFanRunning(bool state)
{
#ifdef IS_EXTRUDER_BOARD
ExtruderBoard::getBoard().setFan(true);
ExtruderBoard::getBoard().setFanRunning(state);
#else
#warning cooling fan feature disabled
#endif
}

void CoolingFan::disableFan() {
#ifdef IS_EXTRUDER_BOARD
//#warning cooling fan feature disabled
ExtruderBoard::getBoard().setFan(false);
#else
#warning cooling fan feature disabled
#endif
}

6 changes: 2 additions & 4 deletions firmware/src/shared/CoolingFan.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@
/// \ingroup SoftwareLibraries
class CoolingFan {
private:
/// Enable the cooling fan, setting it to run at full speed.
void enableFan();

/// Disable the cooling fan, halting it immediately.
void disableFan();
/// Enable/Disable the cooling fan, setting it to run at full speed.
void setFanRunning(bool state);

Heater& heater; ///< Heater module to read the current temperature from.

Expand Down

0 comments on commit 2db7bd0

Please sign in to comment.