-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathload_conv.comp
More file actions
38 lines (33 loc) · 1.05 KB
/
Copy pathload_conv.comp
File metadata and controls
38 lines (33 loc) · 1.05 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
/*
loadrt load_conv
addf load_conv.0 servo-thread
net spindle_curret load-conv.0.amps <= vfdmod.current.out
net spindle_load qtpyvcp.spindle-load-indicator.in-f <= load-conv.0.load
setp load-conv.0.maxamps 10.7
*/
component load_conv "calculates percentage of load based on motor Amps";
pin in bit SpindleActive "True when spindle is running, in";
pin in float DblCurVolts "Double rated VFD power, 0-10v, in";
pin out float load "Percent load out, out";
pin in float maxpower "Max Motor Power, in";
pin out float hp "HP from power, out";
pin out float powerKW "Power in KW, out";
function _;
license "GPL";
author "Travis Farmer";
;;
#include <rtapi_math.h>
float map(float x, float in_min, float in_max, float out_min, float out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
FUNCTION(_) {
if (SpindleActive != true) {
powerKW = ((map(DblCurVolts,0.00,10.00,0.00,46.00) * 220)/1000);
load = round(powerKW/(maxpower/100.0));
hp = (powerKW * 1.34102);
} else {
powerKW = 0.00;
load = 0.00;
hp = 0.00;
}
}