Skip to content

Commit

Permalink
Merge pull request #455 from MaslowCNC/Add-support-for-M106-and-M107
Browse files Browse the repository at this point in the history
Add support for M106 and M107
  • Loading branch information
MaslowCommunityGardenRobot authored Jun 21, 2018
2 parents d11de8a + 6a44c85 commit 3ec93bd
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
8 changes: 8 additions & 0 deletions cnc_ctrl_v1/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,14 @@ void executeMcodeLine(const String& gcodeLine){
pause();
}
break;
case 106:
//Turn laser on
laserOn();
break;
case 107:
//Turn laser off
laserOff();
break;
default:
Serial.print(F("Command M"));
Serial.print(mNumber);
Expand Down
14 changes: 13 additions & 1 deletion cnc_ctrl_v1/Spindle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "Maslow.h"
#include "Settings.h"

// the variable SpindlePowerControlPin is assigned in configAuxLow() in System.cpp
// the variables SpindlePowerControlPin and LaserPowerPin are assigned in configAuxLow() in System.cpp

// Globals for Spindle control, both poorly named
Servo myservo; // create servo object to control a servo
Expand Down Expand Up @@ -102,3 +102,15 @@ void setSpindlePower(bool powerState) {
maslowDelay(delayAfterChange);
}
}

void laserOn() {
Serial.println("Laser on");
pinMode(LaserPowerPin, OUTPUT);
digitalWrite(LaserPowerPin, HIGH);
}

void laserOff(){
Serial.println("Laser off");
pinMode(LaserPowerPin, OUTPUT);
digitalWrite(LaserPowerPin, LOW);
}
2 changes: 2 additions & 0 deletions cnc_ctrl_v1/Spindle.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@
#define spindle_h

void setSpindlePower(bool powerState);
void laserOn();
void laserOff();

#endif
4 changes: 4 additions & 0 deletions cnc_ctrl_v1/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ bool TLE5206;
// extern values using AUX pins defined in configAuxLow() and configAuxHigh()
int SpindlePowerControlPin; // output for controlling spindle power
int ProbePin; // use this input for zeroing zAxis with G38.2 gcode
int LaserPowerPin; // Use this output to turn on and off a laser diode


void calibrateChainLengths(String gcodeLine){
Expand Down Expand Up @@ -253,6 +254,9 @@ void setupAxes(){
void configAuxLow(int aux1, int aux2, int aux3, int aux4, int aux5, int aux6) {
SpindlePowerControlPin = aux1; // output for controlling spindle power
ProbePin = aux4; // use this input for zeroing zAxis with G38.2 gcode
LaserPowerPin = aux2; // output for controlling a laser diode
pinMode(LaserPowerPin, OUTPUT);
digitalWrite(LaserPowerPin, LOW);
}

void configAuxHigh(int aux7, int aux8, int aux9) {
Expand Down
1 change: 1 addition & 0 deletions cnc_ctrl_v1/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ extern RingBuffer incSerialBuffer;
extern Kinematics kinematics;
extern byte systemRtExecAlarm;
extern int SpindlePowerControlPin;
extern int LaserPowerPin;
extern int ProbePin;

void calibrateChainLengths(String);
Expand Down

0 comments on commit 3ec93bd

Please sign in to comment.