<?xml version='1.0' encoding='utf-8'?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.plcopen.org/xml/tc6_0201" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation="http://www.plcopen.org/xml/tc6_0201">
<fileHeader companyName="Beremiz" productName="Beremiz" productVersion="0.0" creationDateTime="2008-12-14T16:53:26"/>
<contentHeader name="Beremiz non-standard POUs library" modificationDateTime="2018-09-06T13:45:38">
<pou name="getRTCString" pouType="functionBlock">
<derived name="python_eval"/>
<xhtml:p><![CDATA[(* Get time from RTC *)
eval(TRIG:=TRIG, CODE:='GetRTC()', ACK => ACK, RESULT => DT_STR);]]></xhtml:p>
<xhtml:p><![CDATA[Sample time from RTC on raising edge of TRIG. Outputs a formated string in DT_STR and sets ACK to TRUE when output is ready.
2018-07-28 11:24:07 6 1]]></xhtml:p>
<pou name="getRTC" pouType="functionBlock">
<derived name="python_eval"/>
<variable name="COMPUTE">
<xhtml:p><![CDATA[(* Get time from RTC *)
eval(TRIG:=TRIG, CODE:='GetRTC()', ACK => ACK, RESULT => DT_STR);
rtrig(CLK := ACK, Q => COMPUTE);
IF COMPUTE OR (TRIG & ACK ) THEN
VALID:=STRING_TO_BOOL(IN:=MID(IN:=DT_STR,L:=1,P:=23));
YEAR:=STRING_TO_UINT(IN:=MID(IN:=DT_STR,L:=4,P:=1));
MONTH:=STRING_TO_UINT(IN:=MID(IN:=DT_STR,L:=2,P:=6));
DAY:=STRING_TO_UINT(IN:=MID(IN:=DT_STR,L:=2,P:=9));
WDAY:=STRING_TO_UINT(IN:=MID(IN:=DT_STR,L:=1,P:=21));
HOUR:=STRING_TO_UINT(IN:=MID(IN:=DT_STR,L:=2,P:=12));
MINUTE:=STRING_TO_UINT(IN:=MID(IN:=DT_STR,L:=2,P:=15));
SECOND:=STRING_TO_UINT(IN:=MID(IN:=DT_STR,L:=2,P:=18));
<xhtml:p><![CDATA[Sample time from RTC on raising edge of TRIG. Outputs time as separate values and sets ACK to TRUE when output is ready. VALID is FALSE if hardware clock had a power failure and time is incorrect, TRUE otherwise.]]></xhtml:p>
<pou name="setRTC" pouType="functionBlock">
<derived name="python_eval"/>
<variable name="COMPUTE">
<variable name="INPUT_ARGS">
<variable name="INPUT_VALUE_CODE">
<xhtml:p><![CDATA[(* Set RTC time *)
rtrig(CLK := TRIG, Q => COMPUTE);
INPUT_VALUE_CODE:=CONCAT(
UINT_TO_STRING(YEAR), ',',
UINT_TO_STRING(MONTH), ',',
UINT_TO_STRING(DAY), ',',
UINT_TO_STRING(HOUR), ',',
UINT_TO_STRING(MINUTE), ',',
UINT_TO_STRING(SECOND), ')');
eval(TRIG := TRIG, CODE := INPUT_VALUE_CODE, ACK => ACK, RESULT => RESULT);
VALID := RESULT = 'True';
<xhtml:p><![CDATA[Set RTC time on raising edge of TRIG]]></xhtml:p>