-
Notifications
You must be signed in to change notification settings - Fork 68
/
voidsController.ino
83 lines (78 loc) · 2.46 KB
/
voidsController.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
// Deposit new powder layer
void newLayer(){
// In case the X is not at zero
// Move bin up to top
jogZ2(-jogStepZ);
stepperX.runToNewPosition(0);
// Lower the powder bin to prevent powder from scooping
jogZ1(2*jogStepZ);
//Jog Y to the end of the powder bin
stepperY.runToNewPosition(-build_piston_end_stop);
// And move the powder bin back again
jogZ1(-2*jogStepZ);
// Move both pistons simultaniously
jogZ(stepZ);
// Spread the powder over the piston, roller rotate with constant spee
stepperY.moveTo(0);
// Let the roller rotate untill
while (stepperY.currentPosition() != 0){
stepperR.runSpeed();
stepperY.run();
}
// Move piston down to prevent scewing
jogZ2(jogStepZ);
// Return carriage to starting position
homeXY();
}
// Reset the positions of the steppers. This acts as a margin
// for the printer, making it possible to fill the pistons with
// powder and stopping the
void resetStepperPositions(){
stepperX.setCurrentPosition(0);
stepperY.setCurrentPosition(-distance_roller_nozzle);
stepperZ1.setCurrentPosition(0);
stepperZ2.setCurrentPosition(0);
Serial.println("Stepper counters reset");
}
void homeXY(){
// Return the XY-carriage to 0,0
stepperX.moveTo(0);
stepperY.moveTo(-distance_roller_nozzle);
while (stepperY.currentPosition() != -distance_roller_nozzle || stepperX.currentPosition() != 0) {
stepperX.run();
stepperY.run();
}
Serial.println("Carriage homing");
}
void spray_ink( byte lower_nozzles, byte upper_nozzles) {
//lower_nozzles = 1-8 - PORTA
for(int i = 0; i <= 7; i++){
byte mask = 1<<i;
if(lower_nozzles & mask){
PORTA |= mask; delayMicroseconds(5);
PORTA &= ~mask; delayMicroseconds(1);
}
}
//upper_nozzles = 9-12 - PORTC using pins 4,5,6,7 so 4-7 not 0-3
for(int i = 4; i <= 7; i++){
byte mask = 1<<i;
if(upper_nozzles<<3 & mask){
PORTC |= mask; delayMicroseconds(5);
PORTC &= ~mask; delayMicroseconds(1);
}
}
//wait to be sure we don't try to fire nozzles to fast and burn them out
delayMicroseconds(450);
}
void abortPrint() {
PORTA = B00000000;
PORTC = B00000000;
digitalWrite(21, LOW);
Serial.println("Printing aborted");
delay(1000);
Serial.println("Please disconnect power and reset Arduino");
// Hence breaking all the loops would demand for a couple of extra statements, it's
// eassier and less resource demanding to put the Arduino controller in a infinite loop
while(1) {
}
}