-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTowerCraneControl.ino
72 lines (62 loc) · 1.7 KB
/
TowerCraneControl.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
#include "InputController.h"
#include "StepMotorControl.h"
#include "CommandTransceiver.h"
StepMotorControl winchMotor;
InputController winchInput;
StepMotorControl trolleyMotor;
InputController trolleyInput;
StepMotorControl rotatorMotor;
InputController rotatorInput;
void setup()
{
CommandTransceiver.init();
winchMotor.init(0, 2);
winchMotor.setMotorHeadPins(5, 4, 3);
winchInput.init();
byte winchButtonPins[] = { 28, 29 };
winchInput.initButtons(winchButtonPins, 2);
byte winchLightBarrierPins[] = { 38 };
winchInput.initLightBarriers(winchLightBarrierPins, 1);
trolleyMotor.init(1, 3);
trolleyMotor.setMotorHeadPins(16, 15, 14);
trolleyInput.init();
byte trolleyButtonPins[] = { 30, 31 };
trolleyInput.initButtons(trolleyButtonPins, 2);
byte trolleyLightBarrierPins[] = { 41, 39 };
trolleyInput.initLightBarriers(trolleyLightBarrierPins, 2);
rotatorMotor.init(2, 10);
rotatorMotor.setMotorHeadPins(46, 45, 44);
rotatorInput.init();
byte rotatorButtonPins[] = { 32, 33 };
rotatorInput.initButtons(rotatorButtonPins, 2);
byte rotatorLightBarrierPins[] = { 40 };
rotatorInput.initLightBarriers(rotatorLightBarrierPins, 1);
}
void loop()
{
CommandTransceiver.update();
updateWinch();
updateTrolley();
updateRotator();
}
void updateWinch()
{
winchInput.update();
winchMotor.update(winchInput.getInput());
}
void updateTrolley()
{
trolleyInput.update();
trolleyMotor.update(trolleyInput.getInput());
}
void updateRotator()
{
// Lichtschranke soll nur bei einer Kalibrierung auf diesen Motor angewendet werden, ansonsten LB-Bit auf Null
rotatorInput.update();
byte input = rotatorInput.getInput();
if (!CommandTransceiver.isCalibrating())
{
input &= ~(1 << 5);
}
rotatorMotor.update(input);
}