Created
September 28, 2021 14:24
-
-
Save RenatoExpert/bb450b6771ed000d2c02adf5e7830b28 to your computer and use it in GitHub Desktop.
Pseudo codigo para CLP de acionamentos eletricos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool is_resting = true; | |
bool auto_mode = true; | |
################# REAGINDO AO NIVEL DA BOMBA ############ | |
function response (levelp) { | |
#levelp is level percentage | |
#the return is a integer in hertz for the frequency the bomb | |
# should ajust to | |
if (levelp<25) { | |
setbomb_f(75); | |
} | |
elseif (level>=25 && level<50) { | |
setbomb_f(60); | |
} | |
elseif (level>=50 && level<75) { | |
setbomb_f(50); | |
} | |
elseif (level>=75 && level<100) { | |
setbomb_f(40); | |
} | |
elseif (level==100) { | |
restingmode(); | |
} | |
else { | |
error(); | |
} | |
} | |
function restingmode(levelp) { | |
h2 = interface.output(n_porta); | |
h2.set(1); | |
v1 = interface.output(n_porta); | |
v1.set(1); #open | |
if (levelp < 25) { | |
is_resting == false; | |
h2.set(0); | |
} | |
} | |
function redefine_motor (levelp) { | |
if (is_resting==true) { | |
restingmode(levelp) | |
} | |
elseif (is_resting==false) { | |
response(levelp); | |
} | |
} | |
######################## CALCULANDO O NIVEL DO TANQUE ################# | |
# TRANSMISSOR TIPO 4A20 | |
function levelp() { | |
return (voltage-4)*(100/16); | |
} | |
function working() { | |
float voltage = interface.input(n_porta); | |
int levelp = get_level(voltage); | |
redefine_motor (levelp); | |
} | |
function automation_core() { | |
h1 = interface.output(n_porta); | |
h1.set(1); | |
while (automode==true) { | |
b2 = interface.input(n_porta); | |
be = interface.input(n_porta); | |
if (b2 == true || be == true) { | |
deactivate(); | |
break; | |
} | |
working(); | |
} | |
} | |
function deactivate() { | |
h1 = interface.output(n_porta); | |
h1.set(0); | |
automode = false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment