mirror of
https://github.com/thunderbug1/Spherebot-Host-GUI.git
synced 2026-03-19 00:06:48 +01:00
implemented sending/resending- buffer and lots of other bugfixes
This commit is contained in:
@@ -40,10 +40,21 @@
|
||||
|
||||
#define VERSIONCODE "Spherebot 2.1"
|
||||
|
||||
StepperModel xAxisStepper(XAXIS_DIR_PIN, XAXIS_STEP_PIN, XAXIS_ENABLE_PIN, XAXIS_ENDSTOP_PIN, XAXIS_MS1_PIN, XAXIS_MS2_PIN, XAXIS_MS3_PIN, XAXIS_VMS1, XAXIS_VMS2, XAXIS_VMS3,
|
||||
XAXIS_MIN_STEPCOUNT, XAXIS_MAX_STEPCOUNT, XAXIS_STEPS_PER_FULL_ROTATION, XAXIS_MICROSTEPPING);
|
||||
StepperModel rotationStepper(YAXIS_DIR_PIN, YAXIS_STEP_PIN, YAXIS_ENABLE_PIN, YAXIS_ENDSTOP_PIN, YAXIS_MS1_PIN, YAXIS_MS2_PIN, YAXIS_MS3_PIN, YAXIS_VMS1, YAXIS_VMS2, YAXIS_VMS3,
|
||||
YAXIS_MIN_STEPCOUNT, YAXIS_MIN_STEPCOUNT, YAXIS_STEPS_PER_FULL_ROTATION, YAXIS_MICROSTEPPING);
|
||||
StepperModel xAxisStepper(
|
||||
XAXIS_DIR_PIN, XAXIS_STEP_PIN, XAXIS_ENABLE_PIN, XAXIS_ENDSTOP_PIN,
|
||||
XAXIS_MS1_PIN, XAXIS_MS2_PIN, XAXIS_MS3_PIN,
|
||||
XAXIS_SLP_PIN, XAXIS_RST_PIN,
|
||||
XAXIS_VMS1, XAXIS_VMS2, XAXIS_VMS3,
|
||||
XAXIS_MIN_STEPCOUNT, XAXIS_MAX_STEPCOUNT,
|
||||
XAXIS_STEPS_PER_FULL_ROTATION, XAXIS_MICROSTEPPING);
|
||||
|
||||
StepperModel rotationStepper(
|
||||
YAXIS_DIR_PIN, YAXIS_STEP_PIN, YAXIS_ENABLE_PIN, YAXIS_ENDSTOP_PIN,
|
||||
YAXIS_MS1_PIN, YAXIS_MS2_PIN, YAXIS_MS3_PIN,
|
||||
YAXIS_SLP_PIN, YAXIS_RST_PIN,
|
||||
YAXIS_VMS1, YAXIS_VMS2, YAXIS_VMS3,
|
||||
YAXIS_MIN_STEPCOUNT, YAXIS_MIN_STEPCOUNT,
|
||||
YAXIS_STEPS_PER_FULL_ROTATION, YAXIS_MICROSTEPPING);
|
||||
|
||||
SoftwareServo servo;
|
||||
boolean servoEnabled=true;
|
||||
@@ -59,6 +70,9 @@ char serial_char; // value for each byte read in from serial comms
|
||||
int serial_count = 0; // current length of command
|
||||
char *strchr_pointer; // just a pointer to find chars in the cmd string like X, Y, Z, E, etc
|
||||
boolean comment_mode = false;
|
||||
|
||||
int next_command_request_counter = 0; //if this counter reaches the maximum then a "ok" is sent to request the nex command
|
||||
int next_command_request_maximum = 1000;
|
||||
// end comm variables
|
||||
|
||||
// GCode States
|
||||
@@ -82,7 +96,7 @@ void setup()
|
||||
|
||||
clear_buffer();
|
||||
|
||||
servo.attach(SERVO_PIN);
|
||||
servo.attach(SERVO_PIN_1);
|
||||
servo.write(DEFAULT_PEN_UP_POSITION);
|
||||
|
||||
if(servoEnabled)
|
||||
@@ -112,13 +126,19 @@ void loop() // input loop, looks for manual input and then checks to see if and
|
||||
get_command(); // check for Gcodes
|
||||
if(servoEnabled)
|
||||
SoftwareServo::refresh();
|
||||
Serial.flush();
|
||||
}
|
||||
|
||||
//--- Interrupt-Routine: Move the steppers
|
||||
void doInterrupt()
|
||||
{
|
||||
{
|
||||
if(isRunning)
|
||||
{
|
||||
if(next_command_request_counter++ > next_command_request_maximum)
|
||||
{
|
||||
//Serial.print("forced ok\n");
|
||||
next_command_request_counter = 0;
|
||||
}
|
||||
if (intervals_remaining-- == 0)
|
||||
isRunning = false;
|
||||
else
|
||||
@@ -199,6 +219,7 @@ void get_command() // gets commands from serial connection and then calls up sub
|
||||
|
||||
if (serial_char == '\n' || serial_char == '\r') // end of a command character
|
||||
{
|
||||
next_command_request_counter = 0;
|
||||
buffer[serial_count]=0;
|
||||
process_commands(buffer, serial_count);
|
||||
clear_buffer();
|
||||
@@ -277,9 +298,11 @@ void process_commands(char command[], int command_length) // deals with standard
|
||||
|
||||
if(!(cs == (int)getcs || hasCS == false)) // if checksum does not match
|
||||
{
|
||||
Serial.print("rs");
|
||||
Serial.print("rs ");
|
||||
Serial.print((int)getcs);
|
||||
//Serial.print((int)nVal);
|
||||
Serial.print("\n");
|
||||
//Serial.flush();
|
||||
}
|
||||
else //continue if checksum matches or none detected
|
||||
{
|
||||
@@ -459,9 +482,11 @@ void process_commands(char command[], int command_length) // deals with standard
|
||||
|
||||
//done processing commands
|
||||
//if (Serial.available() <= 0) {
|
||||
Serial.print("ok");
|
||||
//Serial.println(command);
|
||||
Serial.print("ok ");
|
||||
//Serial.print((int)getcs);
|
||||
Serial.println(command);
|
||||
Serial.print("\n");
|
||||
//Serial.flush();
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,11 @@
|
||||
/*
|
||||
* inEnablePin < 0 => No Endstop
|
||||
*/
|
||||
StepperModel::StepperModel(int inDirPin, int inStepPin, int inEnablePin, int inEndStopPin, int inMs1Pin, int inMs2Pin, int inMs3Pin, bool vms1, bool vms2, bool vms3,
|
||||
StepperModel::StepperModel(
|
||||
int inDirPin, int inStepPin, int inEnablePin, int inEndStopPin,
|
||||
int inMs1Pin, int inMs2Pin, int inMs3Pin,
|
||||
int inSleepPin, int inResetPin,
|
||||
bool vms1, bool vms2, bool vms3,
|
||||
long minSC, long maxSC,
|
||||
double in_kStepsPerRevolution, int in_kMicroStepping)
|
||||
{
|
||||
@@ -33,6 +37,8 @@ StepperModel::StepperModel(int inDirPin, int inStepPin, int inEnablePin, int inE
|
||||
stepPin = inStepPin;
|
||||
enablePin = inEnablePin;
|
||||
endStopPin = inEndStopPin;
|
||||
sleepPin = inSleepPin;
|
||||
resetPin = inResetPin;
|
||||
ms1Pin = inMs1Pin;
|
||||
ms2Pin = inMs2Pin;
|
||||
ms3Pin = inMs3Pin;
|
||||
@@ -43,6 +49,16 @@ StepperModel::StepperModel(int inDirPin, int inStepPin, int inEnablePin, int inE
|
||||
pinMode(dirPin, OUTPUT);
|
||||
pinMode(stepPin, OUTPUT);
|
||||
pinMode(enablePin, OUTPUT);
|
||||
if((sleepPin >=0))
|
||||
{
|
||||
pinMode(sleepPin, OUTPUT);
|
||||
digitalWrite(sleepPin, HIGH);
|
||||
}
|
||||
if((resetPin >=0))
|
||||
{
|
||||
pinMode(resetPin, OUTPUT);
|
||||
digitalWrite(resetPin, HIGH);
|
||||
}
|
||||
if(endStopPin>=0)
|
||||
pinMode(endStopPin, INPUT);
|
||||
if((ms1Pin >=0))
|
||||
|
||||
@@ -28,6 +28,8 @@ private:
|
||||
int dirPin;
|
||||
int stepPin;
|
||||
int enablePin;
|
||||
int sleepPin;
|
||||
int resetPin;
|
||||
int ms1Pin;
|
||||
int ms2Pin;
|
||||
int ms3Pin;
|
||||
@@ -53,7 +55,11 @@ public:
|
||||
volatile long counter;
|
||||
double targetPosition;
|
||||
|
||||
StepperModel(int inDirPin, int inStepPin, int inEnablePin, int inEndStopPin,int inMs1Pin, int inMs2Pin, int inMs3Pin, bool vms1, bool vms2, bool vms3,
|
||||
StepperModel(
|
||||
int inDirPin, int inStepPin, int inEnablePin, int inEndStopPin,
|
||||
int inMs1Pin, int inMs2Pin, int inMs3Pin,
|
||||
int inSleepPin, int inResetPin,
|
||||
bool vms1, bool vms2, bool vms3,
|
||||
long minSC, long maxSC,
|
||||
double in_kStepsPerRevolution, int in_kMicroStepping);
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#define YAXIS_DIR_PIN 14
|
||||
#define YAXIS_STEP_PIN 15
|
||||
#define YAXIS_ENABLE_PIN 21
|
||||
#define YAXIS_RST_PIN -1
|
||||
#define YAXIS_SLP_PIN -1
|
||||
#define YAXIS_MS1_PIN -1
|
||||
#define YAXIS_MS2_PIN -1
|
||||
#define YAXIS_MS3_PIN -1
|
||||
@@ -27,6 +29,8 @@
|
||||
#define XAXIS_DIR_PIN 10
|
||||
#define XAXIS_STEP_PIN 8
|
||||
#define XAXIS_ENABLE_PIN 2
|
||||
#define XAXIS_RST_PIN -1
|
||||
#define XAXIS_SLP_PIN -1
|
||||
#define XAXIS_MS1_PIN -1
|
||||
#define XAXIS_MS2_PIN -1
|
||||
#define XAXIS_MS3_PIN -1
|
||||
@@ -39,7 +43,7 @@
|
||||
#define XAXIS_STEPS_PER_FULL_ROTATION 200.0
|
||||
#define XAXIS_MICROSTEPPING 2
|
||||
|
||||
#define SERVO_PIN 13
|
||||
#define SERVO_PIN_1 13
|
||||
|
||||
/*
|
||||
* Other Configuration
|
||||
|
||||
97
SphereBot Arduino/SphereBot/config_new.h
Normal file
97
SphereBot Arduino/SphereBot/config_new.h
Normal file
@@ -0,0 +1,97 @@
|
||||
//#define BAUDRATE 9600
|
||||
#define BAUDRATE 57600
|
||||
//#define BAUDRATE 115200
|
||||
//#define BAUDRATE 256000
|
||||
|
||||
/*
|
||||
* PINS
|
||||
|
||||
D0 - 0
|
||||
D1 - 1
|
||||
D2 - 2
|
||||
D3 - 3
|
||||
D4 - 4
|
||||
D05 - 5
|
||||
D06 - 6
|
||||
D07 - 7
|
||||
D08 - 8
|
||||
D09 - 9
|
||||
D10 - 10
|
||||
D11 - 11
|
||||
D12 - 12
|
||||
D13 - 13
|
||||
A00 - 14
|
||||
A01 - 15
|
||||
A02 - 16
|
||||
A03 - 17
|
||||
A04 - 18
|
||||
A05 - 19
|
||||
A06 - 20 //no digital pin
|
||||
A07 - 21 //no digital pin
|
||||
|
||||
*/
|
||||
|
||||
// Y-Axis -- Pen
|
||||
#define YAXIS_DIR_PIN 8
|
||||
#define YAXIS_STEP_PIN 9
|
||||
#define YAXIS_ENABLE_PIN 2
|
||||
#define YAXIS_RST_PIN 6
|
||||
#define YAXIS_SLP_PIN 7
|
||||
#define YAXIS_MS1_PIN 3
|
||||
#define YAXIS_MS2_PIN 4
|
||||
#define YAXIS_MS3_PIN 5
|
||||
#define YAXIS_ENDSTOP_PIN -1 // -1 -> No Endstop
|
||||
#define YAXIS_VMS1 LOW
|
||||
#define YAXIS_VMS2 LOW
|
||||
#define YAXIS_VMS3 LOW
|
||||
#define YAXIS_MIN_STEPCOUNT 0 // Travel limits
|
||||
#define YAXIS_MAX_STEPCOUNT 0
|
||||
#define YAXIS_STEPS_PER_FULL_ROTATION 200.0
|
||||
#define YAXIS_MICROSTEPPING 16
|
||||
|
||||
//X-Axis -- Egg
|
||||
#define XAXIS_DIR_PIN 18
|
||||
#define XAXIS_STEP_PIN 17
|
||||
#define XAXIS_ENABLE_PIN 12
|
||||
#define XAXIS_RST_PIN 15
|
||||
#define XAXIS_SLP_PIN 16
|
||||
#define XAXIS_MS1_PIN 11
|
||||
#define XAXIS_MS2_PIN 10
|
||||
#define XAXIS_MS3_PIN 14
|
||||
#define XAXIS_ENDSTOP_PIN -1 // -1 -> No Endstop
|
||||
#define XAXIS_VMS1 LOW
|
||||
#define XAXIS_VMS2 LOW
|
||||
#define XAXIS_VMS3 LOW
|
||||
#define XAXIS_MIN_STEPCOUNT 0 // Travel limits
|
||||
#define XAXIS_MAX_STEPCOUNT 0
|
||||
#define XAXIS_STEPS_PER_FULL_ROTATION 200.0
|
||||
#define XAXIS_MICROSTEPPING 16
|
||||
|
||||
#define SERVO_PIN_1 19
|
||||
#define SERVO_PIN_2 13 //unused -- led on arduino board
|
||||
|
||||
/*
|
||||
* Other Configuration
|
||||
*/
|
||||
|
||||
#define DEFAULT_PEN_UP_POSITION 35
|
||||
|
||||
#define DEFAULT_ZOOM_FACTOR 0.1808 // With a Zoom-Faktor of .65, I can print gcode for Makerbot Unicorn without changes.
|
||||
// The zoom factor can be also manipulated by the propretiary code M402
|
||||
#define X_SCALING_FACTOR 1.65/2 //this factor is for correction to meet the unicorn coordinates
|
||||
#define Y_SCALING_FACTOR 1
|
||||
/*
|
||||
* Microstepping Information
|
||||
*/
|
||||
|
||||
//MS1, MS2 and MS3 are optional. You can also make these settings by hardwiring the pins to high or low
|
||||
|
||||
/* MS1 | MS2 | MS3 Microstepping Resolution
|
||||
-----------------------
|
||||
L | L | L -> Full Step
|
||||
H | L | L -> Half Step
|
||||
L | H | L -> Quarter Step
|
||||
H | H | L -> Eighth Step
|
||||
H | H | H -> Sixteenth Step
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user