Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf4c2c6b64 | ||
|
|
aa35075bd2 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -15,6 +15,8 @@ local.properties
|
|||||||
.classpath
|
.classpath
|
||||||
.settings/
|
.settings/
|
||||||
.loadpath
|
.loadpath
|
||||||
|
.vscode
|
||||||
|
.pio
|
||||||
|
|
||||||
# External tool builders
|
# External tool builders
|
||||||
.externalToolBuilders/
|
.externalToolBuilders/
|
||||||
|
|||||||
71
include/EggDuino.h
Normal file
71
include/EggDuino.h
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
#ifndef EGGDUINO_H
|
||||||
|
#define EGGDUINO_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <Servo.h>
|
||||||
|
#include <avr/eeprom.h>
|
||||||
|
|
||||||
|
#include "AccelStepper.h"
|
||||||
|
#include "SerialCommand.h"
|
||||||
|
#include "button.h"
|
||||||
|
|
||||||
|
// implemented Eggbot-Protocol-Version v13
|
||||||
|
#define initSting "EBBv13_and_above Protocol emulated by Eggduino-Firmware V1.6a"
|
||||||
|
|
||||||
|
// Rotational Stepper
|
||||||
|
#define step1 2
|
||||||
|
#define dir1 5
|
||||||
|
#define enableRotMotor 8
|
||||||
|
#define rotMicrostep 16
|
||||||
|
|
||||||
|
// Pen Stepper
|
||||||
|
#define step2 3
|
||||||
|
#define dir2 6
|
||||||
|
#define enablePenMotor 8
|
||||||
|
#define penMicrostep 16
|
||||||
|
|
||||||
|
#define servoPin 4
|
||||||
|
|
||||||
|
#define penUpPosEEAddress ((uint16_t *)0)
|
||||||
|
#define penDownPosEEAddress ((uint16_t *)2)
|
||||||
|
|
||||||
|
extern AccelStepper rotMotor;
|
||||||
|
extern AccelStepper penMotor;
|
||||||
|
extern Servo penServo;
|
||||||
|
extern SerialCommand SCmd;
|
||||||
|
|
||||||
|
extern int penMin;
|
||||||
|
extern int penMax;
|
||||||
|
extern int penUpPos;
|
||||||
|
extern int penDownPos;
|
||||||
|
extern int servoRateUp;
|
||||||
|
extern int servoRateDown;
|
||||||
|
extern long rotStepError;
|
||||||
|
extern long penStepError;
|
||||||
|
extern int penState;
|
||||||
|
extern uint32_t nodeCount;
|
||||||
|
extern unsigned int layer;
|
||||||
|
extern boolean prgButtonState;
|
||||||
|
extern uint8_t rotStepCorrection;
|
||||||
|
extern uint8_t penStepCorrection;
|
||||||
|
extern float rotSpeed;
|
||||||
|
extern float penSpeed;
|
||||||
|
extern boolean motorsEnabled;
|
||||||
|
|
||||||
|
void makeComInterface();
|
||||||
|
void initHardware();
|
||||||
|
void moveOneStep();
|
||||||
|
void moveToDestination();
|
||||||
|
void sendAck();
|
||||||
|
void sendError();
|
||||||
|
void motorsOff();
|
||||||
|
void motorsOn();
|
||||||
|
void toggleMotors();
|
||||||
|
void doTogglePen();
|
||||||
|
void setprgButtonState();
|
||||||
|
bool parseSMArgs(uint16_t *duration, int *penStepsEBB, int *rotStepsEBB);
|
||||||
|
void prepareMove(uint16_t duration, int penStepsEBB, int rotStepsEBB);
|
||||||
|
void storePenUpPosInEE();
|
||||||
|
void storePenDownPosInEE();
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -267,7 +267,7 @@ public:
|
|||||||
DRIVER = 1, ///< Stepper Driver, 2 driver pins required
|
DRIVER = 1, ///< Stepper Driver, 2 driver pins required
|
||||||
FULL2WIRE = 2, ///< 2 wire stepper, 2 motor pins required
|
FULL2WIRE = 2, ///< 2 wire stepper, 2 motor pins required
|
||||||
FULL3WIRE = 3, ///< 3 wire stepper, such as HDD spindle, 3 motor pins required
|
FULL3WIRE = 3, ///< 3 wire stepper, such as HDD spindle, 3 motor pins required
|
||||||
FULL4WIRE = 4, ///< 4 wire full stepper, 4 motor pins required
|
FULL4WIRE = 4, ///< 4 wire full stepper, 4 motor pins required
|
||||||
HALF3WIRE = 6, ///< 3 wire half stepper, such as HDD spindle, 3 motor pins required
|
HALF3WIRE = 6, ///< 3 wire half stepper, such as HDD spindle, 3 motor pins required
|
||||||
HALF4WIRE = 8 ///< 4 wire half stepper, 4 motor pins required
|
HALF4WIRE = 8 ///< 4 wire half stepper, 4 motor pins required
|
||||||
} MotorInterfaceType;
|
} MotorInterfaceType;
|
||||||
18
platformio.ini
Normal file
18
platformio.ini
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
; PlatformIO Project Configuration File
|
||||||
|
;
|
||||||
|
; Build options: build flags, source filter
|
||||||
|
; Upload options: custom upload port, speed and extra flags
|
||||||
|
; Library options: dependencies, extra library storages
|
||||||
|
; Advanced options: extra scripting
|
||||||
|
;
|
||||||
|
; Please visit documentation for the other options and examples
|
||||||
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
|
[env:uno]
|
||||||
|
platform = atmelavr
|
||||||
|
board = uno
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 9600
|
||||||
|
upload_speed = 115200
|
||||||
|
upload_port= COM3
|
||||||
|
lib_deps = arduino-libraries/Servo@^1.3.0
|
||||||
@@ -1,23 +1,5 @@
|
|||||||
|
#include "EggDuino.h"
|
||||||
|
|
||||||
void makeComInterface(){
|
|
||||||
SCmd.addCommand("v",sendVersion);
|
|
||||||
SCmd.addCommand("EM",enableMotors);
|
|
||||||
SCmd.addCommand("SC",stepperModeConfigure);
|
|
||||||
SCmd.addCommand("SP",setPen);
|
|
||||||
SCmd.addCommand("SM",stepperMove);
|
|
||||||
SCmd.addCommand("SE",ignore);
|
|
||||||
SCmd.addCommand("TP",togglePen);
|
|
||||||
SCmd.addCommand("PO",ignore); //Engraver command, not implemented, gives fake answer
|
|
||||||
SCmd.addCommand("NI",nodeCountIncrement);
|
|
||||||
SCmd.addCommand("ND",nodeCountDecrement);
|
|
||||||
SCmd.addCommand("SN",setNodeCount);
|
|
||||||
SCmd.addCommand("QN",queryNodeCount);
|
|
||||||
SCmd.addCommand("SL",setLayer);
|
|
||||||
SCmd.addCommand("QL",queryLayer);
|
|
||||||
SCmd.addCommand("QP",queryPen);
|
|
||||||
SCmd.addCommand("QB",queryButton); //"PRG" Button,
|
|
||||||
SCmd.setDefaultHandler(unrecognized); // Handler for command that isn't matched (says "What?")
|
|
||||||
}
|
|
||||||
|
|
||||||
void queryPen() {
|
void queryPen() {
|
||||||
char state;
|
char state;
|
||||||
@@ -262,3 +244,23 @@ void unrecognized(const char *command){
|
|||||||
void ignore(){
|
void ignore(){
|
||||||
sendAck();
|
sendAck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void makeComInterface(){
|
||||||
|
SCmd.addCommand("v",sendVersion);
|
||||||
|
SCmd.addCommand("EM",enableMotors);
|
||||||
|
SCmd.addCommand("SC",stepperModeConfigure);
|
||||||
|
SCmd.addCommand("SP",setPen);
|
||||||
|
SCmd.addCommand("SM",stepperMove);
|
||||||
|
SCmd.addCommand("SE",ignore);
|
||||||
|
SCmd.addCommand("TP",togglePen);
|
||||||
|
SCmd.addCommand("PO",ignore); //Engraver command, not implemented, gives fake answer
|
||||||
|
SCmd.addCommand("NI",nodeCountIncrement);
|
||||||
|
SCmd.addCommand("ND",nodeCountDecrement);
|
||||||
|
SCmd.addCommand("SN",setNodeCount);
|
||||||
|
SCmd.addCommand("QN",queryNodeCount);
|
||||||
|
SCmd.addCommand("SL",setLayer);
|
||||||
|
SCmd.addCommand("QL",queryLayer);
|
||||||
|
SCmd.addCommand("QP",queryPen);
|
||||||
|
SCmd.addCommand("QB",queryButton); //"PRG" Button,
|
||||||
|
SCmd.setDefaultHandler(unrecognized); // Handler for command that isn't matched (says "What?")
|
||||||
|
}
|
||||||
@@ -1,3 +1,11 @@
|
|||||||
|
#include "EggDuino.h"
|
||||||
|
|
||||||
|
inline void loadPenPosFromEE() {
|
||||||
|
penUpPos = eeprom_read_word(penUpPosEEAddress);
|
||||||
|
penDownPos = eeprom_read_word(penDownPosEEAddress);
|
||||||
|
penState = penUpPos;
|
||||||
|
}
|
||||||
|
|
||||||
void initHardware(){
|
void initHardware(){
|
||||||
// enable eeprom wait in avr/eeprom.h functions
|
// enable eeprom wait in avr/eeprom.h functions
|
||||||
SPMCSR &= ~SELFPRGEN;
|
SPMCSR &= ~SELFPRGEN;
|
||||||
@@ -16,25 +24,21 @@ void initHardware(){
|
|||||||
penServo.write(penState);
|
penServo.write(penState);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void loadPenPosFromEE() {
|
|
||||||
penUpPos = eeprom_read_word(penUpPosEEAddress);
|
|
||||||
penDownPos = eeprom_read_word(penDownPosEEAddress);
|
|
||||||
penState = penUpPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void storePenUpPosInEE() {
|
|
||||||
|
void storePenUpPosInEE() {
|
||||||
eeprom_update_word(penUpPosEEAddress, penUpPos);
|
eeprom_update_word(penUpPosEEAddress, penUpPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void storePenDownPosInEE() {
|
void storePenDownPosInEE() {
|
||||||
eeprom_update_word(penDownPosEEAddress, penDownPos);
|
eeprom_update_word(penDownPosEEAddress, penDownPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void sendAck(){
|
void sendAck(){
|
||||||
Serial.print("OK\r\n");
|
Serial.print("OK\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void sendError(){
|
void sendError(){
|
||||||
Serial.print("unknown CMD\r\n");
|
Serial.print("unknown CMD\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,25 +19,7 @@
|
|||||||
2 implement homing sequence via microswitch or optical device
|
2 implement homing sequence via microswitch or optical device
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AccelStepper.h" // nice lib from http://www.airspayce.com/mikem/arduino/AccelStepper/
|
#include "EggDuino.h"
|
||||||
#include <Servo.h>
|
|
||||||
#include "SerialCommand.h" //nice lib from Stefan Rado, https://github.com/kroimon/Arduino-SerialCommand
|
|
||||||
#include <avr/eeprom.h>
|
|
||||||
#include "button.h"
|
|
||||||
|
|
||||||
#define initSting "EBBv13_and_above Protocol emulated by Eggduino-Firmware V1.6a"
|
|
||||||
//Rotational Stepper:
|
|
||||||
#define step1 11
|
|
||||||
#define dir1 10
|
|
||||||
#define enableRotMotor 9
|
|
||||||
#define rotMicrostep 16 //MicrostepMode, only 1,2,4,8,16 allowed, because of Integer-Math in this Sketch
|
|
||||||
//Pen Stepper:
|
|
||||||
#define step2 8
|
|
||||||
#define dir2 7
|
|
||||||
#define enablePenMotor 6
|
|
||||||
#define penMicrostep 16 //MicrostepMode, only 1,2,4,8,16 allowed, because of Integer-Math in this Sketch
|
|
||||||
|
|
||||||
#define servoPin 3 //Servo
|
|
||||||
|
|
||||||
// EXTRAFEATURES - UNCOMMENT TO USE THEM -------------------------------------------------------------------
|
// EXTRAFEATURES - UNCOMMENT TO USE THEM -------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -47,12 +29,9 @@
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#define penUpPosEEAddress ((uint16_t *)0)
|
|
||||||
#define penDownPosEEAddress ((uint16_t *)2)
|
|
||||||
|
|
||||||
//make Objects
|
//make Objects
|
||||||
AccelStepper rotMotor(1, step1, dir1);
|
AccelStepper rotMotor(AccelStepper::DRIVER, step1, dir1);
|
||||||
AccelStepper penMotor(1, step2, dir2);
|
AccelStepper penMotor(AccelStepper::DRIVER, step2, dir2);
|
||||||
Servo penServo;
|
Servo penServo;
|
||||||
SerialCommand SCmd;
|
SerialCommand SCmd;
|
||||||
//create Buttons
|
//create Buttons
|
||||||
@@ -91,10 +70,13 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
moveOneStep();
|
|
||||||
|
|
||||||
|
|
||||||
|
moveOneStep();
|
||||||
SCmd.readSerial();
|
SCmd.readSerial();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef penToggleButton
|
#ifdef penToggleButton
|
||||||
penToggle.check();
|
penToggle.check();
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user