-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvfd2mb.comp
More file actions
30 lines (23 loc) · 1 KB
/
Copy pathvfd2mb.comp
File metadata and controls
30 lines (23 loc) · 1 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
component vfd2mb "exchange HAL pins for mb2hal values, Fuling DZB300 series VFD";
pin in float RpmIn "RPM set value, in";
pin out float percOut "percent out, X 100";
pin in bit SpindFwd "send spindle into a forward tizzy";
pin in bit SpindRev "send spindle into a reverse tizzy";
pin out float cmdOut "VFD command instruction out";
/*pin in float vfdRunningFreq "VFD Running Frequency";
pin in float vfdRunningCurr "VFD Running Current";
pin in float vfdRunningVolt "VFD Running Volts";
pin in float vfdRunningTor "VFD Running Torque";*/
function _;
license "GPL";
author "Travis Farmer";
;;
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(_) {
percOut = (int)map(RpmIn,0.00,24000.00,0,10000);
if (SpindFwd == true && SpindRev == false) { cmdOut = 1;}
else if (SpindFwd == false && SpindRev == true) { cmdOut = 2;}
else if (SpindFwd == false && SpindRev == false) { cmdOut = 5;}
}