Skip to content

Commit

Permalink
Merge pull request #419 from blurfl/Define-AUX-pins-at-runtime
Browse files Browse the repository at this point in the history
Define aux pins at runtime
  • Loading branch information
BarbourSmith authored Apr 2, 2018
2 parents 1ec88e8 + d176a32 commit 6ffb1fb
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 76 deletions.
28 changes: 10 additions & 18 deletions cnc_ctrl_v1/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Maslow Control Software. If not, see <http://www.gnu.org/licenses/>.
Copyright 2014-2017 Bar Smith*/

// This file contains precompile configuration settings that apply to the
// This file contains precompile configuration settings that apply to the
// whole system

#ifndef config_h
#define config_h

// Debugging Options
#define verboseDebug 0 // set to 0 for no debug messages, 1 for single-line messages, 2 to also output ring buffer contents
#define misloopDebug 0 // set to 1 for a warning every time the movement loop fails
#define misloopDebug 0 // set to 1 for a warning every time the movement loop fails
// to complete before being interrupted, helpful for loop
// LOOPINTERVAL tuning
#define KINEMATICSDBG 0 // set to 1 for additional kinematics debug messaging
Expand All @@ -35,30 +35,22 @@

#define LOOPINTERVAL 10000 // What is the frequency of the PID loop in microseconds

// Define extra pins
#define AUX1 17
#define AUX2 16
#define AUX3 15
#define AUX4 14
#define SpindlePowerControlPin AUX1 // output for controlling spindle power
#define ProbePin AUX4 // use this input for zeroing zAxis with G38.2 gcode

// Serial variables
#define INCBUFFERLENGTH 128 // The number of bytes(characters) allocated to the
// incoming buffer.
#define EXPGCODELINE 60 // Maximum expected Gcode line length in characters
// including line ending character(s). Assumes
// client will not send more than this. Ground
#define EXPGCODELINE 60 // Maximum expected Gcode line length in characters
// including line ending character(s). Assumes
// client will not send more than this. Ground
// Control is currently set to 60. NIST spec allows
// 256. This value must be <= INCBUFFERLENGTH
#define MAXBUFFERLINES 4 // The maximum number of lines allowed in the buffer
#define POSITIONTIMEOUT 200 // The minimum number of milliseconds between
// position reports sent to Ground Control. This
// cannot be larger than the connection timout in
#define POSITIONTIMEOUT 200 // The minimum number of milliseconds between
// position reports sent to Ground Control. This
// cannot be larger than the connection timout in
// Ground Control which is 2000, a smaller number
// takes more processing time for sending data
// a larger number make position updates in GC less
// smooth. This is only a minimum, and the actual
// timeout could be significantly larger.
// timeout could be significantly larger.

#endif
4 changes: 3 additions & 1 deletion cnc_ctrl_v1/Probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Copyright 2014-2017 Bar Smith*/

#include "Maslow.h"

// the variable probePin is assigned in configAuxLow() in System.cpp

bool checkForProbeTouch(const int& probePin) {
/*
Check to see if ProbePin has gone LOW
Expand All @@ -28,4 +30,4 @@ bool checkForProbeTouch(const int& probePin) {
return 1;
}
return 0;
}
}
18 changes: 10 additions & 8 deletions cnc_ctrl_v1/Spindle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,37 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Maslow Control Software. If not, see <http://www.gnu.org/licenses/>.
Copyright 2014-2017 Bar Smith*/

// This contains all of the Spindle commands

#include "Maslow.h"

// the variable SpindlePowerControlPin is assigned in configAuxLow() in System.cpp

// Globals for Spindle control, both poorly named
Servo myservo; // create servo object to control a servo
Servo myservo; // create servo object to control a servo

void setSpindlePower(bool powerState) {
/*
* Turn spindle on or off depending on powerState
*/
*/
boolean useServo = !sysSettings.spindleAutomate;
boolean activeHigh = true;
int delayAfterChange = 1000; // milliseconds
int servoIdle = 90; // degrees
int servoOn = 180; // degrees
int servoOff = 0; // degrees
int servoDelay = 2000; // milliseconds

// Now for the main code
#if defined (verboseDebug) && verboseDebug > 1
#if defined (verboseDebug) && verboseDebug > 1
Serial.print(F("Spindle control uses pin "));
Serial.print(SpindlePowerControlPin);
#endif
if (useServo) { // use a servo to control a standard wall switch
#if defined (verboseDebug) && verboseDebug > 1
#if defined (verboseDebug) && verboseDebug > 1
Serial.print(F(" with servo (idle="));
Serial.print(servoIdle);
Serial.print(F(", on="));
Expand Down Expand Up @@ -66,7 +68,7 @@ void setSpindlePower(bool powerState) {
myservo.detach(); // stop servo control
}
else { // use a digital I/O pin to control a relay
#if defined (verboseDebug) && verboseDebug > 1
#if defined (verboseDebug) && verboseDebug > 1
Serial.print(F(" as digital output, active "));
if (activeHigh) Serial.println(F("high"));
else Serial.println(F("low"));
Expand All @@ -84,4 +86,4 @@ void setSpindlePower(bool powerState) {
}
}
maslowDelay(delayAfterChange);
}
}
Loading

0 comments on commit 6ffb1fb

Please sign in to comment.