-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLaserAnalog.comp
27 lines (21 loc) · 979 Bytes
/
LaserAnalog.comp
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
component LaserAnalog "convert analog values for Laser 0-10v out";
pin in float LaserIn "Laser set value 0.00-1.00, in";
pin out float FloatOut "Laser 0-10v value, out";
pin out float PercentOut "Laser 0-100% value, out";
pin out bit LaserEnableOut "Laser Enable Relay, out";
pin in bit ProgIsPausedIn "halui.program.is-paused connection";
pin in bit LaserOnSigIn "signal from motion.digital-out-NN to turn on laser";
pin in bit DoorInterlockIn "signal from door interlock latch switch";
function _;
license "GPL";
author "Travis Farmer";
;;
double map(double x, double in_min, double in_max, double out_min, double out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
FUNCTION(_) {
FloatOut = map(LaserIn,0.000,1.000,0.000,10.000);
PercentOut = map(FloatOut,0.00,10.00,0.00,100.00);
if (DoorInterlockIn == true && ProgIsPausedIn == false && LaserOnSigIn == true) {LaserEnableOut = true;}
else {LaserEnableOut = false;}
}