-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValveDA.java
More file actions
100 lines (84 loc) · 2.47 KB
/
Copy pathValveDA.java
File metadata and controls
100 lines (84 loc) · 2.47 KB
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
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Solenoid;
/**
* Interface class for Double Action pneumatic valve.
* Double action is a sliding valve. Calling open applies power to the open side momentarily causing
* the valve to move to the open position. Power is then turned off and the valve
* stays where it is (open). Calling close applies power to the close side momentarily causing the
* valve to move to the closed position. Power is then turned off and the valve
* stays where it is (closed).
*
* Open and Close are arbitrary definitions, they are actually defined by the physical robot
* valve piping/wiring and what you want the cylinder to do. Typically you would pipe the "open" side
* of the valve to extend a cylinder and close to retract. For DA valves, the convention is to wire
* the A side to the first port and pipe to open or extend the cylinder and B side to close or retract.
* Again, these are conventions and the reality is what you design your valve to cylinder piping to be
* and the wiring to the corresponding sides of the valve to the PCM ports.
*/
public class ValveDA
{
private final Solenoid valveOpenSide, valveCloseSide;
public double solenoidSlideTime;
/**
* @param port PCM port wired to open/A side of valve. Close/B side is wired to PCM next port.
* Assumes PCM CAN Id 0.
*/
public ValveDA(int port)
{
valveOpenSide = new Solenoid(port);
valveCloseSide = new Solenoid(port + 1);
solenoidSlideTime = .05;
}
/**
* @param pcmCanId PCM CAN Id number.
* @param port PCM port wired to open/A side of valve. Close/B side is wired to PCM next port.
*/
public ValveDA(int pcmCanId, int port)
{
valveOpenSide = new Solenoid(pcmCanId, port);
valveCloseSide = new Solenoid(pcmCanId, port + 1);
solenoidSlideTime = .05;
}
/**
* Release resources.
*/
public void dispose()
{
valveOpenSide.free();
valveCloseSide.free();
}
/**
* Open the valve (pressurize port).
*/
public void Open()
{
valveCloseSide.set(false);
valveOpenSide.set(true);
Timer.delay(solenoidSlideTime);
valveOpenSide.set(false);
}
/**
* Pressurize the A side of the valve.
*/
public void SetA()
{
Open();
}
/**
* Close the valve (pressurize port+1).
*/
public void Close()
{
valveOpenSide.set(false);
valveCloseSide.set(true);
Timer.delay(solenoidSlideTime);
valveCloseSide.set(false);
}
/**
* Pressurize the B side of the valve.
*/
public void SetB()
{
Close();
}
}