-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLaserAnalog.comp
More file actions
33 lines (27 loc) · 1.22 KB
/
Copy pathLaserAnalog.comp
File metadata and controls
33 lines (27 loc) · 1.22 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
component LaserAnalog "convert analog values for Laser 0-10v out";
pin in float SpindleIn "Spindle set value 0.00-1000.00, in";
pin out float FloatOut "Laser 0-10v value, out";
pin out u32 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 SpindleEnable "Spindle enable pin, in";
pin in float LaserIn "float in from motion.analog-in-NN, in";
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(_) {
if (LaserOnSigIn == true) {
FloatOut = map(LaserIn,0.000,1.000,0.000,10.000);
} else {
FloatOut = map(SpindleIn,0.000,1000.000,0.000,10.000);
}
PercentOut = (unsigned long) map(FloatOut,0.00,10.00,0.00,100.00);
if (DoorInterlockIn == true && ProgIsPausedIn == false && (LaserOnSigIn == true || SpindleEnable == true)) {LaserEnableOut = true;}
else {LaserEnableOut = false;}
}