Update to Verisonn 1.2
complete rework of Move-Algorithm, no position errors any more, complete in integer math //it was the hell to debug it... ;-) optimized timing of Ack-Answer added command QP "Query Pen", untested, answer might be wrong 0 <--> 1? optimized Init-String for EBBv13 optimized some variable types to enhance memory performance changed enablePenMotor to 6 by default to match it to Spherebot Electronics changed default maxSpeeds from 1000 to 2000;
This commit is contained in:
34
EggDuino.ino
34
EggDuino.ino
@@ -6,34 +6,35 @@ Thanks to my wife and my daughter for their patience. :-)
|
||||
|
||||
*/
|
||||
|
||||
// implemented Eggbot-Protocol-Version 2.1.0
|
||||
// EBB-Command-Referenc, I sourced from: http://www.schmalzhaus.com/EBB/EBBCommands.html
|
||||
// implemented Eggbot-Protocol-Version v13
|
||||
// EBB-Command-Reference, I sourced from: http://www.schmalzhaus.com/EBB/EBBCommands.html
|
||||
// no homing sequence, switch-on position of pen will be taken as reference point.
|
||||
// No collision-detection!!
|
||||
// Supported Servos: I do not know, I use Arduino Servo Lib with TG9e- standard servo.
|
||||
// Note: Maximum-Speed in Inkscape is 1000 Steps/s. You could enter more, but then Pythonscript sends nonsense.
|
||||
// EBB-Coordinates are coming in for 16th-Microstepmode. The Coordinate-Transforms are done in weired integer-math. Be careful, when you diecide to modify settings.
|
||||
|
||||
/* TODOs:
|
||||
1 collision control via penMin/penMax
|
||||
2 implement homing sequence via microswitch or optical device
|
||||
3 implement hardware-button , EGGBOT-Guys call it "PRG-Button"
|
||||
4 Replace Stepper Control ACCELSTEPPER --> DDS, interruptbased control to improve step-precision and smoothness.
|
||||
*/
|
||||
|
||||
#include "AccelStepper.h" // nice lib from http://www.airspayce.com/mikem/arduino/AccelStepper/
|
||||
#include "AccelStepper.h"
|
||||
//#include "libs\AccelStepper.h" // nice lib from http://www.airspayce.com/mikem/arduino/AccelStepper/
|
||||
#include <Servo.h>
|
||||
#include "SerialCommand.h" //nice lib from Stefan Rado, https://github.com/kroimon/Arduino-SerialCommand
|
||||
|
||||
#define initSting "EBB 2.1.0+ Protocol emulated by Eggduino-Firmware V1.1"
|
||||
#define initSting "EBBv13_and_above Protocol emulated by Eggduino-Firmware V1.2"
|
||||
//Rotational Stepper
|
||||
#define step1 11
|
||||
#define dir1 10
|
||||
#define enableRotMotor 9
|
||||
#define rotMicrostep 8
|
||||
#define rotMicrostep 8 //only 1,2,4,8,16 allowed, because of Integer-Math in this Sketch
|
||||
//Pen Stepper
|
||||
#define step2 8
|
||||
#define dir2 7
|
||||
#define enablePenMotor 5
|
||||
#define penMicrostep 8
|
||||
#define enablePenMotor 6
|
||||
#define penMicrostep 8 //only 1,2,4,8,16 allowed, because of Integer-Math in this Sketch
|
||||
//Servo
|
||||
#define servoPin 3
|
||||
|
||||
@@ -42,19 +43,26 @@ Thanks to my wife and my daughter for their patience. :-)
|
||||
AccelStepper penMotor(1, step2, dir2);
|
||||
Servo penServo;
|
||||
SerialCommand SCmd;
|
||||
// Variables
|
||||
|
||||
// Variables... be careful, by messing around here, evrything has a reason and crossrelations...
|
||||
int penMin=0;
|
||||
int penMax=0;
|
||||
int penUpPos=5; //can be overwritten from EBB-Command SC
|
||||
int penDownPos=30; //can be overwritten from EBB-Command SC
|
||||
int servoRateUp=0; //from EBB-Protocol not implemented on machine-side
|
||||
int servoRateDown=0;//from EBB-Protocol not implemented on machine-side
|
||||
float rotStepMode=16; //1/16 by default, can be changed by EBB protocol, used as correction factor
|
||||
float penStepMode=16; //1/16 by default, can be changed by EBB protocol, used as correction factor
|
||||
uint8_t rotStepMode=16; //1/16 by default, can be changed by EBB protocol, used as correction factor
|
||||
uint8_t penStepMode=16; //1/16 by default, can be changed by EBB protocol, used as correction factor
|
||||
long rotStepError=0;
|
||||
long penStepError=0;
|
||||
int penState=penUpPos;
|
||||
uint32_t nodeCount=0;
|
||||
unsigned int layer=0;
|
||||
boolean prgButtonState=0;
|
||||
int prgButtonState=0;
|
||||
uint8_t rotStepCorrection = rotStepMode/rotMicrostep ; //devide EBB-Coordinates by this factor to get EGGduino-Steps
|
||||
uint8_t penStepCorrection = penStepMode/penMicrostep ; //devide EBB-Coordinates by this factor to get EGGduino-Steps
|
||||
float rotSpeed=0;
|
||||
float penSpeed=0; // these are local variables for Function SteppermotorMove-Command, but for performance-reasons it will be initialized here
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
Reference in New Issue
Block a user