The simple Greenhouse example is also the target for the online tutorial.
INCLUDE rtcu.inc
VAR_INPUT
Sensor_L : BOOL;
Sensor_H : BOOL;
Alarm_time : INT;
phone_number : SRING;
END_VAR;
VAR_OUTPUT
Out_Heater : BOOL;
Out_Ventilation : BOOL;
online : BOOL;
END_VAR;
VAR
timer : TON;
send_alarm : R_TRIG;
END_VAR;
PROGRAM greenhouse;
timer(pt := Alarm_time*60*1000);
gsmPower(power := ON);
BEGIN
online := gsmConnected();
IF Sensor_H THEN
Out_Ventilation:= ON;
ELSE
Out_Ventilation:= OFF;
END_IF;
IF Sensor_L THEN
Out_Heater:= ON;
ELSE
Out_Heater:= OFF;
END_IF;
timer(trig:= Sensor_L OR Sensor_H);
send_alarm(trig:=timer.q);
IF send_alarm.q THEN
IF Sensor_L THEN
gsmSendSMS(phonenumber:=phone_number, message:="Temperature too low");
ELSIF Sensor_H THEN
gsmSendSMS(phonenumber:=phone_number, message:="Temperature too high");
END_IF;
END_IF;
END;
END_PROGRAM;
|