-
Notifications
You must be signed in to change notification settings - Fork 0
/
Duella.ino
187 lines (134 loc) · 5.3 KB
/
Duella.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
Uncia firmware, partially based on Sedgwick firmware.
Allows for stock printers to connect to the eUNCIA driver in Creation Workshop,
and also allows for modified printers to function. This firmware will automatically
tell the eUNCIA driver if it is stock or modified, and the eUNCIA driver will send
commands accordingly.
****All normal user changes should be limited to "Configuration.h" and "Pins.h"****
The MIT License (MIT)
Copyright (c) 2014 Brandon Pomeroy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
//*****************************//
//Includes
//*****************************//
// #include "Arduino.h"
#include <Stepper.h> //We'll use this for upgraded stepper control
#include <Servo.h> //We'll use this if an aperture is ever implemented.
//Firmware Configuration
#include "Configuration.h"
//Pin Definitions
#include "Pins.h"
//Control classes
#include "MotionController.h"
#include "DuellaSerial.h"
#include "GcodeParser.h"
//*****************************//
//Global Variables
//*****************************//
MotionController motionControl;
DuellaSerial duellaSerial;
GcodeParser gcodeParser;
//*****************************//
//Public Variables
//*****************************//
float stepsPerMM[] = STEPS_PER_MM;
float defaultFeedrate[] = DEFAULT_FEEDRATE;
float homingFeedrate[] = HOMING_FEEDRATE;
void setup()
{
//*****************************//
//Setting the pin modes
//*****************************//
pinMode(IO_LED, OUTPUT);
//Z Motor Pins
pinMode(Z_STEPPER_DISABLE, OUTPUT);
pinMode(Z_STEPPER_STEP, OUTPUT);
pinMode(Z_STEPPER_DIRECTION, OUTPUT);
pinMode(Z_STEPPER_SLEEP, OUTPUT);
pinMode(Z_STEPPER_RESET, OUTPUT);
//X Motor Pins
#ifdef WIPER_AXIS_STEPPER
pinMode(X_STEPPER_DISABLE, OUTPUT);
pinMode(X_STEPPER_STEP, OUTPUT);
pinMode(X_STEPPER_DIRECTION, OUTPUT);
pinMode(X_STEPPER_SLEEP, OUTPUT);
pinMode(X_STEPPER_RESET, OUTPUT);
#endif
//Y motor Pins
#ifdef Y_AXIS_STEPPER
pinMode(Y_STEPPER_DISABLE, OUTPUT);
pinMode(Y_STEPPER_STEP, OUTPUT);
pinMode(Y_STEPPER_DIRECTION, OUTPUT);
pinMode(Y_STEPPER_SLEEP, OUTPUT);
pinMode(Y_STEPPER_RESET, OUTPUT);
#endif
#ifdef Z_PRINT_LEVEL_ENDSTOP
pinMode(Z_PRINT_ENDSTOP_PIN, INPUT_PULLUP);
delayMicroseconds(10);
#endif
#ifdef Y_AXIS_ENDSTOP
pinMode(Y_AXIS_ENDSTOP_PIN, INPUT_PULLUP);
delayMicroseconds(10);
#endif
#ifdef WIPER_AXIS_ENDSTOP
pinMode(WIPER_AXIS_ENDSTOP_PIN, INPUT_PULLUP);
delayMicroseconds(10);
#endif
//*****************************//
//Setting each pin to its respective I/O state
//*****************************//
digitalWrite(IO_LED, 1); //Power on the Teensy status LED
digitalWrite(Z_STEPPER_DISABLE, 1); //Keep stepper disabled when we first start up
digitalWrite(Z_STEPPER_STEP, 0);
digitalWrite(Z_STEPPER_DIRECTION, 0);
digitalWrite(Z_STEPPER_SLEEP, 1); //The SLEEP and RESET pins are logic-inverted.
digitalWrite(Z_STEPPER_RESET, 1); //Keeping these pins HIGH does the opposite of what they say.
#ifdef WIPER_AXIS_STEPPER
digitalWrite(X_STEPPER_DISABLE, 1); //Keep stepper disabled when we first start up
digitalWrite(X_STEPPER_STEP, 0);
digitalWrite(X_STEPPER_DIRECTION, 0);
digitalWrite(X_STEPPER_SLEEP, 1); //The SLEEP and RESET pins are logic-inverted.
digitalWrite(X_STEPPER_RESET, 1); //Keeping these pins HIGH does the opposite of what they say.
#endif
#ifdef Y_AXIS_STEPPER
digitalWrite(Y_STEPPER_DISABLE, 1); //Keep stepper disabled when we first start up
digitalWrite(Y_STEPPER_STEP, 0);
digitalWrite(Y_STEPPER_DIRECTION, 0);
digitalWrite(Y_STEPPER_SLEEP, 1); //The SLEEP and RESET pins are logic-inverted.
digitalWrite(Y_STEPPER_RESET, 1); //Keeping these pins HIGH does the opposite of what they say.
#endif
//*****************************//
//Setting up MotionController
//*****************************//
#ifdef IO_APERTURE_SERVO
motionControl.attachServo();
#endif
motionControl.giveGcodeParser( gcodeParser );
motionControl.setFeedrate(defaultFeedrate);
motionControl.setAxisSteps(stepsPerMM);
//*****************************//
//Setting up DuellaSerial
//*****************************//
duellaSerial.begin();
duellaSerial.giveMotionControl(motionControl);
}
void loop()
{
duellaSerial.CreationWorkshopSerialPing();
duellaSerial.read();
}