Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
documents:de4000:de4000script [2022/01/25 15:53] twebster [5.2 Master Control Script] |
documents:de4000:de4000script [2022/01/25 16:22] (current) twebster |
||
---|---|---|---|
Line 59: | Line 59: | ||
**Example: | **Example: | ||
- | < | + | < |
local suction = get_channel_val(1, | local suction = get_channel_val(1, | ||
local discharge1 = get_channel_val(1, | local discharge1 = get_channel_val(1, | ||
Line 94: | Line 94: | ||
{{: | {{: | ||
- | < | + | < |
defaultModbus() | defaultModbus() | ||
set_modbus(300, | set_modbus(300, | ||
Line 401: | Line 401: | ||
recycleCtrl = true | recycleCtrl = true | ||
end | end | ||
- | --if recycleCtrl and spSuctType == " | + | |
- | -- recycleSuctionRev = true | + | |
- | --end | + | |
- | --if recycleCtrl and spDischType == " | + | |
- | -- recycleDischargeRev = true | + | |
- | --end | + | |
- | --print(" | + | |
- | --local suct = 500 | + | |
local dischPct = 100 | local dischPct = 100 | ||
local suctPct = 100 | local suctPct = 100 | ||
Line 513: | Line 506: | ||
end | end | ||
- | | + | |
- | + | ||
- | + | ||
- | + | ||
local minOutput = 100 | local minOutput = 100 | ||
local winning = 0 | local winning = 0 | ||
Line 576: | Line 565: | ||
end | end | ||
end | end | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | --[[ | ||
- | local idleSpeed = get_gbl(" | ||
- | local lowSpeed = get_gbl(" | ||
- | local highSpeed = get_gbl(" | ||
- | local speedPct = 0 | ||
- | |||
- | if st > highSpeed then st = highSpeed end | ||
- | if st < lowSpeed then st = lowSpeed end | ||
- | if get_state() ~= 8 then | ||
- | --st = idleSpeed | ||
- | end | ||
- | set_sVirt(" | ||
- | speedPct = (st - lowSpeed) /(highSpeed - lowSpeed) * 100 | ||
- | if speedPct < 0 then speedPct = 0 end | ||
- | if speedPct > 100 then speedPct = 100 end | ||
- | st = speedPct | ||
- | |||
- | if idleSpeed < lowSpeed then | ||
- | local speedRpm = speedPct / 100 * (highSpeed - lowSpeed) + lowSpeed | ||
- | st = (speedRpm - idleSpeed) / (highSpeed - idleSpeed) * 100 | ||
- | --st = (st - idleSpeed) / (highSpeed - idleSpeed) * 100 | ||
- | end | ||
- | ]]-- | ||
- | |||
- | |||
--if manMode == 1 and get_state() == 8 then | --if manMode == 1 and get_state() == 8 then | ||
Line 661: | Line 619: | ||
end | end | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | --speedTarget = get_sGbl(" | ||
if manSpeed < lowSpeed then | if manSpeed < lowSpeed then | ||
manSpeed = lowSpeed | manSpeed = lowSpeed | ||
Line 684: | Line 636: | ||
local output2 = 0 | local output2 = 0 | ||
if spSuctType == " | if spSuctType == " | ||
- | --Map minOutput to output1 | ||
output1 = map_range(outputLow, | output1 = map_range(outputLow, | ||
set_sVirt(" | set_sVirt(" | ||
- | --Map minOutput to ourput2 | ||
output2 = map_range(outputLow2, | output2 = map_range(outputLow2, | ||
set_sVirt(" | set_sVirt(" | ||
Line 694: | Line 644: | ||
if hasRPM then | if hasRPM then | ||
local speedRpm = output1 / 100 * (highSpeed - lowSpeed) + lowSpeed | local speedRpm = output1 / 100 * (highSpeed - lowSpeed) + lowSpeed | ||
- | --set_ao_val(outputTerm, | ||
speedTarget = (speedRpm - idleSpeed) / (maxSpeed - idleSpeed) * 100 | speedTarget = (speedRpm - idleSpeed) / (maxSpeed - idleSpeed) * 100 | ||
else | else | ||
- | --set_ao_val(outputTerm, | ||
speedTarget = output1 | speedTarget = output1 | ||
end | end | ||
Line 712: | Line 660: | ||
if get_state() < 8 then speedTarget = 0 end | if get_state() < 8 then speedTarget = 0 end | ||
set_sGbl(" | set_sGbl(" | ||
- | --set_sGbl(" | ||
set_ao_val(outputTerm, | set_ao_val(outputTerm, | ||
- | --set_ao_val(outputChan, | ||
- | --print(suctOutput.." | ||
set_sVirt(" | set_sVirt(" | ||
- | --set_speed_val(1, | ||
if hasRPM then | if hasRPM then | ||
Line 749: | Line 693: | ||
if recycleCtrl then | if recycleCtrl then | ||
local recyclePct = map_range(outputLow2, | local recyclePct = map_range(outputLow2, | ||
- | --if recycleRevAct == 1 then recyclePct = 100 - recyclePct end | ||
if recyclePct <= recycleTarget then | if recyclePct <= recycleTarget then | ||
recycleTarget = recycleTarget - rampRate2 | recycleTarget = recycleTarget - rampRate2 | ||
Line 766: | Line 709: | ||
recycleOutput = 100 - recycleOutput | recycleOutput = 100 - recycleOutput | ||
end | end | ||
- | --set_sGbl(" | ||
set_ao_val(recycleTerm, | set_ao_val(recycleTerm, | ||
set_sGbl(" | set_sGbl(" | ||
Line 779: | Line 721: | ||
if get_state() < 8 then speedTarget = 0 end | if get_state() < 8 then speedTarget = 0 end | ||
set_sGbl(" | set_sGbl(" | ||
- | --set_sGbl(" | ||
set_ao_val(outputTerm, | set_ao_val(outputTerm, | ||
- | --set_ao_val(outputChan, | ||
- | --print(suctOutput.." | ||
set_sVirt(" | set_sVirt(" | ||
- | --set_speed_val(1, | ||
local sRpm = (speedTarget/ | local sRpm = (speedTarget/ | ||
set_sVirt(" | set_sVirt(" |