<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<plcProject caseSensitive="false" useCustomWorkspace="true" debugMode="false" extcheck="true" SFCControl="false" strictPointerCheck="false" verboseWarningMode="false" PNContactsOnEachNetwork="false" LocalVarsFBAccess="false" strictEnumsCheck="false" copyWarningThreshold="200" version="2.9" useLD2="true" useXPLCFiles="true" useFBMethods="false" customSortOfProjectTree="false" autoDerefPointers="false">
	<image>HMI_CH_HP.imgx</image>
	<commSettings>Modbus:1,1000,M#COM:9,38400,E,8,1,H</commSettings>
	<sources>
		<main>
			<resources>
				<resource name="TM172DC" processor="ARMv7M">
					<task name="Timed" interval="t#100000us" priority="0" type="cyclic" hidden="false" dynamic="false" descr="Timed task"/>
					<task name="Background" interval="t#10000us" priority="1" type="cyclic" hidden="false" dynamic="false" descr="Background task - executes continuously at low priority"/>
					<task name="Boot" interval="t#0us" priority="2" type="single" hidden="false" dynamic="false" descr="Boot task - executes once at system startup"/>
					<task name="Init" interval="t#0us" priority="3" type="single" hidden="false" dynamic="false" descr="Init task - executes once at every PLC full restart"/>
					<task name="Draw" interval="t#50000us" priority="4" type="cyclic" hidden="true" dynamic="false" descr="Draw task for HMI"/>
					<task name="Refresh" interval="t#50000us" priority="5" type="cyclic" hidden="true" dynamic="false" descr="Refresh task for HMI"/>
				</resource>
			</resources>
			<tasks>
				<task name="Background">
					<program>MainLoop</program>
				</task>
			</tasks>
			<globalVars/>
			<retainVars/>
			<constantVars/>
			<iecVarsDeclaration/>
			<functions/>
			<functionBlocks/>
			<programs/>
			<macros/>
			<structs/>
			<typedefs/>
			<enums/>
			<subranges/>
			<interfaces/>
		</main>
		<target id="TM172DC-L_659p8" name="HMI_CH_HP.tgt" fullXml="false">
			<![CDATA[(************************************************************************)
(*                                                                      *)
(*	Description: Definition of target variables and functions           *)
(*                                                                      *)
(************************************************************************)


(************************************************************************)
(*                                                                      *)
(*   ENUMS                                                              *)
(*                                                                      *)
(************************************************************************)
TYPE
	MBM_ERRORS: (                             { DE:"Modbus Master possible error list" }
		MBM_E_NO := 0,                        { DE:"No error occurred" }
		MBM_E_ILLEGALFUNCTION := 1,           { DE:"Invalid request message" }
		MBM_E_ILLEGALDATAADDR := 2,           { DE:"Illegal data address" }
		MBM_E_ILLEGALDATAVALUE := 3,          { DE:"Illegal data value" }
		MBM_E_SLAVEDEVICEFAILURE := 4,        { DE:"Salve device failure" }
		MBM_E_ACKNOWLEDGE := 5,               { DE:"Acknowledge error" }
		MBM_E_SLAVEDEVICEBUSY := 6,           { DE:"Slave device busy" }
		MBM_E_MEMORYPARITYERROR := 7,         { DE:"Memory parity error" }
		MBM_E_COMM_CHN := 8,                  { DE:"Communication channel configuration error" }
		MBM_E_SLAVE_ADR := 9,                 { DE:"Invalid slave address (address range 0 - 247)" }
		MBM_E_GATEWAYPATHUNAV := 10,          { DE:"Gateway path unavailable" }
		MBM_E_GATEWAYDEVICEFAILED := 11,      { DE:"Gateway target device failed to respond" }
		MBM_E_MSG_MAX := 12,                  { DE:"Invalid number of element for this function" }
		MBM_E_RQ_INVALID := 13,               { DE:"Cannot correctly build the request message" }
		MBM_E_MSG_INVALID := 14,              { DE:"Invalid response message" }
		MBM_E_MSG_SIZE := 15,                 { DE:"Response size error" }
		MBM_E_TIMEOUT := 16,                  { DE:"Timeout reached" }
		MBM_E_INVALIDTASK := 17				  { DE:"Function invoked by an invalid task"}		
	);
END_TYPE




(************************************************************************)
(*                                                                      *)
(*   GLOBAL VARIABLES                                                   *)
(*                                                                      *)
(************************************************************************)

TYPE
    TypeDataTime : STRUCT
	seconds : USINT;  {DE: "seconds          " }
	minutes : USINT;  {DE: "minutes          " }
	hours   : USINT;  {DE: "hours            " }
	dayweek : USINT;  {DE: "day of week      " }
	daymonth: USINT;  {DE: "day of month     " }
	month   : USINT;  {DE: "month            " }
	year    : USINT;  {DE: "year             " }
	Error   : BOOL;   {DE: "RTC writing error" }
    END_STRUCT;
END_TYPE

TYPE
    SetDataTime : STRUCT
	seconds : USINT;  {DE: "seconds          " }
	minutes : USINT;  {DE: "minutes          " }
	hours   : USINT;  {DE: "hours            " }
	dayweek : USINT;  {DE: "day of week      " }
	daymonth: USINT;  {DE: "day of month     " }
	month   : USINT;  {DE: "month            " }
	year    : USINT;  {DE: "year             " }
	Update  : BOOL;   {DE: "Write flag       " }
    END_STRUCT;
END_TYPE

TYPE
	LCD_pressure : STRUCT
	is_LCD_pressed : BOOL;	{DE: "Notify if the touch screen is pressed or not  (ongoing event)"}
	pressed_event : BOOL;	{DE: "Notify if the touch screen has ever been pressed or not "} 
	last_x_press : UINT;	{DE: "Last x coordinate where touch event happened  "}
	last_y_press : UINT;	{DE: "Last y coordinate where touch event happened  "}
	last_x_release : UINT;	{DE: "Last x coordinate where release event happened"}
	last_y_release : UINT;	{DE: "Last x coordinate where release event happened"}
	END_STRUCT;
END_TYPE

VAR_GLOBAL 
	
	{G:"System Timers"}
	sysTimer					AT %MD60000.0 : UDINT; 					{ DE:"System timer 1 KHz"}
	
	{G:"General purpose Data Block"}
	sysUserDatablock			AT %MB0.0	: ARRAY[0..127] OF USINT;	{ IO:"User datablock" }
	
	{G:"Analog and Digital Inputs"} 
	sysSensorNTC				AT %IW0.0	: INT;						{ DE:"NTC thermistor sensor value" }
	sysSensorRH					AT %IW1.0	: INT;						{ DE:"RH humidity sensor value" }
	sysSensorPIR				AT %IW2.0	: INT;						{ DE:"PIR proximity sensor value" }
	
	{G:"System Parameters: EEPROM image in RAM (read)"}
	sysParameters				AT %MW100.0 : ARRAY[0..16] OF UINT;		{ DE:"System Parameters DB (read)" }
	sysLangID					AT %MW100.13 : UINT;					{ DE:"HMI active Language ID [0=Italiano, 1=English, 2=Francais, 3=Deutsch, 4=Espanol]" }
	
	{G:"System Parameters: image in RAM (read)"}
	sysPar_PARTAB				AT %MW100.0 : UINT;						{ DE:"Map code" }
	sysPar_PARPOLI				AT %MW100.1 : UINT;						{ DE:"Polycarbonate code" }
	sysPar_PARMOD				AT %MW100.2 : BOOL;						{ DE:"Parameter modified flag" }
	sysPar_CAL_RH_interne		AT %MW100.3 : INT;						{ DE:"Calibration value for RH sensor (read)" }
	sysPar_Calibration_RH		AT %MW100.4 : UINT;						{ DE:"RH percentage differential (%/10)" }
	sysPar_Temp_UM				AT %MW100.5 : UINT;						{ DE:"Unit of temperature measurement (°C/°F)" }
	sysPar_Calibration_NTC		AT %MW100.6 : UINT;						{ DE:"NTC differential (°C/10 , °F/10)" }
	sysPar_Addr_RS485_OB		AT %MW100.7 : UINT;						{ DE:"RS485 On Board address [1..255]" }
	sysPar_Proto_RS485_OB		AT %MW100.8 : UINT;						{ DE:"RS485 On Board protocol [0 = Slave, 1 = Master]" }
	sysPar_DataBit_RS485_OB		AT %MW100.9 : UINT;						{ DE:"RS485 On Board data bit number [8]" }
	sysPar_StopBit_RS485_OB		AT %MW100.10 : UINT;					{ DE:"RS485 On Board stop bit number [1..2]" }
	sysPar_Parity_RS485_OB		AT %MW100.11 : UINT;					{ DE:"RS485 On Board parity protocol [0=NULL, 1=ODD, 2=EVEN]" }
	sysPar_Baud_RS485_OB		AT %MW100.12 : UINT;					{ DE:"RS485 On Board baud rate protocol [0=9600, 1=19200, 2= 38400, 3=57600, 4=115200]" }
	sysPar_Orientation			AT %MW100.14 : UINT;					{ DE:"Display Orientation [0=Landscape, 1=Portrait]" }
	sysPar_BacklightTime		AT %MW100.15 : UINT;					{ DE:"Time to wait befor fading; used only if Backlight = Timed [seconds]" }
	sysPar_BacklightMinValue	AT %MW100.16 : UINT;					{ DE:"Minimum light intensity; used only if Backlight = Timed [% percentage]" }
	
	{G:"System Clock"}
	sysClock					AT %MB102.0	: TypeDataTime;
	{ DE:"System Date and Time Read. It is a structure of type TypeDataTime composed 
by the following fields:
	seconds		: USINT; seconds [0...59]
	minutes		: USINT; minutes [0...59] 
	hours		: USINT; hours [0...23]
	dayweek		: USINT; day of week [0...6] 0=sunday,...,6=saturday
	daymonth	: USINT; day of month [1...31]
	month		: USINT; month [1...12]
	year		: USINT; year [0...99]
	Error 		: BOOL;  RTC writing error
" }

	sysSetClock					AT %MB101.0	: SetDataTime;
	{ DE:"System Date and Time write parameters, set Update TRUE to execute the update. Type SetDataTime
is composed of the following fields:
	seconds		: USINT; seconds [0...59]
	minutes		: USINT; minutes [0...59] 
	hours		: USINT; hours [0...23]
	dayweek		: USINT; day of week [0...6]
	daymonth	: USINT; day of month [1...31]
	month		: USINT; month [1...12]
	year		: USINT; year [0...99]
	update		: BOOL;  update RTC 
"}

	sysClockError				AT %MX102.7 : BOOL;						{ DE:"System Date and Time invalid" }   
	
	{G:"Backlight Status"}  
	sysBacklight				AT %MW103.0 : UINT;						{ DE:"Display Backlight [0=Min, 1=On, 2=Timed]" }
	
	{G:"System Display Touch Information"}
	sysLCDPressed				AT %MB60007.0 : LCD_pressure;
	{ DE:"Status and coordinates of the tousch screen. Type LCD_pressure is a structure composed of the 
following fields:
	is_LCD_pressed 	: BOOL;		Notify if the touch screen is pressed or not (ongoing event)
	pressed_event 	: BOOL;		Notify if the touch screen has ever been pressed or not
	last_x_press 	: UINT;		Last x coordinate where touch event happened
	last_y_press 	: UINT;		Last y coordinate where touch event happened
	last_x_release 	: UINT;		Last x coordinate where release event happened
	last_y_release 	: UINT;		Last x coordinate where release event happened 
" }

	
	{G:"System BIOS version"}
	sysMSK						AT %MW104.0 : UINT;						{ DE:"Mask Number" }
	sysVER						AT %MW105.0 : UINT;						{ DE:"Versione Number" }

	{G:"System Modbus messages"}
	sysMODBUS_msg_received		AT %MD60020.0 : UDINT;					{ DE:"Counter for modbus message received" }
	sysRemoteSlave_Addresses	AT %MW106.0   : ARRAY[0..7] OF UINT;	{ DE:"Physical address of the remote slaves with ID from 1 to 8" }
	sysRemoteSlave_Ordering		AT %MW107.0   : ARRAY[0..7] OF UINT;	{ DE:"32 bit data type swap (DWORD / REAL) of the remote slaves with ID from 1 to 8.
	Possible values are:
		0=Word NOT swapped
		1=Word swapped for DWORD 
		2=Word swapped for REAL
		3=Word swapped
" }

	sysMbMRtuNodePresence       AT %MX108.0	  : ARRAY[0..7] OF BOOL;    { DE:"Modbus Master Message Enable of the remote slaves with ID from 1 to 8" }
	
	waitBeforeSendHMI			AT %MW109.0   : UINT;					{ DE:"Time to wait on modbus operations called by HMI" }	

END_VAR


(************************************************************************)
(*                         									            *)
(*   EMBEDDED FUNCTIONS                                                 *)
(*                                                                      *)
(************************************************************************)

FUNCTION sysHmi_Message : BOOL
	{ DE:"Open a Message window on display.
The function return a BOOL which could have the following meanings:
TRUE	=	Command accepted.
FALSE	=	Error entering id value or HMI not running or function called into task timed
" }

	VAR_INPUT
	    id	:  USINT; { DE:"User Message window ID [1..99]" }
	END_VAR
	{CODE:EMBEDDED}
END_FUNCTION

FUNCTION sysDBase_SetExtTable : USINT
	{ HIDDEN:ON }
	{ DE:"Set extended database table" }
	VAR_INPUT
		ptrDB   : DWORD;    { DE:"Database Physical address" }
		numPars : UDINT;    { DE:"Number of parameters" }
		idxDatablockE2   : UINT;  { DE:"Index of datablock for E2 parameters" }
		ptrDatablockE2   : DWORD; { DE:"Address of datablock for E2 parameters" }
		numelemsDatablockE2  : UDINT; { DE:"Number of elements of datablock for E2 parameters" }
		datasizeDatablockE2  : USINT; { DE:"Size of an element of datablock for E2 parameters" }
		idxDatablockRAM  : UINT;  { DE:"Index of datablock for RAM parameters" }
		ptrDatablockRAM  : DWORD; { DE:"Address of datablock for RAM parameters" }
		numelemsDatablockRAM : UDINT; { DE:"Number of elements of datablock for RAM parameters" }
		datasizeDatablockRAM  : USINT; { DE:"Size of an element of datablock for RAM parameters" }
	END_VAR
	{CODE:EMBEDDED}
END_FUNCTION


FUNCTION sysWriteParBOOL: BOOL
	{ DE:"Write BOOL to EEPROM. 
The function return a BOOL which could have the following meanings:
TRUE	=	Writing executed correctly.
FALSE	=	Writing not executed.

Example: bret:=sysWriteParBOOL(ADR(EEPROMPARAMETER),NewValue); 
" }
	VAR_INPUT
		address : UDINT;  { DE:"Address" }
		Value   : BOOL;   { DE:"Value" }
	END_VAR
	{ CODE:EMBEDDED }
END_FUNCTION


FUNCTION sysWriteParUSINT: BOOL
	{ DE:"Write USINT to EEPROM.
The function return a BOOL which could have the following meanings:
TRUE	=	Writing executed correctly.
FALSE	=	Writing not executed.

Example: bret:=sysWriteParUSINT(ADR(EEPROMPARAMETER),NewValue); 	
" }
	VAR_INPUT
		address : UDINT;  { DE:"Address" }
		Value   : USINT;   { DE:"Value" }
	END_VAR
	{ CODE:EMBEDDED }
END_FUNCTION


FUNCTION sysWriteParSINT: BOOL
	{ DE:"Write SINT to EEPROM.
The function return a BOOL which could have the following meanings:
TRUE	=	Writing executed correctly.
FALSE	=	Writing not executed.

Example: bret:=sysWriteParSINT(ADR(EEPROMPARAMETER),NewValue); 	
" }
	VAR_INPUT
		address : UDINT;  { DE:"Address" }
		Value   : SINT;   { DE:"Value" }
	END_VAR
	{ CODE:EMBEDDED }
END_FUNCTION


FUNCTION sysWriteParBYTE: BOOL
	{ DE:"Write BYTE to EEPROM.
The function return a BOOL which could have the following meanings:
TRUE	=	Writing executed correctly.
FALSE	=	Writing not executed.

Example: bret:=sysWriteParBYTE(ADR(EEPROMPARAMETER),NewValue); 	
" }
	VAR_INPUT
		address : UDINT;  { DE:"Address" }
		Value   : BYTE;   { DE:"Value" }
	END_VAR
	{ CODE:EMBEDDED }
END_FUNCTION


FUNCTION sysWriteParINT: BOOL
	{ DE:"Write INT to EEPROM.
The function return a BOOL which could have the following meanings:
TRUE	=	Writing executed correctly.
FALSE	=	Writing not executed.

Example: bret:=sysWriteParINT(ADR(EEPROMPARAMETER),NewValue); 	
" }
	VAR_INPUT
		address : UDINT;  { DE:"Address" }
		Value   : INT;    { DE:"Value" }
	END_VAR
	{ CODE:EMBEDDED }
END_FUNCTION


FUNCTION sysWriteParUINT: BOOL
	{ DE:"Write UINT to EEPROM.
The function return a BOOL which could have the following meanings:
TRUE	=	Writing executed correctly.
FALSE	=	Writing not executed.

Example: bret:=sysWriteParUINT(ADR(EEPROMPARAMETER),NewValue); 	
" }
	VAR_INPUT
		address : UDINT;  { DE:"Address" }
		Value   : UINT;   { DE:"Value" }
	END_VAR
	{ CODE:EMBEDDED }
END_FUNCTION


FUNCTION sysWriteParWORD: BOOL
	{ DE:"Write WORD to EEPROM.
The function return a BOOL which could have the following meanings:
TRUE	=	Writing executed correctly.
FALSE	=	Writing not executed.

Example: bret:=sysWriteParWORD(ADR(EEPROMPARAMETER),NewValue); 	
" }
	VAR_INPUT
		address : UDINT;  { DE:"Address" }
		Value   : WORD;   { DE:"Value" }
	END_VAR
	{ CODE:EMBEDDED }
END_FUNCTION


FUNCTION sysWriteParDINT: BOOL
	{ DE:"Write DINT to EEPROM.
The function return a BOOL which could have the following meanings:
TRUE	=	Writing executed correctly.
FALSE	=	Writing not executed.

Example: bret:=sysWriteParDINT(ADR(EEPROMPARAMETER),NewValue); 
" }
	VAR_INPUT
		address : UDINT;  { DE:"Address" }
		Value   : DINT;   { DE:"Value" }
	END_VAR
	{ CODE:EMBEDDED }
END_FUNCTION


FUNCTION sysWriteParUDINT: BOOL
	{ DE:"Write UDINT to EEPROM.
The function return a BOOL which could have the following meanings:
TRUE	=	Writing executed correctly.
FALSE	=	Writing not executed.

Example: bret:=sysWriteParUDINT(ADR(EEPROMPARAMETER),NewValue); 	
" }
	VAR_INPUT
		address : UDINT;  { DE:"Address" }
		Value   : UDINT;   { DE:"Value" }
	END_VAR
	{ CODE:EMBEDDED }
END_FUNCTION


FUNCTION sysWriteParDWORD: BOOL
	{ DE:"Write DWORD to EEPROM.
The function return a BOOL which could have the following meanings:
TRUE	=	Writing executed correctly.
FALSE	=	Writing not executed.

Example: bret:=sysWriteParDWORD(ADR(EEPROMPARAMETER),NewValue); 	
" }
	VAR_INPUT
		address : UDINT;  { DE:"Address" }
		Value   : DWORD;  { DE:"Value" }
	END_VAR
	{ CODE:EMBEDDED }
END_FUNCTION


FUNCTION sysWriteParREAL: BOOL
	{ DE:"Write REAL to EEPROM.
The function return a BOOL which could have the following meanings:
TRUE	=	Writing executed correctly.
FALSE	=	Writing not executed.

Example: bret:=sysWriteParREAL(ADR(EEPROMPARAMETER),NewValue); 	
" }
	VAR_INPUT
		address : UDINT;  { DE:"Address" }
		Value   : REAL;   { DE:"Value" }
	END_VAR
	{ CODE:EMBEDDED }
END_FUNCTION


FUNCTION sysWriteParSTRING : BOOL
	{ DE:"Write a STRING to EEPROM.
The function return a BOOL which could have the following meanings:
TRUE	=	Writing executed correctly.
FALSE	=	Writing not executed.

Example: bret:=sysWriteParSTRING(ADR(EEPROMPARAMETER),NewValue, SIZEOF(NewValue)); 
" }
	VAR_INPUT
		id  : UDINT;  { DE:"Address" }
		msg : STRING; { DE:"String" }
		len : USINT;  { DE:"SIZEOF(String to write)" }		
	END_VAR
  {CODE:EMBEDDED}
END_FUNCTION


FUNCTION sys_Reboot : BOOL
	{ DE:"Force device to reboot" }
	VAR_INPUT
		doReboot : BOOL;	{ DE:"TRUE to force reboot" }
	END_VAR
	{ CODE:EMBEDDED }
END_FUNCTION


FUNCTION sysClockWrite: USINT
	{ DE:"Write system clock.
The function returns always 0
" }

	VAR_INPUT
	    seconds	:	USINT; { DE:"seconds [0...59]" }
	    minutes	:	USINT; { DE:"minutes [0...59]" }
	    hours	:	USINT; { DE:"hours [0...23]" }
	    dayweek	:	USINT; { DE:"day of week [0...6]" }
	    daymonth	:	USINT; { DE:"day of month [1...31]" }
	    month	:	USINT; { DE:"month [1...12]" } 
	    year	:	USINT; { DE:"year [10...99]" }
	END_VAR
	{ CODE:EMBEDDED }
END_FUNCTION


FUNCTION Video_SetDeviceCfg : BOOL
	{ HIDDEN:ON }
    
	VAR_INPUT
		idxDevice	: USINT;    {DE:"index of device"}
		res         : USINT;    {DE:"0 - local device, 1 - Modbus RTU, 2 - Modbus TCP, 3 - CANopen"}
		address     : UDINT;    {DE:"Modbus RTU/CANopen node address"}
    END_VAR
	
	{ CODE:ST }
	(* This function in automatically generated by PageLab to configure remote slaves. However this is not present on TM172DC firmware, because remote slaves are configured with BIOS parameters *)
	Video_SetDeviceCfg := TRUE;

END_FUNCTION 


        (***************************)
        (*                         *)
        (*     FUNCTION BLOCKS     *)
        (*                         *)
        (***************************)

FUNCTION_BLOCK sysMbMRTU_FC01
{ DE:" Read Coil Status - Function 01 (0x01).
This function block can be used in the Background task only.
You have to assure that all input variables are properly set before invoking the function block. In particular, the addr input variable must be set to the physical address of an existing Modbus Slave target of this operation.
After function block execution, unless an error occurred, you can use a subset of its output variables (from object1 to objectN, where N equals the value of no input variable) to get the Modbus objects read from the communication bus. If an error did occur, you can read its code from the errorCode output variable." }

	VAR_INPUT
		addr : USINT;				{ DE:"Physical address of the target slave" }
		base : UINT;				{ DE:"Address of the first coil to be read" }
		no : UINT;					{ DE:"Number of contiguous coils to be read" }
		pollingTime : UINT;			{ DE:"Polling time [ms]" }
		waitBeforeSend : UINT;		{ DE:"Time to wait before sending the message [ms]" }
		timeout : UINT;				{ DE:"Timeout [ms]" }
	END_VAR

	VAR_OUTPUT
		errorCode : MBM_ERRORS;		{ DE:"Exception Code" }
		error : BOOL;				{ DE:"TRUE = error occurred; FALSE = no error" }
		object1 : BOOL;				{ DE:"1st Coil" }
		object2 : BOOL;				{ DE:"2nd Coil" }
		object3 : BOOL;				{ DE:"3rd Coil" }
		object4 : BOOL;				{ DE:"4th Coil" }
		object5 : BOOL;				{ DE:"5th Coil" }
		object6 : BOOL;				{ DE:"6th Coil" }
		object7 : BOOL;				{ DE:"7th Coil" }
		object8 : BOOL;				{ DE:"8th Coil" }
		object9 : BOOL;				{ DE:"9th Coil" }
		object10 : BOOL;			{ DE:"10th Coil" }
		object11 : BOOL;			{ DE:"11th Coil" }
		object12 : BOOL;			{ DE:"12th Coil" }
		object13 : BOOL;			{ DE:"13th Coil" }
		object14 : BOOL;			{ DE:"14th Coil" }
		object15 : BOOL;			{ DE:"15th Coil" }
		object16 : BOOL;			{ DE:"16th Coil" }
	END_VAR

	VAR
		timestamp : UDINT;			{ DE:"Message timestamp [ms]" }
	END_VAR

	{ CODE:EMBEDDED }

END_FUNCTION_BLOCK


FUNCTION_BLOCK sysMbMRTU_FC02
{ DE:"Read Inputs Status - Function 02 (0x02).
This function block can be used in the Background task only.
You have to assure that all input variables are properly set before invoking the function block. In particular, the addr input variable must be set to the physical address of an existing Modbus Slave target of this operation.
After function block execution, unless an error occurred, you can use a subset of its output variables (from object1 to objectN, where N equals the value of no input variable) to get the Modbus objects read from the communication bus. If an error did occur, you can read its code from the errorCode output variable." }

	VAR_INPUT
		addr : USINT;				{ DE:"Physical address of the target slave" }
		base : UINT;				{ DE:"Address of the first Input to be read" }
		no : UINT;					{ DE:"Number of contiguous Inputs to be read" }
		pollingTime : UINT;			{ DE:"Polling time [ms]" }
		waitBeforeSend : UINT;		{ DE:"Time to wait before sending the message [ms]" }
		timeout : UINT;				{ DE:"Timeout [ms]" }
	END_VAR

	VAR_OUTPUT
		errorCode : MBM_ERRORS;		{ DE:"Exception Code" }
		error : BOOL;				{ DE:"TRUE = error occurred; FALSE = no error" } 
		object1 : BOOL;				{ DE:"1st Input" }
		object2 : BOOL;				{ DE:"2nd Input" }
		object3 : BOOL;				{ DE:"3rd Input" }
		object4 : BOOL;				{ DE:"4th Input" }
		object5 : BOOL;				{ DE:"5th Input" }
		object6 : BOOL;				{ DE:"6th Input" }
		object7 : BOOL;				{ DE:"7th Input" }
		object8 : BOOL;				{ DE:"8th Input" }
		object9 : BOOL;				{ DE:"9th Input" }
		object10 : BOOL;			{ DE:"10th Input" }
		object11 : BOOL;			{ DE:"11th Input" }
		object12 : BOOL;			{ DE:"12th Input" }
		object13 : BOOL;			{ DE:"13th Input" }
		object14 : BOOL;			{ DE:"14th Input" }
		object15 : BOOL;			{ DE:"15th Input" }
		object16 : BOOL;			{ DE:"16th Input" }
	END_VAR

	VAR
		timestamp : UDINT;			{ DE:"Message timestamp [ms]" }
	END_VAR

	{ CODE:EMBEDDED }

END_FUNCTION_BLOCK


FUNCTION_BLOCK sysMbMRTU_FC03
{ DE:"Read Holding Registers - Function 03 (0x03).
This function block can be used in the Background task only.
You have to assure that all input variables are properly set before invoking the function block. In particular, the addr input variable must be set to the physical address of an existing Modbus Slave target of this operation.
After function block execution, unless an error occurred, you can use a subset of its output variables (from object1 to objectN, where N equals the value of no input variable) to get the Modbus objects read from the communication bus. If an error did occur, you can read its code from the errorCode output variable." }

	VAR_INPUT
		addr : USINT;				{ DE:"Physical address of the target slave" }
		base : UINT;				{ DE:"Address of the first Holding Register to be read" }
		no : UINT;					{ DE:"Number of contiguous Holding Registers to be read" }
		pollingTime : UINT;			{ DE:"Polling time [ms]" }
		waitBeforeSend : UINT;		{ DE:"Time to wait before sending the message [ms]" }
		timeout : UINT;				{ DE:"Timeout [ms]" }
	END_VAR

	VAR_OUTPUT
		errorCode : MBM_ERRORS;		{ DE:"Exception Code" } 
		error : BOOL;				{ DE:"TRUE = error occurred; FALSE = no error" }
		object1 : UINT;				{ DE:"1st Holding Register" }
		object2 : UINT;				{ DE:"2nd Holding Register" }
		object3 : UINT;				{ DE:"3rd Holding Register" }
		object4 : UINT;				{ DE:"4th Holding Register" }
		object5 : UINT;				{ DE:"5th Holding Register" }
		object6 : UINT;				{ DE:"6th Holding Register" }
		object7 : UINT;				{ DE:"7th Holding Register" }
		object8 : UINT;				{ DE:"8th Holding Register" }
		object9 : UINT;				{ DE:"9th Holding Register" }
		object10 : UINT;			{ DE:"10th Holding Register" }
		object11 : UINT;			{ DE:"11th Holding Register" }
		object12 : UINT;			{ DE:"12th Holding Register" }
		object13 : UINT;			{ DE:"13th Holding Register" }
		object14 : UINT;			{ DE:"14th Holding Register" }
		object15 : UINT;			{ DE:"15th Holding Register" }
		object16 : UINT;			{ DE:"16th Holding Register" }
	END_VAR

	VAR
		timestamp : UDINT;			{ DE:"Message timestamp [ms]" }
	END_VAR

	{ CODE:EMBEDDED }

END_FUNCTION_BLOCK


FUNCTION_BLOCK sysMbMRTU_FC04
{ DE:"Read Input Registers - Function 04 (0x04).
This function block can be used in the Background task only.
You have to assure that all input variables are properly set before invoking the function block. In particular, the addr input variable must be set to the physical address of an existing Modbus Slave target of this operation.
After function block execution, unless an error occurred, you can use a subset of its output variables (from object1 to objectN, where N equals the value of no input variable) to get the Modbus objects read from the communication bus. If an error did occur, you can read its code from the errorCode output variable." }

	VAR_INPUT
		addr : USINT;				{ DE:"Physical address of the target slave" }
		base : UINT;				{ DE:"Address of the first Input Register to be read" }
		no : UINT;					{ DE:"Number of contiguous Input Registers to be read" }
		pollingTime : UINT;			{ DE:"Polling time [ms]" }
		waitBeforeSend : UINT;		{ DE:"Time to wait before sending the message [ms]" }
		timeout : UINT;				{ DE:"Timeout [ms]" }
	END_VAR

	VAR_OUTPUT
		errorCode : MBM_ERRORS;		{ DE:"Exception Code" } 
		error : BOOL;				{ DE:"TRUE = error occurred; FALSE = no error" } 
		object1 : UINT;				{ DE:"1st Input Register" }
		object2 : UINT;				{ DE:"2nd Input Register" }
		object3 : UINT;				{ DE:"3rd Input Register" }
		object4 : UINT;				{ DE:"4th Input Register" }
		object5 : UINT;				{ DE:"5th Input Register" }
		object6 : UINT;				{ DE:"6th Input Register" }
		object7 : UINT;				{ DE:"7th Input Register" }
		object8 : UINT;				{ DE:"8th Input Register" }
	END_VAR

	VAR
		timestamp : UDINT;			{ DE:"Message timestamp [ms]" }
	END_VAR

	{ CODE:EMBEDDED }

END_FUNCTION_BLOCK



FUNCTION_BLOCK sysMbMRTU_FC05
{ DE:"Write Single Coil - Function 05 (0x05).
This function block can be used in the Background task only.
You have to assure that all input variables are properly set before invoking the function block. In particular, the addr input variable must be set to the physical address of an existing Modbus Slave target of this operation. The value of the object input variable is the value sent on the communication bus to the slave node.
After function block execution, if an error did occur, you can read its code from the errorCode output variable." }

	VAR_INPUT
		addr : USINT;				{ DE:"Physical address of the target slave" }
		base : UINT;				{ DE:"Address of the Coil to write" }
		object : BOOL;				{ DE:"Coil value" }
		pollingTime : UINT;			{ DE:"Polling time [ms]" }
		waitBeforeSend : UINT;		{ DE:"Time to wait before sending the message [ms]" }
		timeout : UINT;				{ DE:"Timeout [ms]; used as Turnaround time in case of BROADCAST MESSAGE" }
	END_VAR

	VAR_OUTPUT
		errorCode : MBM_ERRORS;		{ DE:"Exception Code" } 
		error : BOOL;				{ DE:"TRUE = error occurred; FALSE = no error" }
	END_VAR

	VAR
		timestamp : UDINT;			{ DE:"Message timestamp [ms]" }
	END_VAR

	{ CODE:EMBEDDED }

END_FUNCTION_BLOCK



FUNCTION_BLOCK sysMbMRTU_FC06
{ DE:"Write Single Register - Function 06 (0x06).
This function block can be used in the Background task only.
You have to assure that all input variables are properly set before invoking the function block. In particular, the addr input variable must be set to the physical address of an existing Modbus Slave target of this operation. The value of the object input variable is the value sent on the communication bus to the slave node.
After function block execution, if an error did occur, you can read its code from the errorCode output variable." }

	VAR_INPUT
		addr : USINT;				{ DE:"Physical address of the target slave" }
		base : UINT;				{ DE:"Address of the Register to write" }
		object :  UINT;				{ DE:"Register value" }
		pollingTime : UINT;			{ DE:"Polling time [ms]" }
		waitBeforeSend : UINT;		{ DE:"Time to wait before sending the message [ms]" }
		timeout : UINT;				{ DE:"Timeout [ms]; used as Turnaround time in case of BROADCAST MESSAGE" }
	END_VAR

	VAR_OUTPUT
		errorCode : MBM_ERRORS;		{ DE:"Exception Code" } 
		error : BOOL;				{ DE:"TRUE = error occurred; FALSE = no error" }
	END_VAR

	VAR
		timestamp : UDINT;			{ DE:"Message timestamp [ms]" }
	END_VAR

	{ CODE:EMBEDDED }

END_FUNCTION_BLOCK



FUNCTION_BLOCK sysMbMRTU_FC15
{ DE:"Write Multiple Coils - Function 15 (0x0F).
This function block can be used in the Bakcground task only.
You have to assure that all input variables, except any objectN variable, where N is greater than the value of no input variable, are properly set before invoking the function block. In particular, the addr input variable must be set to the physical address of an existing Modbus Slave target of this operation. The values of all input variables ranging from object1 to objectN, where N equals the value of no input variable are the values sent on the communication bus to the slave node.
After function block execution, if an error did occur, you can read its code from the errorCode output variable." }

	VAR_INPUT
		addr : USINT;				{ DE:"Physical address of the target slave" }
		base : UINT;				{ DE:"Address of the first Coils to write" }
		no : UINT;					{ DE:"Number of contiguous Coils to write" }
		object1 : BOOL;				{ DE:"1st Coil value" }
		object2 : BOOL;				{ DE:"2nd Coil value" }
		object3 : BOOL;				{ DE:"3rd Coil value" }
		object4 : BOOL;				{ DE:"4th Coil value" }
		object5 : BOOL;				{ DE:"5th Coil value" }
		object6 : BOOL;				{ DE:"6th Coil value" }
		object7 : BOOL;				{ DE:"7th Coil value" }
		object8 : BOOL;				{ DE:"8th Coil value" }
		object9 : BOOL;				{ DE:"9th Coil value" }
		object10 : BOOL;			{ DE:"10th Coil value" }
		object11 : BOOL;			{ DE:"11th Coil value" }
		object12 : BOOL;			{ DE:"12th Coil value" }
		object13 : BOOL;			{ DE:"13th Coil value" }
		object14 : BOOL;			{ DE:"14th Coil value" }
		object15 : BOOL;			{ DE:"15th Coil value" }
		object16 : BOOL;			{ DE:"16th Coil value" }
		pollingTime : UINT;			{ DE:"Polling time [ms]" }
		waitBeforeSend : UINT;		{ DE:"Time to wait before sending the message [ms]" }
		timeout : UINT;				{ DE:"Timeout [ms]; used as Turnaround time in case of BROADCAST MESSAGE" }
	END_VAR

	VAR_OUTPUT
		errorCode : MBM_ERRORS;		{ DE:"Exception Code" } 
		error : BOOL;				{ DE:"TRUE = error occurred; FALSE = no error" }
	END_VAR

	VAR
		timestamp : UDINT;			{ DE:"Message timestamp [ms]" }
	END_VAR

	{ CODE:EMBEDDED }

END_FUNCTION_BLOCK



FUNCTION_BLOCK sysMbMRTU_FC16
{ DE:"Write Multiple Registers - Function 16 (0x10).
This function block can be used in the Background task only.
You have to assure that all input variables, except any objectN variable, where N is greater than the value of no input variable, are properly set before invoking the function block. In particular, the addr input variable must be set to the physical address of an existing Modbus Slave target of this operation. The values of all input variables ranging from object1 to objectN, where N equals the value of no input variable are the values sent on the communication bus to the slave node.
After function block execution, if an error did occur, you can read its code from the errorCode output variable." }

	VAR_INPUT
		addr : USINT;				{ DE:"Physical address of the target slave" }
		base : UINT;				{ DE:"Address of the first Holding Register to write" }
		no : UINT;					{ DE:"Number of contiguous Holding Registers to write" }
		object1 : UINT;				{ DE:"1st Holding Register value" }
		object2 : UINT;				{ DE:"2nd Holding Register value" }
		object3 : UINT;				{ DE:"3rd Holding Register value" }
		object4 : UINT;				{ DE:"4th Holding Register value" }
		object5 : UINT;				{ DE:"5th Holding Register value" }
		object6 : UINT;				{ DE:"6th Holding Register value" }
		object7 : UINT;				{ DE:"7th Holding Register value" }
		object8 : UINT;				{ DE:"8th Holding Register value" }
		object9 : UINT;				{ DE:"9th Holding Register value" }
		object10 : UINT;			{ DE:"10th Holding Register value" }
		object11 : UINT;			{ DE:"11th Holding Register value" }
		object12 : UINT;			{ DE:"12th Holding Register value" }
		object13 : UINT;			{ DE:"13th Holding Register value" }
		object14 : UINT;			{ DE:"14th Holding Register value" }
		object15 : UINT;			{ DE:"15th Holding Register value" }
		object16 : UINT;			{ DE:"16th Holding Register value" }
		pollingTime : UINT;			{ DE:"Polling time [ms]" }
		waitBeforeSend : UINT;		{ DE:"Time to wait before sending the message [ms]" }
		timeout : UINT;				{ DE:"Timeout [ms]; used as Turnaround time in case of BROADCAST MESSAGE" }
	END_VAR

	VAR_OUTPUT
		errorCode : MBM_ERRORS;		{ DE:"Exception Code" } 
		error : BOOL;				{ DE:"TRUE = error occurred; FALSE = no error" }
	END_VAR

	VAR
		timestamp : UDINT;			{ DE:"Message timestamp [ms]" }
	END_VAR

	{ CODE:EMBEDDED }

END_FUNCTION_BLOCK]]>
		</target>
		<targetXML name="HMI_CH_HP.tgtx" fullXml="true">
			<target>
				<resources>
					<!-- !!!!!!!!!! IMPORTANT  : REMEMBER TO UPDATE ALSO THE <target> SECTION INSIDE THE TM172DC_659pX_emptyPLC.plcprj !!!!!!!!!! -->
					<resource name="TM172DC" processor="ARMv7M">
						<task id="0" name="Timed" period="100000" type="cyclic" descr="Timed task">
							<constraints minPeriod="10000" maxPeriod="1000000"/>
						</task>
						<task id="1" name="Background" period="10000" type="cyclic" descr="Background task - executes continuously at low priority"/>
						<task id="2" name="Boot" type="single" period="0" descr="Boot task - executes once at system startup"/>
						<task id="3" name="Init" type="single" period="0" descr="Init task - executes once at every PLC full restart"/>
						<task id="4" name="Draw" type="cyclic" period="50000" hidden="true" descr="Draw task for HMI"/>
						<task id="5" name="Refresh" type="cyclic" period="50000" hidden="true" descr="Refresh task for HMI"/>
					</resource>
				</resources>
			</target>
		</targetXML>
		<libraries>
			<lib version="1.0.0" name="c:\program files (x86)\eliwell\free studio plus\catalog\tm172dc\..\..\Application\Libraries\basic.plclib" fullXml="true" link="true">
				<descr/>
				<libWorkspace>
					<folder id="7" name="basic">
						<folder name="Conversion">
							<Pou name="BitToWord"/>
							<Pou name="BitToByte"/>
							<Pou name="ByteToWord"/>
							<Pou name="ByteToBit"/>
							<Pou name="WordToBit"/>
							<Pou name="WordToByte"/>
						</folder>
						<folder name="Timers">
							<Pou name="Pulse"/>
							<Pou name="TOF"/>
							<Pou name="TON"/>
							<Pou name="TP"/>
						</folder>
						<folder name="Bistable">
							<Pou name="FF_D"/>
							<Pou name="SR"/>
							<Pou name="RS"/>
						</folder>
						<folder name="Counters">
							<Pou name="CTD"/>
							<Pou name="CTD_DINT"/>
							<Pou name="CTD_UDINT"/>
							<Pou name="CTU"/>
							<Pou name="CTU_DINT"/>
							<Pou name="CTU_UDINT"/>
							<Pou name="CTUD"/>
							<Pou name="CTUD_DINT"/>
							<Pou name="CTUD_UDINT"/>
						</folder>
						<folder name="Edge detection">
							<Pou name="F_TRIG"/>
							<Pou name="R_TRIG"/>
						</folder>
					</folder>
				</libWorkspace>
				<globalVars/>
				<retainVars/>
				<constantVars/>
				<functions>
					<function name="ByteToWord" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<descr>Compose a word from 2 bytes</descr>
						<returnValue>UINT</returnValue>
						<vars>
							<inputVars>
								<var name="byte0" type="BYTE">
									<descr>Low byte</descr>
								</var>
								<var name="byte1" type="BYTE">
									<descr>High byte</descr>
								</var>
							</inputVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<sourceCode type="IL">
							<![CDATA[
	(*---------- WORD in memoria IEEE --------*)
	(*										  *)
	(*	WORD -> | H byte1 | L byte0 |		  *)
	(*										  *)
	(*----------------------------------------*)

	(*	Low byte *)

	LD		byte0
	TO_UINT
	ST		ByteToWord

	(*	High byte *)

	LD		byte1
	TO_UINT
	SHL		8
	ADD		ByteToWord
	ST		ByteToWord

]]>
						</sourceCode>
					</function>
					<function name="BitToByte" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<descr>Compose a byte from 8 bits</descr>
						<returnValue>USINT</returnValue>
						<vars>
							<inputVars>
								<var name="b0" type="BOOL">
									<descr>Bit 0</descr>
								</var>
								<var name="b1" type="BOOL">
									<descr>Bit 1</descr>
								</var>
								<var name="b2" type="BOOL">
									<descr>Bit 2</descr>
								</var>
								<var name="b3" type="BOOL">
									<descr>Bit 3</descr>
								</var>
								<var name="b4" type="BOOL">
									<descr>Bit 4</descr>
								</var>
								<var name="b5" type="BOOL">
									<descr>Bit 5</descr>
								</var>
								<var name="b6" type="BOOL">
									<descr>Bit 6</descr>
								</var>
								<var name="b7" type="BOOL">
									<descr>Bit 7</descr>
								</var>
							</inputVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<sourceCode type="IL">
							<![CDATA[
	LD		b7
	TO_USINT
	SHL		7
	ST		BitToByte

	LD		b6
	TO_USINT
	SHL		6
	ADD		BitToByte
	ST		BitToByte

	LD		b5
	TO_USINT
	SHL		5
	ADD		BitToByte
	ST		BitToByte

	LD		b4
	TO_USINT
	SHL		4
	ADD		BitToByte
	ST		BitToByte

	LD		b3
	TO_USINT
	SHL		3
	ADD		BitToByte
	ST		BitToByte

	LD		b2
	TO_USINT
	SHL		2
	ADD		BitToByte
	ST		BitToByte

	LD		b1
	TO_USINT
	SHL		1
	ADD		BitToByte
	ST		BitToByte

	LD		b0
	TO_USINT
	ADD		BitToByte
	ST		BitToByte

]]>
						</sourceCode>
					</function>
					<function name="BitToWord" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<descr>Compose a word from 16 bits</descr>
						<returnValue>WORD</returnValue>
						<vars>
							<inputVars>
								<var name="b0" type="BOOL">
									<descr>Bit 0</descr>
								</var>
								<var name="b1" type="BOOL">
									<descr>Bit 1</descr>
								</var>
								<var name="b2" type="BOOL">
									<descr>Bit 2</descr>
								</var>
								<var name="b3" type="BOOL">
									<descr>Bit 3</descr>
								</var>
								<var name="b4" type="BOOL">
									<descr>Bit 4</descr>
								</var>
								<var name="b5" type="BOOL">
									<descr>Bit 5</descr>
								</var>
								<var name="b6" type="BOOL">
									<descr>Bit 6</descr>
								</var>
								<var name="b7" type="BOOL">
									<descr>Bit 7</descr>
								</var>
								<var name="b8" type="BOOL">
									<descr>Bit 8</descr>
								</var>
								<var name="b9" type="BOOL">
									<descr>Bit 9</descr>
								</var>
								<var name="b10" type="BOOL">
									<descr>Bit 10</descr>
								</var>
								<var name="b11" type="BOOL">
									<descr>Bit 11</descr>
								</var>
								<var name="b12" type="BOOL">
									<descr>Bit 12</descr>
								</var>
								<var name="b13" type="BOOL">
									<descr>Bit 13</descr>
								</var>
								<var name="b14" type="BOOL">
									<descr>Bit 14</descr>
								</var>
								<var name="b15" type="BOOL">
									<descr>Bit 15</descr>
								</var>
							</inputVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<sourceCode type="IL">
							<![CDATA[
	LD		b15
	TO_UINT
	SHL		15
	ST		BitToWord

	LD		b14
	TO_UINT
	SHL		14
	ADD		BitToWord
	ST		BitToWord

	LD		b13
	TO_UINT
	SHL		13
	ADD		BitToWord
	ST		BitToWord

	LD		b12
	TO_UINT
	SHL		12
	ADD		BitToWord
	ST		BitToWord

	LD		b11
	TO_UINT
	SHL		11
	ADD		BitToWord
	ST		BitToWord

	LD		b10
	TO_UINT
	SHL		10
	ADD		BitToWord
	ST		BitToWord

	LD		b9
	TO_UINT
	SHL		9
	ADD		BitToWord
	ST		BitToWord

	LD		b8
	TO_UINT
	SHL		8
	ADD		BitToWord
	ST		BitToWord

	LD		b7
	TO_UINT
	SHL		7
	ADD		BitToWord
	ST		BitToWord

	LD		b6
	TO_UINT
	SHL		6
	ADD		BitToWord
	ST		BitToWord

	LD		b5
	TO_UINT
	SHL		5
	ADD		BitToWord
	ST		BitToWord

	LD		b4
	TO_UINT
	SHL		4
	ADD		BitToWord
	ST		BitToWord

	LD		b3
	TO_UINT
	SHL		3
	ADD		BitToWord
	ST		BitToWord

	LD		b2
	TO_UINT
	SHL		2
	ADD		BitToWord
	ST		BitToWord

	LD		b1
	TO_UINT
	SHL		1
	ADD		BitToWord
	ST		BitToWord

	LD		b0
	TO_UINT
	ADD		BitToWord
	ST		BitToWord

]]>
						</sourceCode>
					</function>
				</functions>
				<functionBlocks>
					<functionBlock name="R_TRIG" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<title>Rising edge detector</title>
						<descr>&lt;HTML&gt;The output Q will remain FALSE as long as the input variable CLK is FALSE.&lt;br&gt;
As soon as CLK returns TRUE, Q will first return TRUE.&lt;br&gt;&lt;br&gt;
This means each time the function is called up, Q will return FALSE until CLK has falling edge followed by an rising edge.&lt;br&gt;&lt;br&gt;
&lt;img src= r_trig.png&gt;</descr>
						<vars>
							<inputVars>
								<var name="clk" type="BOOL">
									<descr>Input for edge detection</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="q" type="BOOL">
									<descr>Raising edge output</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="m" type="BOOL">
									<initValue>TRUE</initValue>
								</var>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
	LD		clk
	ANDN	m
	ST		q

	LD		clk
	ST		m
]]>
						</sourceCode>
						<images>
							<image name="r_trig.png" width="218" height="117">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAANoAAAB1CAYAAAAoV//gAAAAAXNSR0IArs4c6QAAAARnQU1B
AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvq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ihVBLWmhxXkLhMYeXH6XCA3cOp4k5lV1bpRy+V1y/JshjwiNPcjZJc97e/8PobEHObskrlbT
P1hHdP5gzT8ib5cs/ResGBHbCqGxB9fdJe31Wdw6br1Gqzxgw/V3SbzrOL6lnBAae1B+l/wN
DW6Y0CCB0CCB0CCB0CCB0CCB0CCB0CCB0CCB0GDFufaf0GBF23+n7sOL7eDpBA1jT+NYQjOM
Z4xjXSy0c3nuPwzOYRzXKftQaLDiXPtPaJBAaJBAaJBAaJBAaJBAaJBAaJDADoYEQoMEQoME
QoMEQoMEQoMEQoMEQoMEQoMEQoMEQoOLOxx+A+X2Hit+emmnAAAAAElFTkSuQmCC]]>
							</image>
							<image icon="true" name="rtrig34.png" width="34" height="34">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAACIAAAAiCAYAAAA6RwvCAAAApklEQVRYhe2VUQrEIAxEZ0pP
Vw/V9VA9X/qzLYvUNrGWTSEPBJEYhzFGIAiC4B4UEUUUa0GEZr+CoUuWDliF8Dv+LuQx7EI6
1UTJix15CDdCxp8eQQBH8zMEND+iw3PcOFJtmVVE0ODCJY4cUfQFptyjeVCWGUwZssxbXmxr
bhwZjfEtxaFy87WO7PerhSmr4tw4EkJKiOlj+WvYUCNlHt9/TRBcsQJT/izAApTRbQAAAABJ
RU5ErkJggg==]]>
							</image>
						</images>
					</functionBlock>
					<functionBlock name="F_TRIG" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<title>Falling edge detector</title>
						<descr>&lt;HTML&gt;The output Q remain FALSE as long as the input variable CLK returns TRUE.&lt;br&gt;
As soon as CLK returns FALSE, Q will first return TRUE.&lt;br&gt;&lt;br&gt;
This means each time the function is called up, Q will return FALSE until CLK has a rising followed by a falling edge.&lt;br&gt;&lt;br&gt;
&lt;img src= f_trig.png &gt;</descr>
						<vars>
							<inputVars>
								<var name="clk" type="BOOL">
									<descr>Input for edge detection</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="q" type="BOOL">
									<descr>Falling edge output</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="m" type="BOOL">
									<initValue>FALSE</initValue>
								</var>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
	LDN		clk
	AND		m
	ST		q

	LD		clk
	ST		m
]]>
						</sourceCode>
						<images>
							<image name="f_trig.png" width="218" height="117">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAANoAAAB1CAYAAAAoV//gAAAAAXNSR0IArs4c6QAAAARnQU1B
AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5l
dCA0LjAuMjHxIGmVAAAEDUlEQVR4Xu3awXHUShCAYadAAFxIgSNXUqDIgARIghtnUqBIhRAg
BAJ477BUYw2WJbEa2atW79b3VY3t9S72oNZfkg13J2B3QoMEQoMEQoMEQoMEQoMEQoMEQoME
QoMEQoMEQoMEQoMEQoME5UO7u7v7s+CaCQ0SlD6DW2Ri49oJDRKUPXunkbUF10hokKD8mSsw
boHQIIHQIIHQIIHQIIHQIIHQIIHQIIHQIIHQIIHQniG2VW1RU/nRCG3boqbyo7mG0CqotBfm
yo9GaH0q7YW58qMRWp9Ke2Gu/GiE1qfSXpgrPxqh9am0F+bKj0ZofSrthblNo/n+/WGgsd68
GZ4YxOc+fx4eTLx8eTp9/Dg8GHz7dv9n3r8fPrFAaH0q7YW57tG0KMYhRWjj2KbPj01Da9FO
45sSWp9Ke2GuezRLV6QWS0QY4uPe0OK1a5EFofWptBfmukYzDepf4jU9ocXH524Xx4TWp9Je
mOsaTbttjODOideshTa93VwjtD6V9sJc12guFVo7Gaa3kecIrU+lvTDXNZpL3Tq2E6H36wWh
9am0F+a6RxO3e0s/V8VwW1zjj6emV7F4Xbx+/SoptB6V9sJc92ja7eM4pIgvAmqmz48t3S5O
//wSofWptBfmNo2mxdbW9Jca4+faalfBpdBCvOZcbC209vUqrgqW9mU9Xkc6+N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wAAAA
AElFTkSuQmCC]]>
							</image>
						</images>
					</functionBlock>
					<functionBlock name="CTUD_UDINT" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<title>Up-Down counter (UDINT data type)</title>
						<descr>&lt;HTML&gt;(Same as CTUD_UDINT but with PV and CV of &lt;b&gt;DINT&lt;/b&gt; data type)&lt;br/&gt;&lt;br/&gt;
The CTUD_UDINT block &lt;b&gt;counts up&lt;/b&gt; for each FALSE-to-TRUE transition of the input CU and &lt;b&gt;count down&lt;/b&gt; for each  FALSE-to-TRUE transition of the input CD.&lt;br/&gt;
Sets the QU output when the accumulated value (CV) reaches the preset value (PV) value and sets the QD output when the accumulated value (CV) becomes 0.&lt;br/&gt;
&lt;img src= ctudscheme.png&gt;
&lt;ul&gt;
&lt;li&gt;rising edge of R reset CV to 0&lt;/li&gt;
&lt;li&gt;rising edge of LD set CV to PV&lt;/li&gt;
&lt;li&gt;rising edge of CU increments CV by 1&lt;/li&gt;
&lt;li&gt;rising edge of CD decrements CV by 1&lt;/li&gt;
&lt;li&gt;when CV reaches PV the output QU is set&lt;/li&gt;
&lt;li&gt;when CV becomes 0 the output QD is set&lt;/li&gt;
&lt;/ul&gt;</descr>
						<vars>
							<inputVars>
								<var name="CU" type="BOOL">
									<descr>Count-up input</descr>
								</var>
								<var name="CD" type="BOOL">
									<descr>Count-down input</descr>
								</var>
								<var name="R" type="BOOL">
									<descr>Reset counter input</descr>
								</var>
								<var name="LD" type="BOOL">
									<descr>Preset counter input</descr>
								</var>
								<var name="PV" type="UDINT">
									<descr>Preset value</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="QU" type="BOOL">
									<descr>Count-up output</descr>
								</var>
								<var name="QD" type="BOOL">
									<descr>Count-down output</descr>
								</var>
								<var name="CV" type="UDINT">
									<descr>Counter current value</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="MEMCU" type="BOOL">
									<descr>Previous value of CU</descr>
								</var>
								<var name="MEMCD" type="BOOL">
									<descr>Previous value of CD</descr>
								</var>
								<var name="CUEDGE" type="BOOL">
									<descr>True whenever a posedge on CU is detected</descr>
								</var>
								<var name="CDEDGE" type="BOOL">
									<descr>True whenever a posedge on CD is detected</descr>
								</var>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
	(* Check for reset input *)
	LD		R
	JMPCN	l0
	
	LD		0
	ST		CV
	JMP		l10

l0:
	(* Check for preset input *)
	LD		LD
	JMPCN	l1
	
	LD		PV
	ST		CV
	JMP		l10

l1:
	(* Check for posedge on CU *)
	LD		CU
	ANDN 	MEMCU
	ST 		CUEDGE
	(* Store CU value for next cycle *)	
	LD 		CU
	ST 		MEMCU

	(* Check for posedge on CD *)
	LD		CD
	ANDN 	MEMCD
	ST 		CDEDGE
	(* Store CD value for next cycle *)	
	LD 		CD
	ST 		MEMCD

	(* Check for simultaneous posedges on *)
	LD		CUEDGE
	AND		CDEDGE
	JMPC	l10
	
	(* ASSERT(!CUEDGE || !CDEDGE) *)

	(* Check if posedge on CU and we are in bounds *)
	LD		CUEDGE
	AND(	16#FFFFFFFF
	GT		CV
	)
	JMPCN	l2
	
	(* ASSERT(CUEDGE) *)
	(* Increment *)
	LD		CV
	ADD		1
	ST		CV

l2:
    (* Check if posedge on CD and we are in bounds *)
	LD		CDEDGE
	AND(	CV
	GT		0
	)
	JMPCN	l10
	
	(* ASSERT(CDEDGE) *)
	(* Decrement *)
	LD		CV
	SUB		1
	ST		CV
	
	(* ASSERT(!CUEDGE && !CDEDGE) *)
	
l10:
	(* Up counter output *)
	LD		CV
	GE		PV
	ST		QU

	(* Down counter output *)
	LD		CV
	LE		0
	ST		QD
]]>
						</sourceCode>
						<images>
							<image name="ctudscheme.png" width="376" height="244">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAXgAAAD0CAYAAACRmD2xAAAWEklEQVR4nO3dPXbbSLrG8afu
[encoded data, 7488 characters]
AAAAAAAAAAAAAAAAAEbq/wGQpWZSHyQgQgAAAABJRU5ErkJggg==]]>
							</image>
							<image icon="true" name="ctud48.png" width="48" height="48">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAC5UlEQVRoge1YoZLbMBB92yns
gRRcZ2xWHtSZfEGKDxXHKCHH8wvHW3KHHFzSooLeF1yn6Ep7zAIBNcgHbEEkZ61IthS7OWea
N6ORJa1Xb61drSXgjDP+b5Cnn11jzPxv2USAaEvvhWOMrXrQsA2wSQ/eiJdW27iN04WGCJcL
nRTOBjw3WrfRJMlvAczF2F1RzBb2C2m6WgK4cegqAbwH8FO35wBufXJKZUYOzAwiQpLkDICU
yvZesoPYhXvxPPdKbQneOfrnuiwi5QDAkAcATpJ8z4ioRKaV3SmVLWRSG0/W+FN886gCa8J7
q+aSUyqr5AT5GueimDUmslbYGfnx4fIQNY3wkAcATtNV1QhxoVCMACx1HYIbIWvqEmgkb1B5
yMEGpOlqVBSzcjxZm66lLjZK7Pv8CFt/t401ARycRLtso7/TdCV3HUOGrPJaEDModb+UAYCp
rjmgHG6ADqARgNHjw2UfMVCaB2aGUlnbClTjnRPZeLKGcKPOMLtLgxFUFLOq0RoDSZJ/wG5p
AWCqk5sPrrHP2OWTd2jOJxWKYkZpupIBTUplIMqqjpAgnloTvhXtp18/3gAAkiQ34y5yT2g3
wBXsUCqjpkzsw9HOAU2nPGauFfGR2vWGKOyrtBkXS77RgKHh5H+nzwY8N6ptVPq3SSZ9+jwf
srMxE4jMj1utNlku6jzQBdyzTqOo8+/0QV+2R+xcSHQSolntviyzWGAHYtySyC+v5whZgThb
msiHjAfIb66vqudQFxr+LR3rxdI+zVwvQSeMYxW8+l7xrlZgc32125k+fWXRDsLFxy+gi/t2
QQu8mdbek217zPRB9FUk5c+SUhknSS4veiVsw9pixKfHp68V8lolNgZiSXQ13j2ZCGxpgMx0
TcpjJw25IvFhLwNvaybzLcQXqWUCLeTS1TRXCDdqGQ9Fh5u544OiLR3ayaV2FyTR13oeE2Su
3ZswNGO8K3AiMQAgMl8MbQXOGCz+ArhmepcGiq6VAAAAAElFTkSuQmCC]]>
							</image>
						</images>
					</functionBlock>
					<functionBlock name="CTUD_DINT" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<title>Up-Down counter (DINT data type)</title>
						<descr>&lt;HTML&gt;(Same as CTUD but with PV and CV of &lt;b&gt;DINT&lt;/b&gt; data type)&lt;br/&gt;&lt;br/&gt;
The CTUD_DINT block &lt;b&gt;counts up&lt;/b&gt; for each FALSE-to-TRUE transition of the input CU and &lt;b&gt;count down&lt;/b&gt; for each  FALSE-to-TRUE transition of the input CD.&lt;br/&gt;
Sets the QU output when the accumulated value (CV) reaches the preset value (PV) value and sets the QD output when the accumulated value (CV) becomes 0.&lt;br/&gt;
&lt;img src= ctudscheme.png&gt;
&lt;ul&gt;
&lt;li&gt;rising edge of R reset CV to 0&lt;/li&gt;
&lt;li&gt;rising edge of LD set CV to PV&lt;/li&gt;
&lt;li&gt;rising edge of CU increments CV by 1&lt;/li&gt;
&lt;li&gt;rising edge of CD decrements CV by 1&lt;/li&gt;
&lt;li&gt;when CV reaches PV the output QU is set&lt;/li&gt;
&lt;li&gt;when CV becomes 0 the output QD is set&lt;/li&gt;
&lt;/ul&gt;</descr>
						<vars>
							<inputVars>
								<var name="CU" type="BOOL">
									<descr>Count-up input</descr>
								</var>
								<var name="CD" type="BOOL">
									<descr>Count-down input</descr>
								</var>
								<var name="R" type="BOOL">
									<descr>Reset counter input</descr>
								</var>
								<var name="LD" type="BOOL">
									<descr>Preset counter input</descr>
								</var>
								<var name="PV" type="DINT">
									<descr>Preset value</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="QU" type="BOOL">
									<descr>Count-up output</descr>
								</var>
								<var name="QD" type="BOOL">
									<descr>Count-down output</descr>
								</var>
								<var name="CV" type="DINT">
									<descr>Counter current value</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="MEMCU" type="BOOL">
									<descr>Previous value of CU</descr>
								</var>
								<var name="MEMCD" type="BOOL">
									<descr>Previous value of CD</descr>
								</var>
								<var name="CUEDGE" type="BOOL">
									<descr>True whenever a posedge on CU is detected</descr>
								</var>
								<var name="CDEDGE" type="BOOL">
									<descr>True whenever a posedge on CD is detected</descr>
								</var>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
	(* Check for reset input *)
	LD		R
	JMPCN	l0
	
	LD		0
	ST		CV
	JMP		l10

l0:
	(* Check for preset input *)
	LD		LD
	JMPCN	l1
	
	LD		PV
	ST		CV
	JMP		l10

l1:
	(* Check for posedge on CU *)
	LD		CU
	ANDN 	MEMCU
	ST 		CUEDGE
	(* Store CU value for next cycle *)	
	LD 		CU
	ST 		MEMCU

	(* Check for posedge on CD *)
	LD		CD
	ANDN 	MEMCD
	ST 		CDEDGE
	(* Store CD value for next cycle *)	
	LD 		CD
	ST 		MEMCD

	(* Check for simultaneous posedges on *)
	LD		CUEDGE
	AND		CDEDGE
	JMPC	l10
	
	(* ASSERT(!CUEDGE || !CDEDGE) *)

	(* Check if posedge on CU and we are in bounds *)
	LD		CUEDGE
	AND(	CV
	LT		16#7FFFFFFF
	)
	JMPCN	l2
	
	(* ASSERT(CUEDGE) *)
	(* Increment *)
	LD		CV
	ADD		1
	ST		CV

l2:
    (* Check if posedge on CD and we are in bounds *)
	LD		CDEDGE
	AND(	CV
	GT		-2147483648
	)
	JMPCN	l10
	
	(* ASSERT(CDEDGE) *)
	(* Decrement *)
	LD		CV
	SUB		1
	ST		CV
	
	(* ASSERT(!CUEDGE && !CDEDGE) *)
	
l10:
	(* Up counter output *)
	LD		CV
	GE		PV
	ST		QU

	(* Down counter output *)
	LD		CV
	LE		0
	ST		QD
]]>
						</sourceCode>
						<images>
							<image name="ctudscheme.png" width="376" height="244">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAXgAAAD0CAYAAACRmD2xAAAWEklEQVR4nO3dPXbbSLrG8afu
[encoded data, 7488 characters]
AAAAAAAAAAAAAAAAAEbq/wGQpWZSHyQgQgAAAABJRU5ErkJggg==]]>
							</image>
							<image icon="true" name="ctud48.png" width="48" height="48">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAC5UlEQVRoge1YoZLbMBB92yns
gRRcZ2xWHtSZfEGKDxXHKCHH8wvHW3KHHFzSooLeF1yn6Ep7zAIBNcgHbEEkZ61IthS7OWea
N6ORJa1Xb61drSXgjDP+b5Cnn11jzPxv2USAaEvvhWOMrXrQsA2wSQ/eiJdW27iN04WGCJcL
nRTOBjw3WrfRJMlvAczF2F1RzBb2C2m6WgK4cegqAbwH8FO35wBufXJKZUYOzAwiQpLkDICU
yvZesoPYhXvxPPdKbQneOfrnuiwi5QDAkAcATpJ8z4ioRKaV3SmVLWRSG0/W+FN886gCa8J7
q+aSUyqr5AT5GueimDUmslbYGfnx4fIQNY3wkAcATtNV1QhxoVCMACx1HYIbIWvqEmgkb1B5
yMEGpOlqVBSzcjxZm66lLjZK7Pv8CFt/t401ARycRLtso7/TdCV3HUOGrPJaEDModb+UAYCp
rjmgHG6ADqARgNHjw2UfMVCaB2aGUlnbClTjnRPZeLKGcKPOMLtLgxFUFLOq0RoDSZJ/wG5p
AWCqk5sPrrHP2OWTd2jOJxWKYkZpupIBTUplIMqqjpAgnloTvhXtp18/3gAAkiQ34y5yT2g3
wBXsUCqjpkzsw9HOAU2nPGauFfGR2vWGKOyrtBkXS77RgKHh5H+nzwY8N6ptVPq3SSZ9+jwf
srMxE4jMj1utNlku6jzQBdyzTqOo8+/0QV+2R+xcSHQSolntviyzWGAHYtySyC+v5whZgThb
msiHjAfIb66vqudQFxr+LR3rxdI+zVwvQSeMYxW8+l7xrlZgc32125k+fWXRDsLFxy+gi/t2
QQu8mdbek217zPRB9FUk5c+SUhknSS4veiVsw9pixKfHp68V8lolNgZiSXQ13j2ZCGxpgMx0
TcpjJw25IvFhLwNvaybzLcQXqWUCLeTS1TRXCDdqGQ9Fh5u544OiLR3ayaV2FyTR13oeE2Su
3ZswNGO8K3AiMQAgMl8MbQXOGCz+ArhmepcGiq6VAAAAAElFTkSuQmCC]]>
							</image>
						</images>
					</functionBlock>
					<functionBlock name="CTUD" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<title>Up-Down counter</title>
						<descr>&lt;HTML&gt;The CTUD block &lt;b&gt;counts up&lt;/b&gt; for each FALSE-to-TRUE transition of the input CU and &lt;b&gt;count down&lt;/b&gt; for each  FALSE-to-TRUE transition of the input CD.&lt;br/&gt;
Sets the QU output when the accumulated value (CV) reaches the preset value (PV) value and sets the QD output when the accumulated value (CV) becomes 0.&lt;br/&gt;
&lt;img src= ctudscheme.png&gt;
&lt;ul&gt;
&lt;li&gt;rising edge of R reset CV to 0&lt;/li&gt;
&lt;li&gt;rising edge of LD set CV to PV&lt;/li&gt;
&lt;li&gt;rising edge of CU increments CV by 1&lt;/li&gt;
&lt;li&gt;rising edge of CD decrements CV by 1&lt;/li&gt;
&lt;li&gt;when CV reaches PV the output QU is set&lt;/li&gt;
&lt;li&gt;when CV becomes 0 the output QD is set&lt;/li&gt;
&lt;/ul&gt;</descr>
						<vars>
							<inputVars>
								<var name="CU" type="BOOL">
									<descr>Count-up input</descr>
								</var>
								<var name="CD" type="BOOL">
									<descr>Count-down input</descr>
								</var>
								<var name="R" type="BOOL">
									<descr>Reset counter input</descr>
								</var>
								<var name="LD" type="BOOL">
									<descr>Preset counter input</descr>
								</var>
								<var name="PV" type="INT">
									<descr>Preset value</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="QU" type="BOOL">
									<descr>Count-up output</descr>
								</var>
								<var name="QD" type="BOOL">
									<descr>Count-down output</descr>
								</var>
								<var name="CV" type="INT">
									<descr>Counter current value</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="MEMCU" type="BOOL">
									<descr>Previous value of CU</descr>
								</var>
								<var name="MEMCD" type="BOOL">
									<descr>Previous value of CD</descr>
								</var>
								<var name="CUEDGE" type="BOOL">
									<descr>True whenever a posedge on CU is detected</descr>
								</var>
								<var name="CDEDGE" type="BOOL">
									<descr>True whenever a posedge on CD is detected</descr>
								</var>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
	(* Check for reset input *)
	LD		R
	JMPCN	l0
	
	LD		0
	ST		CV
	JMP		l10

l0:
	(* Check for preset input *)
	LD		LD
	JMPCN	l1
	
	LD		PV
	ST		CV
	JMP		l10
	
l1:
	(* Check for posedge on CU *)
	LD		CU
	ANDN 	MEMCU
	ST 		CUEDGE
	(* Store CU value for next cycle *)	
	LD 		CU
	ST 		MEMCU
	
	(* Check for posedge on CD *)
	LD		CD
	ANDN 	MEMCD
	ST 		CDEDGE
	(* Store CD value for next cycle *)	
	LD 		CD
	ST 		MEMCD

	(* Check for simultaneous posedges on *)
	LD		CUEDGE
	AND		CDEDGE
	JMPC	l10
	
	(* ASSERT(!CUEDGE || !CDEDGE) *)

	(* Check if posedge on CU and we are in bounds *)
	LD		CUEDGE
	AND(	CV
	LT		16#7FFF
	)
	JMPCN	l2
	
	(* ASSERT(CUEDGE) *)
	(* Increment *)
	LD		CV
	ADD		1
	ST		CV
	
l2: 
    (* Check if posedge on CD and we are in bounds *)
	LD		CDEDGE
	AND(	CV
	GT		-32768
	)
	JMPCN	l10
	
	(* ASSERT(CDEDGE) *)
	(* Decrement *)
	LD		CV
	SUB		1
	ST		CV
	
	(* ASSERT(!CUEDGE && !CDEDGE) *)
	
l10:
	(* Up counter output *)
	LD		CV
	GE		PV
	ST		QU

	(* Down counter output *)
	LD		CV
	LE		0
	ST		QD
]]>
						</sourceCode>
						<images>
							<image name="ctudscheme.png" width="376" height="244">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAXgAAAD0CAYAAACRmD2xAAAWEklEQVR4nO3dPXbbSLrG8afu
[encoded data, 7488 characters]
AAAAAAAAAAAAAAAAAEbq/wGQpWZSHyQgQgAAAABJRU5ErkJggg==]]>
							</image>
							<image icon="true" name="ctud48.png" width="48" height="48">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAC5UlEQVRoge1YoZLbMBB92yns
gRRcZ2xWHtSZfEGKDxXHKCHH8wvHW3KHHFzSooLeF1yn6Ep7zAIBNcgHbEEkZ61IthS7OWea
N6ORJa1Xb61drSXgjDP+b5Cnn11jzPxv2USAaEvvhWOMrXrQsA2wSQ/eiJdW27iN04WGCJcL
nRTOBjw3WrfRJMlvAczF2F1RzBb2C2m6WgK4cegqAbwH8FO35wBufXJKZUYOzAwiQpLkDICU
yvZesoPYhXvxPPdKbQneOfrnuiwi5QDAkAcATpJ8z4ioRKaV3SmVLWRSG0/W+FN886gCa8J7
q+aSUyqr5AT5GueimDUmslbYGfnx4fIQNY3wkAcATtNV1QhxoVCMACx1HYIbIWvqEmgkb1B5
yMEGpOlqVBSzcjxZm66lLjZK7Pv8CFt/t401ARycRLtso7/TdCV3HUOGrPJaEDModb+UAYCp
rjmgHG6ADqARgNHjw2UfMVCaB2aGUlnbClTjnRPZeLKGcKPOMLtLgxFUFLOq0RoDSZJ/wG5p
AWCqk5sPrrHP2OWTd2jOJxWKYkZpupIBTUplIMqqjpAgnloTvhXtp18/3gAAkiQ34y5yT2g3
wBXsUCqjpkzsw9HOAU2nPGauFfGR2vWGKOyrtBkXS77RgKHh5H+nzwY8N6ptVPq3SSZ9+jwf
srMxE4jMj1utNlku6jzQBdyzTqOo8+/0QV+2R+xcSHQSolntviyzWGAHYtySyC+v5whZgThb
msiHjAfIb66vqudQFxr+LR3rxdI+zVwvQSeMYxW8+l7xrlZgc32125k+fWXRDsLFxy+gi/t2
QQu8mdbek217zPRB9FUk5c+SUhknSS4veiVsw9pixKfHp68V8lolNgZiSXQ13j2ZCGxpgMx0
TcpjJw25IvFhLwNvaybzLcQXqWUCLeTS1TRXCDdqGQ9Fh5u544OiLR3ayaV2FyTR13oeE2Su
3ZswNGO8K3AiMQAgMl8MbQXOGCz+ArhmepcGiq6VAAAAAElFTkSuQmCC]]>
							</image>
						</images>
					</functionBlock>
					<functionBlock name="CTU_UDINT" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<title>Up counter (UDINT data type)</title>
						<descr>&lt;HTML&gt;(Same as CTU but with PV and CV of &lt;b&gt;UDINT&lt;/b&gt; data type)&lt;br/&gt;&lt;br/&gt;
The CTU_UDINT block &lt;b&gt;counts up&lt;/b&gt; for each FALSE-to-TRUE transition of the input CU and sets the output Q when the accumulated value (CV) reaches the preset value (PV) value.&lt;br/&gt;
&lt;img src= ctuscheme.png&gt;
&lt;ul&gt;
&lt;li&gt;rising edge of R reset CV to 0&lt;/li&gt;
&lt;li&gt;rising edge of CU increments CV by 1&lt;/li&gt;
&lt;li&gt;when CV reaches PV the output Q is set&lt;/li&gt;
&lt;li&gt;once CV is equal to PV its value remains until a rising edge of R&lt;/li&gt;
&lt;/ul&gt;</descr>
						<vars>
							<inputVars>
								<var name="CU" type="BOOL">
									<descr>Count-up on input rising edge</descr>
								</var>
								<var name="R" type="BOOL">
									<descr>Reset counter input</descr>
								</var>
								<var name="PV" type="UDINT">
									<descr>Preset value</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="Q" type="BOOL">
									<descr>Count-up output</descr>
								</var>
								<var name="CV" type="UDINT">
									<descr>Counter current value</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="CUEDGE" type="BOOL"/>
								<var name="MEMCU" type="BOOL"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
	(*	Check for reset input *)
	LD		R
	JMPCN	l0
	
	LD		0
	ST		CV
	JMP		l1

	(*	Check for increment enable *)
l0:
	LD		CU
	ANDN 	MEMCU
	ST 		CUEDGE
	
	LD 		CU
	ST 		MEMCU
	
	LD 		CUEDGE
	AND(	CV
	LT		16#FFFFFFFF
	)
	JMPCN	l1
	
	LD		CV
	ADD		1
	ST		CV
	
l1:

	(*	Counter output	*)
	LD		CV
	GE		PV
	ST		Q
	

]]>
						</sourceCode>
						<images>
							<image icon="true" name="ctu48.png" width="48" height="48">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAACtUlEQVRoge2YoXLcMBCGf3UK
G3AF7YzFyoM6kye44KDiO3RHwu8VwluSQz5c0qKA5gnaKWppw2wQUIN7gC2w1ifLki3ZzkU3
9TfjsSWt17vWrtYyMDHxfyMc/WQbI6KntSYAIUrzXljGyDhHjemAaXT0Trw02hw21hCKEVsI
nRSTA89N5zKaJOktgJU2ts2yxdq8QcrdBsCNRVcB4BLAT9VeAbh1yeX5kuVARBBCIElSAiDy
fNm4yUxiG/fa9copVRq4tfSv1LEOlAMANh4AKEnShhNBhUwp2+b5cq0XtfOLR/zN7hyqQMrg
xqzZ5PJ8WclpxtdszrJFayHrxKzIv76/6aOmFYfxAEBS7qqGTwj5MgOwUWcfbjRZPhdAq/FM
FSG9HZByN8uyRXF+8chdG3WYFGjG/AxlvJvOcgJ7F9Ehy+gfKXf6qsPGCON4rRnGFKpflwGA
eagRvWZALW0zADOOfyn7aKoo+MLML05WF4NzQAuhUegy2KTTgSRJP6A+tXNV3FzYxj7jUE/e
o72eBOEzA3Pjge+09sPvH28BAEmS8rjNuAd0O2BL9t4cbR8wdJcXlAMxbSmZ4CQOTbKn5uQ/
pycHnpsqB/QE5TgfM2mpz8pGJCAEf7jVzpyJQfuBIdDIOlnR4E+JXm92RA4hpHUKBFt1eLNE
2gRbCAlLIdzy6hk+MxDmS1edCK0jFvn99VV17RtCcVUvG6QmS8U0Uf1ATAdefavsrmZgf311
WJk+fSWt7cXZxy8QZ/fdgga0n9fu09vmGPdB69OMrKUxASQsA8Y91nETlx6Xvk7KdcI/iYcY
MdR5+8O0xNYd0Ctdm/LQh/r8InHRqMDlmQS/C58QMnS1PcvHNtEx7suAP3PHRwR7GtvWq1pB
Tcaaz2Mi+Ld7G7E545yBE8kBAIH1IrYZmIiWf2FOAyn58r38AAAAAElFTkSuQmCC]]>
							</image>
						</images>
					</functionBlock>
					<functionBlock name="CTU_DINT" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<title>Up counter (DINT data type)</title>
						<descr>&lt;HTML&gt;(Same as CTU but with PV and CV of &lt;b&gt;DINT&lt;/b&gt; data type)&lt;br/&gt;&lt;br/&gt;
The CTU_DINT block &lt;b&gt;counts up&lt;/b&gt; for each FALSE-to-TRUE transition of the input CU and sets the output Q when the accumulated value (CV) reaches the preset value (PV) value.&lt;br/&gt;
&lt;img src= ctuscheme.png&gt;
&lt;ul&gt;
&lt;li&gt;rising edge of R reset CV to 0&lt;/li&gt;
&lt;li&gt;rising edge of CU increments CV by 1&lt;/li&gt;
&lt;li&gt;when CV reaches PV the output Q is set&lt;/li&gt;
&lt;li&gt;once CV is equal to PV its value remains until a rising edge of R&lt;/li&gt;
&lt;/ul&gt;</descr>
						<vars>
							<inputVars>
								<var name="CU" type="BOOL">
									<descr>Count-up on input rising edge</descr>
								</var>
								<var name="R" type="BOOL">
									<descr>Reset counter input</descr>
								</var>
								<var name="PV" type="DINT">
									<descr>Preset value</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="Q" type="BOOL">
									<descr>Count-up output</descr>
								</var>
								<var name="CV" type="DINT">
									<descr>Counter current value</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="CUEDGE" type="BOOL"/>
								<var name="MEMCU" type="BOOL"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
	(*	Check for reset input *)
	LD		R
	JMPCN	l0
	
	LD		0
	ST		CV
	JMP		l1

	(*	Check for increment enable *)
l0:
	LD		CU
	ANDN 	MEMCU
	ST 		CUEDGE
	
	LD 		CU
	ST 		MEMCU
	
	LD 		CUEDGE
	AND(	CV
	LT		16#7FFFFFFF
	)
	JMPCN	l1
	
	LD		CV
	ADD		1
	ST		CV
	
l1:

	(*	Counter output	*)
	LD		CV
	GE		PV
	ST		Q
	

]]>
						</sourceCode>
						<images>
							<image name="ctuscheme.png" width="336" height="200">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAVAAAADICAYAAAC+qrlDAAAKYUlEQVR4nO3dTXLbyqEG0I+p
t4DnuwRlCdIOQm8gKd9BFqA7Vwa6M5be6HoQza0FZGBVZQNmdiAtwVqClR3gDQCalExaQhOU
0NA5VSgZBAg2ZOhjd+OnEwAAAAAAAAAAAAAAAAAAAKCvppsARuVPr10AgFrNXrsAT3hc8xx7
eYE3RA0UoNCYa3S7+j3HXGbgDVEDBSg01trcU2fdx1pu4A1RAwWYMNeBAqOkBgpQSIACFBKg
AIUEKEAhAQpQSIACFBKgAIUEKEAhAQpQSIACFBo0QJvkvEm+NUnTTV+a5MOQnwFT0jRNmsad
ym9eF5ZfNwOzST53QXq636bdC0+ZjS/zsU5tiL72L4rX09U8myaZb1n2uauVvivfvOOLMiMI
SAHKz3U1z687ls33rIUKUIo9CKq+U9e8Lnrv05MAnYC9+0C7muVRkuWOVW67n8f7fhbAmAxx
Eumo+3n/xHqlTXgYxOyiHcrgudOD9w48MQ0uYwIoNESA3nU/n6phPlVDBajK3gE6a4PxLlvO
wHdWfZ+3O5YDvF0uY2KsNs92937vxln4oTkLzwPN9gvp/9jzEqZuM44vygwSoAe4U0iATsOg
JwSb5DzttFnbvE3y62zdV1qwWQnK3mZ9D/aD3mI5m039kJ7N0n5R9JmvzUHL3NVGP3Wzv82S
67LNCFD29uw/0Be5N12ATiJA/+eQG58l101bA/2U/c/C1/j7pXaH+7PuteFDleIlvip6zlel
hsKvaqA1lJUR692EP0gpytQYoLNH23/OPMNzEgkYJXciARQSoACFBChAIQEKUEiAAhQSoACF
BChAIQEKUEiAAhQSoACFBChAIQEKUKiGB6C0DxI52zXsPDB2zT//MkuS2T/+8/35n80///Jg
Ppfz5Gz5cH7k+j0P9Gz5LdvHNlomucrl/Dpny+MkN0muczn/dcd2vnbb+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QXQ+61s4fJ1luvHqb5OiHdVtHj9YFqErJnUi/
J/mS5HMu8lsWuesC8vPG8s11b7p1f80i9z9Z9+eGuXNiypoJnB0d6z68VLnGuv+79CvvoruG
dP233N7J9NT8iPU/idTWQk/SNue/djv7LW1z/eTBrZzrde+TfPvpugCVqeGugvbb6KKKsvZ3
iG/Y16rFDLkvQ+/DyGsyWz3nd1D7fi2eMT9iLmMCmLAm0f8JjI8aKEAhAQpQSIACFBKgAIUE
KEAhAQpQSIACFBKgAIUEKDB1B7sZp2xceID6NEnSNN+zdDab7feIDQEKvCn7huaDbfVY1/3o
wBQVJ6o+UIBCNTxjc/10aoD+drWe984UfaDAWzNYZUyAAm/F4K1YAQpM3cG6/5xEAigkQAEK
CVCAQgIUoJAABSgkQAEKCVCAQgIUoJAABSgkQAEAAAAAAAAAAAAAAAAAAABgIv4fFmQme206
Si8AAAAASUVORK5CYII=]]>
							</image>
							<image icon="true" name="ctu48.png" width="48" height="48">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAACtUlEQVRoge2YoXLcMBCGf3UK
G3AF7YzFyoM6kye44KDiO3RHwu8VwluSQz5c0qKA5gnaKWppw2wQUIN7gC2w1ifLki3ZzkU3
9TfjsSWt17vWrtYyMDHxfyMc/WQbI6KntSYAIUrzXljGyDhHjemAaXT0Trw02hw21hCKEVsI
nRSTA89N5zKaJOktgJU2ts2yxdq8QcrdBsCNRVcB4BLAT9VeAbh1yeX5kuVARBBCIElSAiDy
fNm4yUxiG/fa9copVRq4tfSv1LEOlAMANh4AKEnShhNBhUwp2+b5cq0XtfOLR/zN7hyqQMrg
xqzZ5PJ8WclpxtdszrJFayHrxKzIv76/6aOmFYfxAEBS7qqGTwj5MgOwUWcfbjRZPhdAq/FM
FSG9HZByN8uyRXF+8chdG3WYFGjG/AxlvJvOcgJ7F9Ehy+gfKXf6qsPGCON4rRnGFKpflwGA
eagRvWZALW0zADOOfyn7aKoo+MLML05WF4NzQAuhUegy2KTTgSRJP6A+tXNV3FzYxj7jUE/e
o72eBOEzA3Pjge+09sPvH28BAEmS8rjNuAd0O2BL9t4cbR8wdJcXlAMxbSmZ4CQOTbKn5uQ/
pycHnpsqB/QE5TgfM2mpz8pGJCAEf7jVzpyJQfuBIdDIOlnR4E+JXm92RA4hpHUKBFt1eLNE
2gRbCAlLIdzy6hk+MxDmS1edCK0jFvn99VV17RtCcVUvG6QmS8U0Uf1ATAdefavsrmZgf311
WJk+fSWt7cXZxy8QZ/fdgga0n9fu09vmGPdB69OMrKUxASQsA8Y91nETlx6Xvk7KdcI/iYcY
MdR5+8O0xNYd0Ctdm/LQh/r8InHRqMDlmQS/C58QMnS1PcvHNtEx7suAP3PHRwR7GtvWq1pB
Tcaaz2Mi+Ld7G7E545yBE8kBAIH1IrYZmIiWf2FOAyn58r38AAAAAElFTkSuQmCC]]>
							</image>
						</images>
					</functionBlock>
					<functionBlock name="CTU" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<title>Up counter</title>
						<descr>&lt;HTML&gt;The CTU block &lt;b&gt;counts up&lt;/b&gt; for each FALSE-to-TRUE transition of the input CU and sets the output Q when the accumulated value (CV) reaches the preset value (PV) value.&lt;br/&gt;
&lt;img src= ctuscheme.png&gt;
&lt;ul&gt;
&lt;li&gt;rising edge of R reset CV to 0&lt;/li&gt;
&lt;li&gt;rising edge of CU increments CV by 1&lt;/li&gt;
&lt;li&gt;when CV reaches PV the output Q is set&lt;/li&gt;
&lt;li&gt;once CV is equal to PV its value remains until a rising edge of R&lt;/li&gt;
&lt;/ul&gt;</descr>
						<vars>
							<inputVars>
								<var name="CU" type="BOOL">
									<descr>Count-up on input rising edge</descr>
								</var>
								<var name="R" type="BOOL">
									<descr>Reset counter input</descr>
								</var>
								<var name="PV" type="INT">
									<descr>Preset value</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="Q" type="BOOL">
									<descr>Count-up output</descr>
								</var>
								<var name="CV" type="INT">
									<descr>Counter current value</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="CUEDGE" type="BOOL"/>
								<var name="MEMCU" type="BOOL"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
	(*	Check for reset input *)
	LD		R
	JMPCN	l0
	
	LD		0
	ST		CV
	JMP		l1

	(*	Check for increment enable *)
l0:
	LD		CU
	ANDN 	MEMCU
	ST 		CUEDGE
	
	LD 		CU
	ST 		MEMCU
	
	LD 		CUEDGE
	AND(	CV
	LT		16#7FFF
	)
	JMPCN	l1
	
	LD		CV
	ADD		1
	ST		CV
	
l1:

	(*	Counter output	*)
	LD		CV
	GE		PV
	ST		Q
	

]]>
						</sourceCode>
						<images>
							<image name="ctuscheme.png" width="336" height="200">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAVAAAADICAYAAAC+qrlDAAAKYUlEQVR4nO3dTXLbyqEG0I+p
t4DnuwRlCdIOQm8gKd9BFqA7Vwa6M5be6HoQza0FZGBVZQNmdiAtwVqClR3gDQCalExaQhOU
0NA5VSgZBAg2ZOhjd+OnEwAAAAAAAAAAAAAAAAAAAKCvppsARuVPr10AgFrNXrsAT3hc8xx7
eYE3RA0UoNCYa3S7+j3HXGbgDVEDBSg01trcU2fdx1pu4A1RAwWYMNeBAqOkBgpQSIACFBKg
AIUEKEAhAQpQSIACFBKgAIUEKEAhAQpQSIACFBo0QJvkvEm+NUnTTV+a5MOQnwFT0jRNmsad
ym9eF5ZfNwOzST53QXq636bdC0+ZjS/zsU5tiL72L4rX09U8myaZb1n2uauVvivfvOOLMiMI
SAHKz3U1z687ls33rIUKUIo9CKq+U9e8Lnrv05MAnYC9+0C7muVRkuWOVW67n8f7fhbAmAxx
Eumo+3n/xHqlTXgYxOyiHcrgudOD9w48MQ0uYwIoNESA3nU/n6phPlVDBajK3gE6a4PxLlvO
wHdWfZ+3O5YDvF0uY2KsNs92937vxln4oTkLzwPN9gvp/9jzEqZuM44vygwSoAe4U0i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FT2QOV2eI7z
PBww7jrJ71nkbmO9b0nutj6V/iI3SY6yyC9FZZiSi0Ged/q6Y8mMdR9eqlxj3f9daivvSPWv
gbbheZNknuSkG17gl6R7/SJHg5YQYKRKmvCf0obl+yxymyRZ5D75Pi7Sp2GK9ibNCqaxGes+
vFS5xrr/u9RW3lHpF6Bt7fJDkusuNNfa+dskx0MVDmDM+vaBrprnd1uXLvJ+r9LQ6tOvNNbB
usa6Dy9VrrHu/y61lXck+jbhje0O0HEZE0ChvgF6//QqAG9D3wBd9X1uv1TpIl+6az9XBG5f
U7iubqz78FLlGuv+71JbeUekX4C2F8lfJ/nQXQ+61s4fJ1luvHqb5OiHdVtHj9YFqErJnUi/
J/mS5HMu8lsWuesC8vPG8s11b7p1f80i9z9Z9+eGuXNiypoJnB0d6z68VLnGuv+79CvvoruG
dP233N7J9NT8iPU/idTWQk/SNue/djv7LW1z/eTBrZzrde+TfPvpugCVqeGugvbb6KKKsvZ3
iG/Y16rFDLkvQ+/DyGsyWz3nd1D7fi2eMT9iLmMCmLAm0f8JjI8aKEAhAQpQSIACFBKgAIUE
KEAhAQpQSIACFBKgAIUEKDB1B7sZp2xceID6NEnSNN+zdDab7feIDQEKvCn7huaDbfVY1/3o
wBQVJ6o+UIBCNTxjc/10aoD+drWe984UfaDAWzNYZUyAAm/F4K1YAQpM3cG6/5xEAigkQAEK
CVCAQgIUoJAABSgkQAEKCVCAQgIUoJAABSgkQAEAAAAAAAAAAAAAAAAAAABgIv4fFmQme206
Si8AAAAASUVORK5CYII=]]>
							</image>
							<image icon="true" name="ctu48.png" width="48" height="48">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAACtUlEQVRoge2YoXLcMBCGf3UK
G3AF7YzFyoM6kye44KDiO3RHwu8VwluSQz5c0qKA5gnaKWppw2wQUIN7gC2w1ifLki3ZzkU3
9TfjsSWt17vWrtYyMDHxfyMc/WQbI6KntSYAIUrzXljGyDhHjemAaXT0Trw02hw21hCKEVsI
nRSTA89N5zKaJOktgJU2ts2yxdq8QcrdBsCNRVcB4BLAT9VeAbh1yeX5kuVARBBCIElSAiDy
fNm4yUxiG/fa9copVRq4tfSv1LEOlAMANh4AKEnShhNBhUwp2+b5cq0XtfOLR/zN7hyqQMrg
xqzZ5PJ8WclpxtdszrJFayHrxKzIv76/6aOmFYfxAEBS7qqGTwj5MgOwUWcfbjRZPhdAq/FM
FSG9HZByN8uyRXF+8chdG3WYFGjG/AxlvJvOcgJ7F9Ehy+gfKXf6qsPGCON4rRnGFKpflwGA
eagRvWZALW0zADOOfyn7aKoo+MLML05WF4NzQAuhUegy2KTTgSRJP6A+tXNV3FzYxj7jUE/e
o72eBOEzA3Pjge+09sPvH28BAEmS8rjNuAd0O2BL9t4cbR8wdJcXlAMxbSmZ4CQOTbKn5uQ/
pycHnpsqB/QE5TgfM2mpz8pGJCAEf7jVzpyJQfuBIdDIOlnR4E+JXm92RA4hpHUKBFt1eLNE
2gRbCAlLIdzy6hk+MxDmS1edCK0jFvn99VV17RtCcVUvG6QmS8U0Uf1ATAdefavsrmZgf311
WJk+fSWt7cXZxy8QZ/fdgga0n9fu09vmGPdB69OMrKUxASQsA8Y91nETlx6Xvk7KdcI/iYcY
MdR5+8O0xNYd0Ctdm/LQh/r8InHRqMDlmQS/C58QMnS1PcvHNtEx7suAP3PHRwR7GtvWq1pB
Tcaaz2Mi+Ld7G7E545yBE8kBAIH1IrYZmIiWf2FOAyn58r38AAAAAElFTkSuQmCC]]>
							</image>
						</images>
					</functionBlock>
					<functionBlock name="CTD_UDINT" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<title>Down counter (UDINT data type)</title>
						<descr>&lt;HTML&gt;(Same as CTD but with PV and CV of &lt;b&gt;UDINT&lt;/b&gt; data type)&lt;br/&gt;&lt;br/&gt;
The CTD_UDINT block &lt;b&gt;counts down&lt;/b&gt; for each FALSE-to-TRUE transition of the input CD and sets the output Q when the accumulated value (CV) reaches the 0 value.&lt;br/&gt;
&lt;img src= ctdscheme.png&gt;
&lt;ul&gt;
&lt;li&gt;rising edge of LD set CV to the value of PV&lt;/li&gt;
&lt;li&gt;rising edge of CD decrements CV by 1&lt;/li&gt;
&lt;li&gt;when CV reaches 0 the output Q is set&lt;/li&gt;
&lt;li&gt;once CV is 0 its value remains 0 until a rising edge of LD&lt;/li&gt;
&lt;/ul&gt;</descr>
						<vars>
							<inputVars>
								<var name="CD" type="BOOL">
									<descr>Count-down on input rising edge</descr>
								</var>
								<var name="LD" type="BOOL">
									<descr>Preset counter input</descr>
								</var>
								<var name="PV" type="UDINT">
									<descr>Preset value</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="Q" type="BOOL">
									<descr>Count-down output</descr>
								</var>
								<var name="CV" type="UDINT">
									<descr>Counter current value</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="CDEDGE" type="BOOL"/>
								<var name="MEMCD" type="BOOL"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
	(*	Check for reset input *)
	LD		LD
	JMPCN	l0
	
	LD		PV
	ST		CV
	JMP		l1

	(*	Check for increment enable *)
l0:
	LD 	CD
	ANDN 	MEMCD
	ST 		CDEDGE
	
	LD 		CD
	ST 		MEMCD
	
	LD 		CDEDGE
	AND(	CV
	GT		0
	)
	JMPCN	l1
	
	LD		CV
	SUB		1
	ST		CV
	
l1:

	(*	Counter output	*)
	LD		CV
	LE		0
	ST		Q
	

]]>
						</sourceCode>
						<images>
							<image name="ctdscheme.png" width="336" height="200">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAVAAAADICAYAAAC+qrlDAAAKr0lEQVR4nO3dzXHiwBqF4aNb
NwFPCNwQTAajCYEJwd4zC7yj2NmLYW+HYEKwJgMIwYRgh6C7aAkEBkN/+qFbvE+VyiNAQnjk
Q/9JLQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF95sQBAUP5z6QMAgFgllz6AE/ZL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jnonN9B7J9resZ6wBjGBAA9lku0fwIIDyVQADAiQAHAiAAF
ACMCFACMCFAAMCJAAcCIAAUAIwIUAIwIUAB919rFOLZ54QEgPrkk5fkmS5MkqXeLDQIUwFWp
G5o7+/J4LdejA+gjc6LSBgoARjHcY3N7d2oA8Hes9lw7U2gDBXBtGiuMEaAArkXjtVgCFEDf
tdb8RycSABgRoABgRIACgBEBCgBGBCgAGBGgAGBEgAKAEQEKAEYEKAAYEaAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAABAT/wfCXs1gPu5dKwAAAAASUVORK5CYII=]]>
							</image>
							<image icon="true" name="ctd48.png" width="48" height="48">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAADBElEQVRoge1YvW7bMBD+WHRs
AthDA1Bbpg7NVDRP4Ayd2jeQJmdpZ79C9naJJ3nu0k4Zmido4KlZm40EmiEGnO7XQaJ8okiL
st2Yaf0BhCTyJN7H++GJwA47/N8Qnn5yjRHR39WmA4Qo1HviGCPrGjVsArbS0ZN4aj0bt3G6
UIxwudCjwo7AttGaRqXMhwDOHTIzACdKpVMASJLJCMCZTw7AtHweAPhm66F11lSCCEIIEBGS
ZAKXjB3ELkwBjB39w7KddpS7YXIDAIfLJjd7j1IpkgQNEp02Mg4pcwIwVio9PTq+xZ268OpQ
KnzqGDtHQc5rARtJMoFS6dKNzIuXr3+BiBof/vH9eZfPBMG36xeWmFTPIS4EAJAyP7tTF70k
AQD0yu4ZE+kBGLGxldFWshQWyAAEEpAy76Ewta3c9Oj41tyPymZjBndsNObQOpsBqK1wG4Jc
SOtspnXW7ydvhFKpANAvhwZMzJATVutjkYGW4aeUucliFNDCCRhcXx1ACAGzUkDh/xuKgR6A
Xuk+SxOI1lk1HhwDPjAX2ghY3hdwFJNceSCAgJT5KxT+HwrXpvcZwGV5f4hFrBgXrL1jUqSU
eY2EUqkwwWsQYgEfgRmA8fXVgZnM9LtkbywCtsyQyVXQOqtIFCufBqhb4MH+A9b9y+sUAzH9
Uhp0DmLjn7Hg3ymnqd5JFPEvJVeMW8A+jWjsejGCExCOa5RW4CsaGsRtVtga0RACbcpt1cXW
roVKhJLYjKWIgDKdewk4Kym/aNC0gXKtuP/wrrrflAVC0ZWEWUfX1foyUZEzi3KBqj7TH1HD
s8WpTMVk/v5t1bn/6SsBELyvDXsfv0DsXbYLWqD7Qe09/myP1fp+n9QJsHIYWmcEED/o5bDN
F5pifXLeGKJ5fSh5UejIj1VCY2BVJdYl756MFZTsg8SCpJGDtkKA5kKIfa4Xv4oGAT4PdyE2
97L5XBxc8qJlPBQrnMxtD6Iz09gqUG9VvCl7PiSEOXZfhtjIeC3wSGIAQMdCMDYL7BAt/gCj
bz7ec2bPQgAAAABJRU5ErkJggg==]]>
							</image>
						</images>
					</functionBlock>
					<functionBlock name="CTD_DINT" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<title>Down counter (DINT data type)</title>
						<descr>&lt;HTML&gt;(Same as CTD but with PV and CV of &lt;b&gt;DINT&lt;/b&gt; data type)&lt;br/&gt;&lt;br/&gt;
The CTD_DINT block &lt;b&gt;counts down&lt;/b&gt; for each FALSE-to-TRUE transition of the input CD and sets the output Q when the accumulated value (CV) reaches the 0 value.&lt;br/&gt;
&lt;img src= ctdscheme.png&gt;
&lt;ul&gt;
&lt;li&gt;rising edge of LD set CV to the value of PV&lt;/li&gt;
&lt;li&gt;rising edge of CD decrements CV by 1&lt;/li&gt;
&lt;li&gt;when CV reaches 0 the output Q is set&lt;/li&gt;
&lt;li&gt;once CV is 0 its value remains 0 until a rising edge of LD&lt;/li&gt;
&lt;/ul&gt;</descr>
						<vars>
							<inputVars>
								<var name="CD" type="BOOL">
									<descr>Count-down on input rising edge</descr>
								</var>
								<var name="LD" type="BOOL">
									<descr>Preset counter input</descr>
								</var>
								<var name="PV" type="DINT">
									<descr>Preset value</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="Q" type="BOOL">
									<descr>Count-down output</descr>
								</var>
								<var name="CV" type="DINT">
									<descr>Counter current value</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="CDEDGE" type="BOOL"/>
								<var name="MEMCD" type="BOOL"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
	(*	Check for reset input *)
	LD		LD
	JMPCN	l0
	
	LD		PV
	ST		CV
	JMP		l1

	(*	Check for increment enable *)
l0:
	LD 	CD
	ANDN 	MEMCD
	ST 		CDEDGE
	
	LD 		CD
	ST 		MEMCD
	
	LD 		CDEDGE
	AND(	CV
	GT		-2147483648
	)
	JMPCN	l1
	
	LD		CV
	SUB		1
	ST		CV
	
l1:

	(*	Counter output	*)
	LD		CV
	LE		0
	ST		Q
	

]]>
						</sourceCode>
						<images>
							<image name="ctdscheme.png" width="336" height="200">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAVAAAADICAYAAAC+qrlDAAAKr0lEQVR4nO3dzXHiwBqF4aNb
NwFPCNwQTAajCYEJwd4zC7yj2NmLYW+HYEKwJgMIwYRgh6C7aAkEBkN/+qFbvE+VyiNAQnjk
Q/9JLQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF95sQBAUP5z6QMAgFgllz6AE/ZLnqEfL4Ar
QgkUAIxCLtEda/cM+ZgBXBFKoABgFGpp7lSve6jHDeCKUAIFgB5jHCiAIFECBQAjAhQAjAhQ
ADAiQAHAiAAFACMCFACMCFAAMCJAAcCIAAUAIwIUAIwaDdBcmuTSRy7lxfKWS6Mm3wPokzzP
ledcqXz1irB8rwZmLr0WQXpXb9dcCw+bypd5qIsL0Uv/onA5Rckzz6X0wHOvRan0xr57zi/Y
BBCQBCi+V5Q83488l9YshRKgMNsJKt+lqF6btj29EKA9ULsNtChZDiRlR16yKn7e1n0vAAhJ
E51Ig+Ln54nXWavwQCOSmZvK4NxlZ9uGF/QDw5gAwKiJAF0XP0+VME+VUAEgKrUDNHHBuNaB
HvhC2fa5OvI8AFwvh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75l3z3j/nUehQY
xgQAPZYXCwAEhRIoABgRoABgRIACgBEBCgBGBCgAGBGgAGBEgAKAEQEKAEYEKAAYEaAAYESA
AoARAQoARgQoABgRoABgRIACgJFtSg83OdykWEoLSQ87k8XN9CpptLf1Sm5SOab2KDUz39Nl
55IJ9TN0dVyhfv5jYjveQPmXQF14LiWlkobF9AI/pOLxmQYHtvqhqZLitQtJkyJcASBalir8
s1xY/tJUK0nSVJ/SZq6k52+3diXP35JGmu2UYOHmhfFdQhPqZ+jquEL9/MfEdrxB8QtQV7oc
yVXBP3eec+srSbcn9zNVVrz2zuv9ASAgvm2gZfV8ffDZqX557CuTq8oPdtpN4TeDY6jzgof6
Gbo6rlA//zGxHW8gfKvwNy0cQxv7BIDWMYwJAIx8A/Tz9Eu8tbFPAGidb4CWbZWHhipJM71p
po8z95VKWtP+uacP4+pC/QxdHVeon/+Y2I43IH4B6sJuITcEabft0q3fynUOfW+mUfHaF6/3
B4CAWK5EepD0JulVM91rqnURnq+V549zYz8f5Xs1UjNXTvRZ3oPe0VA/Q1fHFernP8bveKfF
GNLt37K7kunUesD8O5FcKXQoV51/Lz7sh1xb5vBIlfxDM+XFa1NJ95puBt4DQJRiuKrAfRvN
ojhWf218w16qFNPkZ2n6MwRekjnonN9B7J9resZ6wBjGBAA9lku0fwIIDyVQADAiQAHAiAAF
ACMCFACMCFAAMCJAAcCIAAUAIwIUAIwIUAB919rFOLZ54QEgPrkk5fkmS5MkqXeLDQIUwFWp
G5o7+/J4LdejA+gjc6LSBgoARjHcY3N7d2oA8Hes9lw7U2gDBXBtGiuMEaAArkXjtVgCFEDf
tdb8RycSABgRoABgRIACgBEBCgBGBCgAGBGgAGBEgAKAEQEKAEYEKAAYEaAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAABAT/wfCXs1gPu5dKwAAAAASUVORK5CYII=]]>
							</image>
							<image icon="true" name="ctd48.png" width="48" height="48">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYA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QgAAAABJRU5ErkJggg==]]>
							</image>
						</images>
					</functionBlock>
					<functionBlock name="CTD" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<title>Down counter</title>
						<descr>&lt;HTML&gt;The CTD block &lt;b&gt;counts down&lt;/b&gt; for each FALSE-to-TRUE transition of the input CD and sets the output Q when the accumulated value (CV) reaches the 0 value.&lt;br/&gt;
&lt;img src= ctdscheme.png&gt;
&lt;ul&gt;
&lt;li&gt;rising edge of LD set CV to the value of PV&lt;/li&gt;
&lt;li&gt;rising edge of CD decrements CV by 1&lt;/li&gt;
&lt;li&gt;when CV reaches 0 the output Q is set&lt;/li&gt;
&lt;li&gt;once CV is 0 its value remains 0 until a rising edge of LD&lt;/li&gt;
&lt;/ul&gt;</descr>
						<vars>
							<inputVars>
								<var name="CD" type="BOOL">
									<descr>Count-down on input rising edge</descr>
								</var>
								<var name="LD" type="BOOL">
									<descr>Preset counter input</descr>
								</var>
								<var name="PV" type="INT">
									<descr>Preset value</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="Q" type="BOOL">
									<descr>Count-down output</descr>
								</var>
								<var name="CV" type="INT">
									<descr>Counter current value</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="CDEDGE" type="BOOL"/>
								<var name="MEMCD" type="BOOL"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
	(*	Check for reset input *)
	LD		LD
	JMPCN	l0
	
	LD		PV
	ST		CV
	JMP		l1

	(*	Check for increment enable *)
l0:
	LD 		CD
	ANDN 	MEMCD
	ST 		CDEDGE
	
	LD 		CD
	ST 		MEMCD
	
	LD 		CDEDGE
	AND(	CV
	GT		-32768
	)
	JMPCN	l1
	
	LD		CV
	SUB		1
	ST		CV
	
l1:

	(*	Counter output	*)
	LD		CV
	LE		0
	ST		Q
	

]]>
						</sourceCode>
						<images>
							<image name="ctdscheme.png" width="336" height="200">
								<![CDATA[iVBORw0KGgoAAAANS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H4B6sJuITcEabft0q3fynUOfW+mUfHaF6/3
B4CAWK5EepD0JulVM91rqnURnq+V549zYz8f5Xs1UjNXTvRZ3oPe0VA/Q1fHFernP8bveKfF
GNLt37K7kunUesD8O5FcKXQoV51/Lz7sh1xb5vBIlfxDM+XFa1NJ95puBt4DQJRiuKrAfRvN
ojhWf218w16qFNPkZ2n6MwRekjnonN9B7J9resZ6wBjGBAA9lku0fwIIDyVQADAiQAHAiAAF
ACMCFACMCFAAMCJAAcCIAAUAIwIUAIwIUAB919rFOLZ54QEgPrkk5fkmS5MkqXeLDQIUwFWp
G5o7+/J4LdejA+gjc6LSBgoARjHcY3N7d2oA8Hes9lw7U2gDBXBtGiuMEaAArkXjtVgCFEDf
tdb8RycSABgRoABgRIACgBEBCgBGBCgAGBGgAGBEgAKAEQEKAEYEKAAYEaAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAABAT/wfCXs1gPu5dKwAAAAASUVORK5CYII=]]>
							</image>
							<image icon="true" name="ctd48.png" width="48" height="48">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAADBElEQVRoge1YvW7bMBD+WHRs
AthDA1Bbpg7NVDRP4Ayd2jeQJmdpZ79C9naJJ3nu0k4Zmido4KlZm40EmiEGnO7XQaJ8okiL
st2Yaf0BhCTyJN7H++GJwA47/N8Qnn5yjRHR39WmA4Qo1HviGCPrGjVsArbS0ZN4aj0bt3G6
UIxwudCjwo7AttGaRqXMhwDOHTIzACdKpVMASJLJCMCZTw7AtHweAPhm66F11lSCCEIIEBGS
ZAKXjB3ELkwBjB39w7KddpS7YXIDAIfLJjd7j1IpkgQNEp02Mg4pcwIwVio9PTq+xZ268OpQ
KnzqGDtHQc5rARtJMoFS6dKNzIuXr3+BiBof/vH9eZfPBMG36xeWmFTPIS4EAJAyP7tTF70k
AQD0yu4ZE+kBGLGxldFWshQWyAAEEpAy76Ewta3c9Oj41tyPymZjBndsNObQOpsBqK1wG4Jc
SOtspnXW7ydvhFKpANAvhwZMzJATVutjkYGW4aeUucliFNDCCRhcXx1ACAGzUkDh/xuKgR6A
Xuk+SxOI1lk1HhwDPjAX2ghY3hdwFJNceSCAgJT5KxT+HwrXpvcZwGV5f4hFrBgXrL1jUqSU
eY2EUqkwwWsQYgEfgRmA8fXVgZnM9LtkbywCtsyQyVXQOqtIFCufBqhb4MH+A9b9y+sUAzH9
Uhp0DmLjn7Hg3ymnqd5JFPEvJVeMW8A+jWjsejGCExCOa5RW4CsaGsRtVtga0RACbcpt1cXW
roVKhJLYjKWIgDKdewk4Kym/aNC0gXKtuP/wrrrflAVC0ZWEWUfX1foyUZEzi3KBqj7TH1HD
s8WpTMVk/v5t1bn/6SsBELyvDXsfv0DsXbYLWqD7Qe09/myP1fp+n9QJsHIYWmcEED/o5bDN
F5pifXLeGKJ5fSh5UejIj1VCY2BVJdYl756MFZTsg8SCpJGDtkKA5kKIfa4Xv4oGAT4PdyE2
97L5XBxc8qJlPBQrnMxtD6Iz09gqUG9VvCl7PiSEOXZfhtjIeC3wSGIAQMdCMDYL7BAt/gCj
bz7ec2bPQgAAAABJRU5ErkJggg==]]>
							</image>
						</images>
					</functionBlock>
					<functionBlock name="RS" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<title>Bistable, reset dominant</title>
						<descr>&lt;HTML&gt;Bistable, reset dominant&lt;/br&gt;&lt;/br&gt;
&lt;img src= rsscheme.png &gt;</descr>
						<vars>
							<inputVars>
								<var name="s" type="BOOL">
									<descr>Logic input</descr>
								</var>
								<var name="r1" type="BOOL">
									<descr>Reset input</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="q1" type="BOOL">
									<descr>Bistable output</descr>
								</var>
							</outputVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
	LD		s
	OR		q1
	ANDN	r1
	ST		q1
]]>
						</sourceCode>
						<images>
							<image name="rsscheme.png" width="290" height="146">
								<![CDATA[iVBORw0K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0+Hzl1CifoMK//+7b7yVERAXDnPnl+Tt8suTIb7oRXyF99
u2q73wcqogEggDB2BFHG6BPCVBBEGaMSwlQQRADcEUQA3BFEANwRRADcEUQA3BFEANy5j6wG
MF67ToJIRQTgGIKZhfrMjKWOlxMyhtgBSGEte6iIALjr2keU6uynn/uNiV4PQJ7qe1Eb/+bp
rAZwDFuLjk5BlOrSP9UOq9wuJwQgHdvQOx1C+OVyQlREAI5iW9FBEAHoza57PBw1A+COIALg
jiAC4I4gAgAAAAAAAAC4+x/I2TESQcxc7AAAAABJRU5ErkJggg==]]>
							</image>
						</images>
					</functionBlock>
					<functionBlock name="SR" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<title>Bistable, set dominant</title>
						<descr>&lt;HTML&gt;Bistable, set dominant&lt;/br&gt;&lt;/br&gt;
&lt;img src= srscheme.png &gt;</descr>
						<vars>
							<inputVars>
								<var name="s1" type="BOOL">
									<descr>Logic input</descr>
								</var>
								<var name="r" type="BOOL">
									<descr>Reset input</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="q1" type="BOOL">
									<descr>Bistable output</descr>
								</var>
							</outputVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[	
	LDN		r
	AND		q1
	OR		s1
	ST		q1
]]>
						</sourceCode>
						<images>
							<image name="srscheme.png" width="290" height="146">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAASIAAACSCAYAAADhA8d3AAAHFElEQVR4nO3d4U3jSBjG8ec9
7eeTsiVACaGE3QIOCSSuAK4EKAFKgAIOCSSuALYEUsJSwqK7BuY+jL04Xie2k3Hesf3/SVY2
OJsMwXnyejweSwAAAAAAZ7ZpRQhhuBc1K5/chnwdAHkyW4+e35zaISmGXb1BAObn4EFUqYbW
/g1gvlwrohJVETBvBw2iDRUQVREwc1lURADm7dOBX6/cBwu1+wBm7KBBVB6qr/YJcfgeALtm
ANwRRADcEUQA3BFEANwRRADcEUQA3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BBEA
dwQRAAAAAAAAAMDd/4pQhvHzOGzbAAAAAElFTkSuQmCC]]>
							</image>
						</images>
					</functionBlock>
					<functionBlock name="FF_D" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<descr>D-type flip-flop</descr>
						<vars>
							<inputVars>
								<var name="d" type="BOOL">
									<descr>Input</descr>
								</var>
								<var name="clk" type="BOOL">
									<descr>Clock</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="q" type="BOOL">
									<descr>Out</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="m" type="BOOL">
									<initValue>TRUE</initValue>
								</var>
								<var name="ok" type="BOOL"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[	
	LD		clk
	ANDN	m
	ST		ok
	
	LD		clk
	ST		m

	LD		ok
	RETCN	

	LD		d
	ST		q

]]>
						</sourceCode>
					</functionBlock>
					<functionBlock name="TP" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<title>Pulse generator</title>
						<descr>&lt;HTML&gt;Pulse generator&lt;/br&gt;&lt;/br&gt;
&lt;img src= ptscheme.png &gt;</descr>
						<vars>
							<inputVars>
								<var name="IN" type="BOOL">
									<descr>Timer input source</descr>
								</var>
								<var name="PT" type="UDINT">
									<descr>Preset time value</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="Q" type="BOOL">
									<descr>Pulse output</descr>
								</var>
								<var name="ET" type="UDINT">
									<descr>Actual timer value</descr>
								</var>
							</outputVars>
							<externalVars>
								<var name="sysTimer" type="UDINT">
									<descr>1 ms system timer</descr>
								</var>
							</externalVars>
							<localVars>
								<var name="timStart" type="UDINT">
									<descr>Time value at start of counting</descr>
								</var>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
	(*	Check if in counting	*)

	LD		Q
	JMPCN	l10
	
	(*	Update actual time *)
	LD		sysTimer
	SUB		timStart
	ST		ET	
	
	(*	Update output *)
	LD		ET
	LT		PT
	ST		Q
	RET
	
l10:

	(*	Check for input status *)

	LD		IN
	JMPCN	l11
	
	LD		ET
	GE		PT
	RETC

	LD		sysTimer
	ST		timStart
	
	LD		TRUE
	ST		Q
	
l11:
	
	(*	No input and no counting active *)
	LD		0
	ST		ET
	

]]>
						</sourceCode>
						<images>
							<image name="ptscheme.png" width="265" height="146">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAQkAAACSCAYAAABWvj9QAAAH+klEQVR4nO3d743TSBjH8d9z
ugaWEkC6BjYlcAWABNJeAVACK91rJCgBCgBpT9or4Cgh2wASlAAlzL1wzDpee+L/M5nn+5Gs
JWsS+9lknjwztscSAAAAAKzC+laEENbbqFn94rbmdgAMZ9adDn7beD+OhBB6dwxAHjZPEo0q
4ujfAPKUtJKoUU0A+do0SfRUDlQTQMayqCQA5Ov3jbdX9ytC6zGATG2aJOrDnc0xCA6BAnmj
uwEgiiQBIIokASCKJAEgiiQBIIokASCKJAGUYqXLG8YlCbMLmX2QWWgsH2T2eJW929pxXOkX
j3EjO8OTRJUI9pIeS3qiEEzSk8PjfTGJApjKLM2ydlh9Kx6cCWl2I+lS0k4h/Gyt+ybpp0LY
DdporpPONPYr6X7Up61XiXh9ecS9bcxrSHU1c92GzO7/PcG8SWeqKuGFpC8PEkTlo6RLqgm4
FkKaZWVDr924PPy861n//fDzqaqEcf5SVjgp59dIFTdzimRr6JhEXSF0VRFNFzP2BUCGOAQK
IGpokqi7E6cqhVOVBoAzMzRJ1GMRlz3r6+7Il3m7gyP005EBDoE2NQ8Fph243HY/coi73odz
PgSaWtJDoJXrw8+bX4c6qzMw/1PVDXk5ee8AZGt4kgjhu6SdqvGJb4fM/0PVYc+7w3oAhRl3
dCOEnwrhtUKwX0tVYTyVGadmAwWafwg0hPequhoc2QAKxA2Dm3IYwEuxHznEzcBlclneMBhA
/kgSQEna1cCpxwNsfQevI0EKnDAU5e/vw8Qzp9VdsnY3sX5sdv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f0/q9qj8n7cc6nPTWXj8WYxI9PDYWjzHjtLSVxF//2thJ
Z2Lq0njprN98vY3KbxprHo7eh1y7Xu3kfurxWFy70aNvPsAcy86l1LHl2hiQRn+G+fTs1GnZ
13p4G8BBZ1ya2X2fqdDJcIFzY9adDnqTxJqNlyQB5KcvSTBwCSCKJAEgiiQBIIokASCKJAEg
iiQBIIokASCKMy5bzDTpxI0QzvdU6qkxe3LO7+9cVBIAonqThJkuzBTMdNP43c3hd696nvPD
TPs1dnRrIciGLKn3c0lDYx6zSOexnHp/ze6XNW2xjbGmVhLvzHSx6J4AyNLUJHEh6cOSO4Iy
hTBtmfPcqdsbGsuattjGWFOTxEdJL/q6HQDKMTVJXEu6k/SGbgdQtjlHN65VzR1BtwOLy63k
9mxykghBX0S3AyjerPMkQtBrSd9FtwMo1hInU71W1e0o/oY9gEezT8sOQV/M9FGiywGUaJHT
shvdDgCFWfLajesFXwtAJpgtu6W+InLodRlj/3+OSohhLY0rZC2zj+rimC0bwCQkCQBRiSed
CSG3y2KnYuKW4mX5Wa27iM0uY7uLNLfLRCUBICpxJWGmTL+AzYZdP9A32Jfjtw4m6Xwnh3w2
1vgMdG33sJ3m1tpbnrUnVBIAojgEegaGVjXAHBwCPWMkCKREksgY4xrIAUkiY1QQyAFJAkAU
SQJAFEkCQBRJAkAUSQJAFEkCQFTiazcAbGnK2c5UEoBPwcxC36nYTaOu3WhkIQAFCSEY124A
mGTsmMRSVxP86hct9HoAhmn3Bg4zW/U3RQYuAZ8Gf0GPShJLzf3QzFrMJwFsqjc5MCYBYBKS
BIAokgSAKJIEgCiSBIAokgQAAAAAAACA7PwPE9lwMokr1EsAAAAASUVORK5CYII=]]>
							</image>
							<image icon="true" name="tp34.png" width="34" height="34">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAACIAAAAiCAYAAAA6RwvCAAAAxklEQVRYhe2Waw6EIAyEp8bT
6aFwD8X5un/MRqBkYB+mm/RLjLFaKENbBIIgCD5DVNWwimE0UJWv+AFYhhxvYCXvm8hP2Mqn
/f5GEcDOIT7ypJ8bRSKQmvVS+4I6q619vtLrG+N+rzndKDLYCn+PG0UWqOKOS7ajuNc2s6HJ
/mh2THOiXczyAyCaE1WEd1Z7wuJZc2pss7AcMVUYWOHAGVDyliJAGwxThQXvqGqc4CYQwXZ0
zxrNSTolycflf3HFd24UCQLGE7KZdlKKljJmAAAAAElFTkSuQmCC]]>
							</image>
						</images>
					</functionBlock>
					<functionBlock name="TON" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<title>On-delay timer</title>
						<descr>&lt;HTML&gt;The TON block produces a delayed output Q of the input IN. The delay time is expressed in milliseconds on the PT input.&lt;/br&gt;&lt;/br&gt;
&lt;img src= tonscheme.png&gt;
&lt;ul&gt;
&lt;li&gt;if IN is FALSE Q is false&lt;/li&gt;
&lt;li&gt;Q becomes TRUE as IN remains TRUE for PT milliseconds&lt;/li&gt;
&lt;li&gt;Q remains TRUE until IN remains TRUE&lt;/li&gt;
&lt;/ul&gt;</descr>
						<vars>
							<inputVars>
								<var name="IN" type="BOOL">
									<descr>Timer input source</descr>
								</var>
								<var name="PT" type="UDINT">
									<descr>Preset time value (ms)</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="Q" type="BOOL">
									<descr>Timer output</descr>
								</var>
								<var name="ET" type="UDINT">
									<descr>Timer current value (ms)</descr>
								</var>
							</outputVars>
							<externalVars>
								<var name="sysTimer" type="UDINT">
									<descr>1 ms system timer</descr>
								</var>
							</externalVars>
							<localVars>
								<var name="timStart" type="UDINT">
									<descr>Time value at start of counting</descr>
								</var>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
	(*	Check if in counting	*)

	LD		IN
	JMPCN	lReset

	(*	Check if Q is TRUE *)
	LD		Q
	RETC
	
	(*	Check if already in counting *)
	LD		timStart
	EQ		0
	JMPCN	lUpdate

	(*	Start of counting *)
	LD		sysTimer
	ST		timStart
	
lUpdate:

	(*	Update timer and check if time elapsed *)
	LD		sysTimer
	SUB		timStart
	ST		ET
	GE		PT
	ST		Q
	RETCN

	(*	Limit actual time value *)
	LD		PT
	ST		ET
	RET

lReset:

	(*	Reset status *)
	LD		0
	ST		ET
	ST		timStart
	LD		FALSE
	ST		Q

]]>
						</sourceCode>
						<images>
							<image name="tonscheme.png" width="230" height="146">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAOYAAACSCAYAAABR2bZsAAAHoUlEQVR4nO3d7W3bSBSF4XMX
24BTQgJsA1YJ2QJiIAa8BSQlxMD+DpCUYBcQA17AW8C6BLmBAEkJcQmzPyhaFC3K/BiS94rv
Awi2REgaUXM0Q3I4lAAAAICQrGlBSmm8NzUrX9zGfB8gErNtHH+bsRxKKe0UBkBh8mBWWsud
/wFszdpilmg1gV2TBrOhhaTVBGpctJgAdv0+8fuVfdZUuw+gYtJglodGqtuUHC4BnqMrCzhE
MAGHCCbgEMEEHCKYgEMEE3CIYAIOdQum2YnMrmSWKrcrmb0eqXyYyu536usWRcYx3+2DWYRv
Lem1pDdKySS92dxfE06EYZb3NkYRmxY8G5FjdivpVNJKKT3Wlv2Q9KiUVq3elBOl98v9JXdZ
t5XvJG8hBinKVDQC+Yy1ns26rfOa7idKF63he0n3z0JZuJZ0SquJEFLKextB267s6ebvQ8Py
n5u/b4cVBy4qTO6K66jCR9E2mGVLuK+1rDoZUBYAGxwuARxqG8yyq/pSi/hSiwqghbbBLLct
TxuWl13d+2HFASBxuMSXgbvbB7739nCJl++kLFPuwyVjmfxwSeFy8/f26bBIMRLoPxVd3PPe
JQKwo30wU/opaaVie/PH5tfsl4pDJA+b5QAy6LZXNqVHpfRRKdnTrWhJ38qMYXlAJsMPl6T0
VUU3lj2yQCZcVMgTdv7sirbzZyA3FxUCsB/BBHKqn7ny0v0GU8/EviNJaazz2cJifTzn7WTp
smtd7/6X98127/c4lW7WYAKL0fEHd9ZgmuTsp7Cn6s6SKC1enx080382nytzux6s9ljz/Y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imtk9rmEwo4pKiEV
PaYlf2+NTeyYM9iZ2Xbj2OlMecDUzLZxZOcP4BDBBBwimIBDBBNwiGACDhFMwCGCCTh0dCN/
zDTqgdGU8s+7M3aZj8EY690zWkzAocZgmunETMlsOyTPTLebxz40POeXmdZjFLSrlGSbX9lB
t8rrTFbmnLehn3+q24HyS5LMtrcxTfEebfRtMb+Y6SRrSQA86buNeSLpSsXsBq4tfShu389v
5m/dTVEeL5+5b4t5Lel9U5cWwDB9g3kp6UHSJ7q0QH5D9speqph1/SpTWeCIly7dUvUOZkq6
F11aYBSDjmOmpI+SfoouLZBVjgEGH1V0ad1PAg1EMXhIXkq6N9O1RHcWyCXLkLxKlxZABjnH
yl5mfC1g0Y5ulrzyTI3c41vHet2xXzu6ypk3duyHcJglD3COYAIOzXyidEoeTrHpgpOaZ+Oy
rpSbH9XNkXr3u093nBYTcGjmFtNMIzVAQ09b2vPr7PD3ehH2rvc23+0YLey+9928T/Xd6u/c
uSS0mIBDR3e4BIiKwyWAcwQTcIhgAg4RTMAhggk4RDABhwgm4BDBBBwimIBDR3cZPsCztqPe
aDGBeSQzS9Yw0r7TWNlK2gFklFIyxsoCznXdxsx1httTPzvT6wFR1HudmxkQdqPAzh9gHgcb
pU7BzHXuZPXXgfMxsTCNgWQbE3COYAIOEUzAIYIJOEQwAYcIJgAAAAAAwBH7Hwwz9gCyftvv
AAAAAElFTkSuQmCC]]>
							</image>
							<image icon="true" name="ton1.png" width="48" height="58">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAADAAAAA6CAYAAAD2mdrhAAAD4klEQVRoge3YT4hVdRQH8M91
akhpIVOjmxYR1K4CIUTQyQYai3YWFVFtRPtjjNbCTUQgropqksqRqU1CloS0CjSw0EBECsqN
IESLNs0kTYvSjPG1+J3nez7nvfe7902TyvvC45537znfc869vz/nd+ijjz766KOPPvqojKLt
k2dvXwj+WgWbosmuIX/887yxLqkU1lWEGxbJT/sv3V2/o+01/wX6Cfzf6DQHrlwJLpevClzz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ptHcXRE60xrN3cPxy17n++ij
j+sc/wLOpNwgfFLcXQAAAABJRU5ErkJggg==]]>
							</image>
						</images>
					</functionBlock>
					<functionBlock name="TOF" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<title>Off-delay timer</title>
						<descr>&lt;HTML&gt;The TOF block produces a delayed de-activation of the output Q with respect of the input IN. The delay time is expressed in milliseconds on the PT input.&lt;/br&gt;&lt;/br&gt;
&lt;img src= tofscheme.png&gt;
&lt;ul&gt;
&lt;li&gt;if IN is TRUE then Q is TRUE&lt;/li&gt;
&lt;li&gt;Q becomes FALSE after PT milliseconds from IN becomes FALSE&lt;/li&gt;
&lt;li&gt;Q remains FALSE until IN remains FALSE&lt;/li&gt;
&lt;/ul&gt;</descr>
						<vars>
							<inputVars>
								<var name="IN" type="BOOL">
									<descr>Timer input source</descr>
								</var>
								<var name="PT" type="UDINT">
									<descr>Preset time value (ms)</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="Q" type="BOOL">
									<descr>Timer output</descr>
								</var>
								<var name="ET" type="UDINT">
									<descr>Timer current value (ms)</descr>
								</var>
							</outputVars>
							<externalVars>
								<var name="sysTimer" type="UDINT">
									<descr>1 ms system timer</descr>
								</var>
							</externalVars>
							<localVars>
								<var name="timStart" type="UDINT">
									<descr>Time value at start of counting</descr>
								</var>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
	(*	Check if in counting	*)

	LD		IN
	JMPC	lReset

	(*	Check if falling edge of IN	*)
	LD		Q
	RETCN

	(*	Check if already in counting *)
	LD		timStart
	EQ		0
	JMPCN	lUpdate
	
	(*	Start of counting *)
	LD		sysTimer
	ST		timStart

lUpdate:
	
	(*	Update timer and check if time elapsed *)
	LD		sysTimer
	SUB		timStart
	ST		ET
	GE		PT
	STN		Q
	RETCN
	
	(*	Limit actual time value *)
	LD		PT
	ST		ET
	RET

lReset:

	(*	Reset status *)
	LD		0
	ST		ET
	ST		timStart
	LD		TRUE
	ST		Q

]]>
						</sourceCode>
						<images>
							<image name="tofscheme.png" width="243" height="146">
								<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAPMAAACSCAYAAACQXvzAAAAIkklEQVR4nO3d/23bRhjG8eeK
LuCMkABdwBohHSAGYsAdIBkhBvp3gXiEeoAacAF3gHoEaYECyQjxCNc/KEoULUpH8u54fPn9
AEJC0aLIEx+9/KWjBAAAACAy1zXCe5/uTZ2rJ+5Svg8wF851RjHYTxHmYzDvfZSFADBBmBtV
+eD/AMaZtDLXqM7AeFnD3FGJqc5ABEVUZgDj/Zz5/ertad8aBjBS1jDXp6Ga+8icmgLiYDMb
MIIwA0YQZsAIwgwYQZgBIwgzYARhXgoumTWv33lm5y4kfZX0qfHsvaQ7ef894nwNZ/3HG973
S2WzPQj0Xt92DOGcNOF1E+GV2bm3ktaS3kp6t22Md9vh9XY8YINz4Y9ChHdO4NyjpEtJK3n/
0hr3TdKLvF8FvWnKzgka04474clVy3Wuorxeuay2x1Dx26Neh0dU5nydE1RV96Ok51dBrtxL
uqQ6Y/a87/8oROg+8+X2303H+Hp/+b2qYJehoIYerc83d3O5m6+z1B5DGW6P0H3muuIeq8pN
FyPmBcAInJoCjAgNc70Zfa7ynqvcABIJDXO9r3zZMb7eDH8eNzsAhrJ9asrSAY56uUJOTR0e
ALPZHkOlbI9ZnJqq3G7/fdydgnLuQs79q2rz+3r03AAYLDzM1eWaK1X7z9+233A/VJ2O2hRz
OSewUP2OZnv/Iu8/y3u3e1QV+72c45JOYELjT015f6dqE5sj2cCE7N04zuoBHw6AxVFoe8z+
xnEA4rEb5oK+dbEg7Qp7bjii3He0OOAlX9LvQWchpPMF2jTE8HWv3tVpb7LXw84dDmf6+emk
YQYWI8MX7KRhdpLNPn7SfHDzKbclbhnsd7vGz9x++Vzrue7hDOxW5vYKNXYf+tQK2vX7YQyX
45hHzuMqGd5r+jDP5UBV6HzOZXlSKrkNSp63kewezQYWhjADRhBmwAjCDBhBmAEj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jJGOmCthdPYDiVv
KspsZJ9L1yH9+Eq6JukW64JrRXB/Vpag7E68U6oYB3FMmk5VcqKIsceC63Bwl0bZAObxFPZL
leY4vtW8R6TCrIZayI3YIG2I48GxPzjnS/qCajdz89KpaUqau/V7nml8IR16+hv0+/FwOP4k
7ov2Gemtl542jej2cndAOpBvxx2ZNuek+f6eDgl7LS53z0nXhHulU9SIhcvdodCZsXC5ezR+
2et8Dz30cJPjP37X3iBpuO6PAAAAAElFTkSuQmCC]]>
							</image>
						</images>
					</functionBlock>
					<functionBlock name="Pulse" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<descr>Pulse generator</descr>
						<vars>
							<inputVars>
								<var name="enable" type="BOOL">
									<descr>Enable Input</descr>
								</var>
								<var name="period" type="UINT">
									<descr>Period [number of function block call]</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="out" type="BOOL">
									<descr>Pulse Signal</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="cnt" type="UINT"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[

		LD		enable
		JMPC	l0

		LD		0
		ST		cnt
		LD		FALSE
		ST		out
		RET

l0:

		LD		cnt
		ADD		1
		ST		cnt

		LD		cnt
		GE		period
		ST		out
		RETCN

l1:

		LD		0
		ST		cnt

]]>
						</sourceCode>
					</functionBlock>
					<functionBlock name="WordToByte" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<descr>Split a word into two bytes</descr>
						<vars>
							<inputVars>
								<var name="w" type="UINT">
									<descr>Word Input</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="byte0" type="USINT">
									<descr>Low byte</descr>
								</var>
								<var name="byte1" type="USINT">
									<descr>High byte</descr>
								</var>
							</outputVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
	(*---------- WORD in memoria IEEE --------*)
	(*										  *)
	(*	WORD -> | H byte1 | L byte0 |		  *)
	(*										  *)
	(*----------------------------------------*)

	(*	Low byte *)

	LD		w
	TO_USINT
	ST		byte0

	(*	High byte *)

	LD		w
	SHR		8
	TO_USINT
	ST		byte1

]]>
						</sourceCode>
					</functionBlock>
					<functionBlock name="WordToBit" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<descr>Split a word into bits</descr>
						<vars>
							<inputVars>
								<var name="word" type="WORD">
									<descr>Word Input</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="b0" type="BOOL">
									<descr>Bit 0</descr>
								</var>
								<var name="b1" type="BOOL">
									<descr>Bit 1</descr>
								</var>
								<var name="b2" type="BOOL">
									<descr>Bit 2</descr>
								</var>
								<var name="b3" type="BOOL">
									<descr>Bit 3</descr>
								</var>
								<var name="b4" type="BOOL">
									<descr>Bit 4</descr>
								</var>
								<var name="b5" type="BOOL">
									<descr>Bit 5</descr>
								</var>
								<var name="b6" type="BOOL">
									<descr>Bit 6</descr>
								</var>
								<var name="b7" type="BOOL">
									<descr>Bit 7</descr>
								</var>
								<var name="b8" type="BOOL">
									<descr>Bit 8</descr>
								</var>
								<var name="b9" type="BOOL">
									<descr>Bit 9</descr>
								</var>
								<var name="b10" type="BOOL">
									<descr>Bit 10</descr>
								</var>
								<var name="b11" type="BOOL">
									<descr>Bit 11</descr>
								</var>
								<var name="b12" type="BOOL">
									<descr>Bit 12</descr>
								</var>
								<var name="b13" type="BOOL">
									<descr>Bit 13</descr>
								</var>
								<var name="b14" type="BOOL">
									<descr>Bit 14</descr>
								</var>
								<var name="b15" type="BOOL">
									<descr>Bit 15</descr>
								</var>
							</outputVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
			LD		word
			AND		16#0001
			NE		0
			ST		b0

			LD		word
			AND		16#0002
			NE		0
			ST		b1

			LD		word
			AND		16#0004
			NE		0
			ST		b2

			LD		word
			AND		16#0008
			NE		0
			ST		b3

			LD		word
			AND		16#0010
			NE		0
			ST		b4

			LD		word
			AND		16#0020
			NE		0
			ST		b5

			LD		word
			AND		16#0040
			NE		0
			ST		b6

			LD		word
			AND		16#0080
			NE		0
			ST		b7

			LD		word
			AND		16#0100
			NE		0
			ST		b8

			LD		word
			AND		16#0200
			NE		0
			ST		b9

			LD		word
			AND		16#0400
			NE		0
			ST		b10

			LD		word
			AND		16#0800
			NE		0
			ST		b11

			LD		word
			AND		16#1000
			NE		0
			ST		b12

			LD		word
			AND		16#2000
			NE		0
			ST		b13

			LD		word
			AND		16#4000
			NE		0
			ST		b14

			LD		word
			AND		16#8000
			NE		0
			ST		b15

]]>
						</sourceCode>
					</functionBlock>
					<functionBlock name="ByteToBit" version="1.0.0" creationDate="0" lastModifiedDate="0">
						<descr>Split a byte into bits</descr>
						<vars>
							<inputVars>
								<var name="byte" type="BYTE">
									<descr>Byte Input</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="b0" type="BOOL">
									<descr>Bit 0</descr>
								</var>
								<var name="b1" type="BOOL">
									<descr>Bit 1</descr>
								</var>
								<var name="b2" type="BOOL">
									<descr>Bit 2</descr>
								</var>
								<var name="b3" type="BOOL">
									<descr>Bit 3</descr>
								</var>
								<var name="b4" type="BOOL">
									<descr>Bit 4</descr>
								</var>
								<var name="b5" type="BOOL">
									<descr>Bit 5</descr>
								</var>
								<var name="b6" type="BOOL">
									<descr>Bit 6</descr>
								</var>
								<var name="b7" type="BOOL">
									<descr>Bit 7</descr>
								</var>
							</outputVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[
			LD		byte
			AND		16#0001
			NE		0
			ST		b0

			LD		byte
			AND		16#0002
			NE		0
			ST		b1

			LD		byte
			AND		16#0004
			NE		0
			ST		b2

			LD		byte
			AND		16#0008
			NE		0
			ST		b3

			LD		byte
			AND		16#0010
			NE		0
			ST		b4

			LD		byte
			AND		16#0020
			NE		0
			ST		b5

			LD		byte
			AND		16#0040
			NE		0
			ST		b6

			LD		byte
			AND		16#0080
			NE		0
			ST		b7

]]>
						</sourceCode>
					</functionBlock>
				</functionBlocks>
				<programs/>
				<macros/>
				<structs/>
				<typedefs/>
				<enums/>
				<subranges/>
				<interfaces/>
			</lib>
			<lib version="1.3.0" name="C:\Users\tiziano.tremonti\Box\Toolbox Eliwell\Libraries\Basic_Addons_Lib_FS\Basic_Addons_Lib_v1.3.0\Basic_Addons.plclib" fullXml="true" link="true">
				<descr>&lt;HTML&gt;The Basic Addons library provides added functions in line with the Basic library of the software.
The key functionalities of the library are:
&lt;ul&gt;
  &lt;li&gt;&lt;b&gt;Data Conversion:&lt;/b&gt;
    &lt;ul&gt;
    &lt;li&gt;Double Integer to Word&lt;/li&gt;
    &lt;li&gt;Double Word to Bit&lt;/li&gt;
    &lt;li&gt;Unsigned Double Integer to Word&lt;/li&gt;
    &lt;li&gt;Word to Double Integer&lt;/li&gt;
    &lt;li&gt;Word to Unsigned Double Integer&lt;/li&gt;
	lt;li&gt;String (max 31) to 16 Words&lt;/li&gt;
    lt;li&gt;16 Words to String (max 31)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;b&gt;Data Interpretation:&lt;/b&gt;
    &lt;ul&gt;
    &lt;li&gt;2 Words interpreted with the IEEE754 real data format&lt;/li&gt;
    &lt;li&gt;4 Words interpreted with the IEEE754 real data format&lt;/li&gt;
	&lt;li&gt;a IEEE754 real value split in 2 Words&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;b&gt;Bit in a Word:&lt;/b&gt;
    &lt;ul&gt;
    &lt;li&gt;Set/Reset a bit of a word&lt;/li&gt;
    &lt;li&gt;Read a bit of a word&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
   &lt;li&gt;&lt;b&gt;Linear Conversion:&lt;/b&gt;
    &lt;ul&gt;
    &lt;li&gt;Linear Integer Converter&lt;/li&gt;
    &lt;li&gt;Linear Unsigned Integer Converter&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt; 
&lt;/ul&gt;

The library supports all the &lt;b&gt;targets&lt;/b&gt; which are available in SoMachine HVAC.&lt;br&gt;
The library is tested/supported on SoMachine HVAC v2.4.1 / EcoStruxure Machine Expert HVAC 1.0.0 and greater versions.&lt;/p&gt;

&lt;b&gt;The Basic Addons Library Resources (updated documentation, etc.) are availabe at 
&lt;a href= https://schneider-electric.box.com/s/nrofepuzc6gtzh9v5spgyhta7nl8ib8d  target= _blank &gt;this link&lt;/a&gt;.&lt;/b&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
				<libWorkspace>
					<folder name="basic_addons" id="304">
						<folder name="Conversion">
							<Pou name="DintToWord"/>
							<Pou name="DWordToBit"/>
							<Pou name="UdintToWord"/>
							<Pou name="WordToDint"/>
							<Pou name="WordToUdint"/>
							<Pou name="String31ToWord16"/>
							<Pou name="Word16ToString31"/>
						</folder>
						<folder name="Data Interpretation">
							<Pou name="Word2ToIEEE754"/>
							<Pou name="Word4ToIEEE754"/>
							<Pou name="IEEE754ToWord2"/>
						</folder>
						<folder name="Bit in Word">
							<Pou name="ReadWordBit"/>
							<Pou name="SRBitWord"/>
						</folder>
						<Pou name="PowReToRe_BasL"/>
						<folder name="Linear Conversion">
							<Pou name="iLinConv"/>
							<Pou name="uiLinConv"/>
						</folder>
					</folder>
				</libWorkspace>
				<globalVars/>
				<retainVars/>
				<constantVars/>
				<functions>
					<function name="uiLinConv" version="1.0.0">
						<descr>Linear Unsigned Integer Converter

X1 is mapped to Y1
X2 is mapped to Y2
between X1 and X2 a linear conversion is applied.
If LIMITED input is TRUE the output is limited between Y1 and Y2

If X1=X2 the function becomes a step regardless to LIMITED input</descr>
						<returnValue>UINT</returnValue>
						<vars>
							<inputVars>
								<var name="uiValue" type="UINT"/>
								<var name="uiX1" type="UINT"/>
								<var name="uiX2" type="UINT"/>
								<var name="uiY1" type="UINT"/>
								<var name="uiY2" type="UINT"/>
								<var name="LIMITED" type="BOOL">
									<descr>If TRUE out is saturated outside interval [x1,x2]</descr>
								</var>
							</inputVars>
							<localVars>
								<var name="Scaler_tmp" type="DINT"/>
								<var name="Ymin" type="DINT"/>
								<var name="Ymax" type="DINT"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<sourceCode type="ST">
							<![CDATA[	IF uiX2=uiX1 THEN
	
		Scaler_tmp := (uiY1)*TO_UINT(uiValue<uiX1) + (uiY2)*TO_UINT(uiValue>=uiX1);
	
	ELSE
	
		Scaler_tmp := TO_DINT(uiValue-uiX1)*TO_DINT(uiY2-uiY1)/TO_DINT(uiX2-uiX1)+TO_DINT(uiY1);
	
	END_IF;
	
	IF LIMITED THEN
	
		IF uiY1<uiY2 THEN
			Ymin := TO_DINT(uiY1);
			Ymax := TO_DINT(uiY2);
		ELSE
			Ymin := TO_DINT(uiY2);
			Ymax := TO_DINT(uiY1);
		END_IF;	
	
		Scaler_tmp := LIMIT(Scaler_tmp,Ymin,Ymax);
		
	END_IF;
	
	uiLinConv := TO_UINT(Scaler_tmp);
	
]]>
						</sourceCode>
					</function>
					<function name="iLinConv" version="1.0.0">
						<descr>Linear Integer Converter

X1 is mapped to Y1
X2 is mapped to Y2
between X1 and X2 a linear conversion is applied.
If LIMITED input is TRUE the output is limited between Y1 and Y2

If X1=X2 the function becomes a step regardless to LIMITED input
if iValue=-32768 output is -32768</descr>
						<returnValue>INT</returnValue>
						<vars>
							<inputVars>
								<var name="iValue" type="INT"/>
								<var name="iX1" type="INT"/>
								<var name="iX2" type="INT"/>
								<var name="iY1" type="INT"/>
								<var name="iY2" type="INT"/>
								<var name="LIMITED" type="BOOL">
									<descr>If TRUE out is saturated outside interval [x1,x2]</descr>
								</var>
							</inputVars>
							<localVars>
								<var name="Scaler_tmp" type="DINT"/>
								<var name="Ymin" type="DINT"/>
								<var name="Ymax" type="DINT"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<sourceCode type="ST">
							<![CDATA[IF iValue <= -32765 THEN

	iLinConv := iValue;

ELSE
	IF iX2=iX1 THEN
	
		Scaler_tmp := (iY1)*TO_INT(iValue<iX1) + (iY2)*TO_INT(iValue>=iX1);
	
	ELSE
	
		Scaler_tmp := TO_DINT(iValue-iX1)*TO_DINT(iY2-iY1)/TO_DINT(iX2-iX1)+TO_DINT(iY1);
	
	END_IF;
	
	IF LIMITED THEN
	
		IF iY1<iY2 THEN
			Ymin := TO_DINT(iY1);
			Ymax := TO_DINT(iY2);
		ELSE
			Ymin := TO_DINT(iY2);
			Ymax := TO_DINT(iY1);
		END_IF;	
	
		Scaler_tmp := LIMIT(Scaler_tmp,Ymin,Ymax);
		
	END_IF;
	
	iLinConv := TO_INT(Scaler_tmp);
	
END_IF;	

]]>
						</sourceCode>
					</function>
					<function name="PowReToRe_BasL" version="1.0.0" hidden="true">
						<returnValue>REAL</returnValue>
						<vars>
							<inputVars>
								<var name="Base" type="REAL"/>
								<var name="Exponent" type="REAL"/>
							</inputVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<sourceCode type="ST">
							<![CDATA[IF Base>0.0 AND Exponent>=0.0 THEN
	PowReToRe_BasL := EXP(Exponent*LN(Base));
ELSE
	PowReToRe_BasL := -32768.0;
END_IF;
]]>
						</sourceCode>
					</function>
					<function name="SRBitWord" version="1.0.0">
						<descr>Set/Reset a bit of a word

Example:
(* Set Bit 7 *)
wValue := SRBitWord(wInput:=wValue,xBitValue:=TRUE,usBitIndex:=7);</descr>
						<returnValue>WORD</returnValue>
						<vars>
							<inputVars>
								<var name="wInput" type="WORD">
									<descr>Word to be updated</descr>
								</var>
								<var name="xBitValue" type="BOOL">
									<descr>New Bit Value</descr>
								</var>
								<var name="usiBitIndex" type="USINT">
									<descr>Bit To be updated Index 0...15</descr>
								</var>
							</inputVars>
							<localVars>
								<var name="wMask" type="WORD"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<sourceCode type="ST">
							<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: Basic_Addons														*
*************************************************************************************
* FUNCT/FB NAME : SRBitWord															*
*																					*
* PURPOSE		: Set/Reset a bit of a word											*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	09-04-18 	Federico Marcassa	First release 								*
* 												 									*
*************************************************************************************)

wMask:=SHL(UINT#1, MIN(15,usiBitIndex));
IF 	xBitValue THEN
	SRBitWord:= (wInput OR wMask);
ELSE
	SRBitWord:= (wInput AND (NOT(wMask)));
END_IF;

]]>
						</sourceCode>
					</function>
					<function name="ReadWordBit" version="1.0.0">
						<descr>Read a bit of a word

Example:
xbit7 := ReadWordBit(wValue,7);</descr>
						<returnValue>BOOL</returnValue>
						<vars>
							<inputVars>
								<var name="wInput" type="WORD">
									<descr>Word to be read</descr>
								</var>
								<var name="usiBitIndex" type="USINT">
									<descr>Bit To be read Index 0...15</descr>
								</var>
							</inputVars>
							<localVars>
								<var name="wMask" type="WORD"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<sourceCode type="ST">
							<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: Basic_Addons														*
*************************************************************************************
* FUNCT/FB NAME : ReadWordBit														*
*																					*
* PURPOSE		: Conversion of 2 Words into a REAL value using IEEE754 32bit format*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	09-04-18 	Federico Marcassa	First release 								*
* 												 									*
*************************************************************************************)

wMask:=SHL(UINT#1, MIN(15,usiBitIndex));
ReadWordBit:= (wInput AND wMask)<>0;

]]>
						</sourceCode>
					</function>
					<function name="WordToUdint" version="1.0.0">
						<descr>Compose a double unsigned integer from 2 words

Example:
udiValue := WordToUdint(wLValue,wHValue);</descr>
						<returnValue>UDINT</returnValue>
						<vars>
							<inputVars>
								<var name="wLSW" type="WORD">
									<descr>Less Significative Word</descr>
								</var>
								<var name="wMSW" type="WORD">
									<descr>Most Significative Word</descr>
								</var>
							</inputVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<sourceCode type="IL">
							<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: Basic_Addons														*
*************************************************************************************
* FUNCT/FB NAME : WordToUdint														*
*																					*
* PURPOSE		: Compose a double unsigned integer from 2 words					*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	09-04-18 	Federico Marcassa	First release 								*
* 												 									*
*************************************************************************************)

	(*---------- Word values -----------------*)
	(*										  *)
	(*	UDINT <- | H word1 | L word0 |		  *)
	(*										  *)
	(*----------------------------------------*)

	(*	Low word *)

	LD		wLSW
	TO_UDINT
	ST		WordToUdint

	(*	High word *)

	LD		wMSW
	TO_UDINT	
	SHL		16
	ADD		WordToUdint
	ST		WordToUdint

]]>
						</sourceCode>
					</function>
					<function name="WordToDint" version="1.0.0">
						<descr>Compose a double integer from 2 words

Example:
diValue := WordToDint(wLValue,wHValue);</descr>
						<returnValue>DINT</returnValue>
						<vars>
							<inputVars>
								<var name="wLSW" type="WORD">
									<descr>Less Significative Word</descr>
								</var>
								<var name="wMSW" type="WORD">
									<descr>Most Significative Word</descr>
								</var>
							</inputVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<sourceCode type="IL">
							<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: Basic_Addons														*
*************************************************************************************
* FUNCT/FB NAME : WordToDint														*
*																					*
* PURPOSE		: Compose a double integer from 2 words								*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	09-04-18 	Federico Marcassa	First release 								*
* 												 									*
*************************************************************************************)

	(*---------- Word values -----------------*)
	(*										  *)
	(*	DINT <- | H word1 | L word0 |		  *)
	(*										  *)
	(*----------------------------------------*)

	(*	Low word *)

	LD		wLSW
	TO_DINT
	ST		WordToDint

	(*	High word *)

	LD		wMSW
	TO_DINT	
	SHL		16
	ADD		WordToDint
	ST		WordToDint

]]>
						</sourceCode>
					</function>
				</functions>
				<functionBlocks>
					<functionBlock name="String31ToWord16" version="1.0.0" creationDate="1552554403" lastModifiedDate="1552987455">
						<title>Copy String content into a vector of Words</title>
						<descr>This function can be used to create the vector of values needed to send a string through modbus</descr>
						<vars>
							<inputVars>
								<var name="s31input" type="STRING" length="31">
									<descr>Input string - Max size 31</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="w16output" type="WORD" dim0="16">
									<descr>Output Word Vector</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="iIndex" type="INT"/>
								<var name="usPtr1" type="@USINT"/>
								<var name="usPtr2" type="@USINT"/>
								<var name="xStringEnd" type="BOOL"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="ST">
							<![CDATA[usPtr1 := ADR(s31input);
usPtr2 := ADR(w16output[0]);
xStringEnd := FALSE;

FOR iIndex := 0 TO 30 DO

	IF @usPtr1 = 0 THEN
		xStringEnd := TRUE;		
	END_IF;	
	IF xStringEnd THEN
		@usPtr2 := 0;
	ELSE
		@usPtr2 := @usPtr1;
	END_IF;	
	usPtr1 := usPtr1+1;
	usPtr2 := usPtr2+1;

END_FOR;
// Write in any case an end of string in the last byte
@usPtr2 := 0;
]]>
						</sourceCode>
					</functionBlock>
					<functionBlock name="Word16ToString31" version="1.0.0" creationDate="1552554403" lastModifiedDate="1552987520">
						<title>Copy String content into a vector of Words</title>
						<descr>This function can be used to create the string related to a vector of word values read through modbus</descr>
						<vars>
							<inputVars>
								<var name="w16input" type="WORD" dim0="16">
									<descr>Input Word Vector</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="s31output" type="STRING" length="31">
									<descr>Output string - Max size 31</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="iIndex" type="INT"/>
								<var name="usPtr1" type="@USINT"/>
								<var name="usPtr2" type="@USINT"/>
								<var name="xStringEnd" type="BOOL"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="ST">
							<![CDATA[usPtr1 := ADR(w16input[0]);
usPtr2 := ADR(s31output);

xStringEnd := FALSE;

FOR iIndex := 0 TO 30 DO

	IF @usPtr1 = 0 THEN
		xStringEnd := TRUE;		
	END_IF;	
	IF xStringEnd THEN
		@usPtr2 := 0;
	ELSE
		@usPtr2 := @usPtr1;
	END_IF;	
	usPtr1 := usPtr1+1;
	usPtr2 := usPtr2+1;

END_FOR;
// Write in any case an end of string in the last byte
@usPtr2 := 0;
]]>
						</sourceCode>
					</functionBlock>
					<functionBlock name="IEEE754ToWord2" version="1.0.0">
						<descr>Conversion of a REAL value IEEE754 32bit format into the related 2 Words

Example:
RealToWordInstance(rInput:=rValue);
wL:=RealToWordInstance.wL;
wH:=RealToWordInstance.wH;</descr>
						<vars>
							<inputVars>
								<var name="rInput" type="REAL">
									<descr>Real Value</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="wH" type="WORD">
									<descr>High Word</descr>
								</var>
								<var name="wL" type="WORD">
									<descr>Low Word</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="uintptr" type="@UINT"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="ST">
							<![CDATA[
uintptr := ADR(rInput);

wL := @uintptr;
uintptr :=  uintptr + 2;
wH := @uintptr;
]]>
						</sourceCode>
					</functionBlock>
					<functionBlock name="Word4ToIEEE754" version="1.0.0">
						<descr>Conversion of 4 Words into a REAL value using IEEE754 64bit format.
Note: a loss of accuracy takes inevitably place in the conversion, due to the fact that the 64bit-REAL format is not supported by the platform (wL2 not used).

Example:
WordToRealInstance(w1H:=w1HValue,w1L:=w1LValue,w2H:=w2HValue,w2L:=w2LValue);
rValue := WordToRealInstance.IEEE754;</descr>
						<vars>
							<inputVars>
								<var name="w1H" type="WORD">
									<descr>High Word 1</descr>
								</var>
								<var name="w1L" type="WORD">
									<descr>Low Word 1</descr>
								</var>
								<var name="w2H" type="WORD">
									<descr>High Word 2</descr>
								</var>
								<var name="w2L" type="WORD">
									<descr>Low Word 2</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="rIEEE754" type="REAL">
									<descr>Real Value</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="fullbit" type="DWORD"/>
								<var name="exponent" type="REAL"/>
								<var name="fullbit1" type="DWORD"/>
								<var name="mantisse" type="REAL"/>
								<var name="exponentInt" type="INT"/>
								<var name="mantisseDW" type="DWORD"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="ST">
							<![CDATA[fullbit := SHL(TO_UDINT(w1H),16) OR TO_UDINT(w1L);

exponentInt:=TO_INT(SHR(fullbit AND 16#7FF00000,20))-1023;
exponent := TO_REAL(exponentInt);

mantisseDW := (fullbit AND 16#000FFFFF);
IF exponentInt<>-1023 THEN
	mantisseDW := mantisseDW OR 16#00100000;
ELSE
	mantisseDW := SHL(mantisseDW,1);	
END_IF;	
mantisseDW := SHL(mantisseDW,10);
w2H := SHR(w2H,6);
mantisseDW := mantisseDW OR TO_UDINT(w2H);
mantisse := TO_REAL(mantisseDW) / TO_REAL(16#40000000);

rIEEE754 := PowReToRe_BasL (2.0,exponent);
rIEEE754 := rIEEE754 * mantisse;
IF (fullbit AND 16#80000000)<>0 THEN
	rIEEE754 := -rIEEE754;
END_IF;	
]]>
						</sourceCode>
					</functionBlock>
					<functionBlock name="Word2ToIEEE754" version="1.0.0">
						<descr>Conversion of 2 Words into a REAL value using IEEE754 32bit format

Example:
WordToRealInstance(wL:=wLValue,wH:=wHValue);
rValue := WordToRealInstance.IEEE754;</descr>
						<vars>
							<inputVars>
								<var name="wH" type="WORD">
									<descr>High Word</descr>
								</var>
								<var name="wL" type="WORD">
									<descr>Low Word</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="rIEEE754" type="REAL">
									<descr>Real Value</descr>
								</var>
							</outputVars>
							<localVars>
								<var name="udintptr" type="@UDINT"/>
							</localVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="ST">
							<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: Basic_Addons														*
*************************************************************************************
* FUNCT/FB NAME : WordToReal														*
*																					*
* PURPOSE		: Conversion of 2 Words into a REAL value using IEEE754 32bit format*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	09-04-18 	Federico Marcassa	First release 								*
* 												 									*
*************************************************************************************)

udintptr := ADR(rIEEE754);

@udintptr := TO_UDINT(wL)+SHL(TO_UDINT(wH),16);

]]>
						</sourceCode>
					</functionBlock>
					<functionBlock name="UdintToWord" version="1.0.0">
						<descr>Split a double unsigned integer into two words

Example:
UdintToWordInstance(udiInput:=udiValue);
wL := UdintToWordInstance.wLSW;
wH := UdintToWordInstance.wMSW;</descr>
						<vars>
							<inputVars>
								<var name="udiInput" type="UDINT">
									<descr>Input Value</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="wLSW" type="WORD">
									<descr>Less Significative Word</descr>
								</var>
								<var name="wMSW" type="WORD">
									<descr>Most Significative Word</descr>
								</var>
							</outputVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: Basic_Addons														*
*************************************************************************************
* FUNCT/FB NAME : UdintToWord														*
*																					*
* PURPOSE		: Split a double unsigned integer into two words					*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	09-04-18 	Federico Marcassa	First release 								*
* 												 									*
*************************************************************************************)

	(*---------- UDINT value -----------------*)
	(*										  *)
	(*	UDINT -> | H word1 | L word0 |		  *)
	(*										  *)
	(*----------------------------------------*)

	(*	Low byte *)

	LD		udiInput
	TO_UINT
	ST		wLSW

	(*	High byte *)

	LD		udiInput
	SHR		16
	TO_UINT
	ST		wMSW

]]>
						</sourceCode>
					</functionBlock>
					<functionBlock name="DWordToBit" version="1.0.0">
						<descr>Split a double word into 32 bits

Example:
DWordToBitInstance(dwInput:=dwValue);
xbit7 := DWordToBitInstance.xb7;</descr>
						<vars>
							<inputVars>
								<var name="dwInput" type="DWORD">
									<descr>Input Value</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="xb0" type="BOOL">
									<descr>Bit 0</descr>
								</var>
								<var name="xb1" type="BOOL">
									<descr>Bit 1</descr>
								</var>
								<var name="xb2" type="BOOL">
									<descr>Bit 2</descr>
								</var>
								<var name="xb3" type="BOOL">
									<descr>Bit 3</descr>
								</var>
								<var name="xb4" type="BOOL">
									<descr>Bit 4</descr>
								</var>
								<var name="xb5" type="BOOL">
									<descr>Bit 5</descr>
								</var>
								<var name="xb6" type="BOOL">
									<descr>Bit 6</descr>
								</var>
								<var name="xb7" type="BOOL">
									<descr>Bit 7</descr>
								</var>
								<var name="xb8" type="BOOL">
									<descr>Bit 8</descr>
								</var>
								<var name="xb9" type="BOOL">
									<descr>Bit 9</descr>
								</var>
								<var name="xb10" type="BOOL">
									<descr>Bit 10</descr>
								</var>
								<var name="xb11" type="BOOL">
									<descr>Bit 11</descr>
								</var>
								<var name="xb12" type="BOOL">
									<descr>Bit 12</descr>
								</var>
								<var name="xb13" type="BOOL">
									<descr>Bit 13</descr>
								</var>
								<var name="xb14" type="BOOL">
									<descr>Bit 14</descr>
								</var>
								<var name="xb15" type="BOOL">
									<descr>Bit 15</descr>
								</var>
								<var name="xb16" type="BOOL">
									<descr>Bit 16</descr>
								</var>
								<var name="xb17" type="BOOL">
									<descr>Bit 17</descr>
								</var>
								<var name="xb18" type="BOOL">
									<descr>Bit 18</descr>
								</var>
								<var name="xb19" type="BOOL">
									<descr>Bit 19</descr>
								</var>
								<var name="xb20" type="BOOL">
									<descr>Bit 20</descr>
								</var>
								<var name="xb21" type="BOOL">
									<descr>Bit 21</descr>
								</var>
								<var name="xb22" type="BOOL">
									<descr>Bit 22</descr>
								</var>
								<var name="xb23" type="BOOL">
									<descr>Bit 23</descr>
								</var>
								<var name="xb24" type="BOOL">
									<descr>Bit 24</descr>
								</var>
								<var name="xb25" type="BOOL">
									<descr>Bit 25</descr>
								</var>
								<var name="xb26" type="BOOL">
									<descr>Bit 26</descr>
								</var>
								<var name="xb27" type="BOOL">
									<descr>Bit 27</descr>
								</var>
								<var name="xb28" type="BOOL">
									<descr>Bit 28</descr>
								</var>
								<var name="xb29" type="BOOL">
									<descr>Bit 29</descr>
								</var>
								<var name="xb30" type="BOOL">
									<descr>Bit 30</descr>
								</var>
								<var name="xb31" type="BOOL">
									<descr>Bit 31</descr>
								</var>
							</outputVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: Basic_Addons														*
*************************************************************************************
* FUNCT/FB NAME : DWordToBit														*
*																					*
* PURPOSE		: Split a double word into 32 bits									*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	09-04-18 	Federico Marcassa	First release 								*
* 												 									*
*************************************************************************************)

			LD		dwInput
			AND		16#00000001
			NE		0
			ST		xb0

			LD		dwInput
			AND		16#00000002
			NE		0
			ST		xb1

			LD		dwInput
			AND		16#00000004
			NE		0
			ST		xb2

			LD		dwInput
			AND		16#00000008
			NE		0
			ST		xb3

			LD		dwInput
			AND		16#00000010
			NE		0
			ST		xb4

			LD		dwInput
			AND		16#00000020
			NE		0
			ST		xb5

			LD		dwInput
			AND		16#00000040
			NE		0
			ST		xb6

			LD		dwInput
			AND		16#00000080
			NE		0
			ST		xb7

			LD		dwInput
			AND		16#00000100
			NE		0
			ST		xb8

			LD		dwInput
			AND		16#00000200
			NE		0
			ST		xb9

			LD		dwInput
			AND		16#00000400
			NE		0
			ST		xb10

			LD		dwInput
			AND		16#00000800
			NE		0
			ST		xb11

			LD		dwInput
			AND		16#00001000
			NE		0
			ST		xb12

			LD		dwInput
			AND		16#00002000
			NE		0
			ST		xb13

			LD		dwInput
			AND		16#00004000
			NE		0
			ST		xb14

			LD		dwInput
			AND		16#00008000
			NE		0
			ST		xb15
			
			LD		dwInput
			AND		16#00010000
			NE		0
			ST		xb16

			LD		dwInput
			AND		16#00020000
			NE		0
			ST		xb17

			LD		dwInput
			AND		16#00040000
			NE		0
			ST		xb18

			LD		dwInput
			AND		16#00080000
			NE		0
			ST		xb19
			
			LD		dwInput
			AND		16#00100000
			NE		0
			ST		xb20

			LD		dwInput
			AND		16#00200000
			NE		0
			ST		xb21

			LD		dwInput
			AND		16#00400000
			NE		0
			ST		xb22

			LD		dwInput
			AND		16#00800000
			NE		0
			ST		xb23
			
			LD		dwInput
			AND		16#01000000
			NE		0
			ST		xb24

			LD		dwInput
			AND		16#02000000
			NE		0
			ST		xb25

			LD		dwInput
			AND		16#04000000
			NE		0
			ST		xb26

			LD		dwInput
			AND		16#08000000
			NE		0
			ST		xb27
			
			LD		dwInput
			AND		16#10000000
			NE		0
			ST		xb28

			LD		dwInput
			AND		16#20000000
			NE		0
			ST		xb29

			LD		dwInput
			AND		16#40000000
			NE		0
			ST		xb30

			LD		dwInput
			AND		16#80000000
			NE		0
			ST		xb31

]]>
						</sourceCode>
					</functionBlock>
					<functionBlock name="DintToWord" version="1.0.0">
						<descr>Split a double integer into two words

Example:
DintToWordInstance(diInput:=diValue);
wL := DintToWordInstance.wLSW;
wH := DintToWordInstance.wMSW;</descr>
						<vars>
							<inputVars>
								<var name="diInput" type="DINT">
									<descr>Input Value</descr>
								</var>
							</inputVars>
							<outputVars>
								<var name="wLSW" type="WORD">
									<descr>Less Significative Word</descr>
								</var>
								<var name="wMSW" type="WORD">
									<descr>Most Significative Word</descr>
								</var>
							</outputVars>
						</vars>
						<iecDeclaration active="FALSE"/>
						<interfaces/>
						<methods/>
						<sourceCode type="IL">
							<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: Basic_Addons														*
*************************************************************************************
* FUNCT/FB NAME : DintToWord														*
*																					*
* PURPOSE		: Split a double integer into two words								*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	09-04-18 	Federico Marcassa	First release 								*
* 												 									*
*************************************************************************************)

	(*---------- DINT value ------------------*)
	(*										  *)
	(*	DINT -> | H word1 | L word0 |		  *)
	(*										  *)
	(*----------------------------------------*)

	(*	Low byte *)

	LD		diInput
	TO_UINT
	ST		wLSW

	(*	High byte *)

	LD		diInput
	SHR		16
	TO_UINT
	ST		wMSW

]]>
						</sourceCode>
					</functionBlock>
				</functionBlocks>
				<programs/>
				<macros/>
				<structs/>
				<typedefs/>
				<enums/>
				<subranges/>
				<interfaces/>
			</lib>
		</libraries>
		<aux>
			<src externalFile="true" name="HMI.plc" order="0" hidden="true"/>
			<src fullXml="false" name="Configuration_variables.plc" order="0" hidden="false">
				<![CDATA[(* Automatically generated, do not edit! *)
]]>
			</src>
			<src fullXml="false" name="ParDB.plc" order="1" hidden="false">
				<![CDATA[(* Automatically generated, do not edit! *)

PROGRAM InitParDB WITH Init;

PROGRAM InitParDB
	{ HIDDEN:ON }
	{ CODE:ST }
	VAR
		warningsKiller: USINT;
		dummyCrc32: UDINT;
	END_VAR

	dummyCrc32 := 0;

	warningsKiller := sysDBase_SetExtTable( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );

END_PROGRAM

]]>
			</src>
			<src fullXml="false" name="ExecTime.plc" order="0" hidden="false">
				<![CDATA[(* Automatically generated, do not edit! *)

PROGRAM ParCheck WITH Init;

PROGRAM ParCheck
	{ HIDDEN:ON }
	{ CODE:ST }
	IF (sysPar_PARPOLI AND 16#fc00) <> 1024 THEN
		WHILE TRUE DO
			(* do nothing and loop forever *)
		END_WHILE;
	END_IF;
END_PROGRAM

]]>
			</src>
			<src fullXml="false" name="TelevisDriverCheck.plc" order="-1" hidden="false">
				<![CDATA[]]>
			</src>
		</aux>
	</sources>
	<codegen crossReference="false" crossReferenceOptions="0x3000001D" listing="true" unusedObjs="false" saveEXPFile="true" saveEXPFileLibraries="false" saveTargetFiles="false" warningEnable="true" symMap="true" checkIndexType="false" waitExtension="false" allocateUnusedVariables="false" checkArrayBounds="false" checkDivisionByZero="false" checkPointers="0" checkReferences="false" checkInterfaces="false" ioVarsAsReferences="false" customTargetBINFileName="HMI_CH_HP.bin" customTargetTSCFileName="HMI_CH_HP_source.bin" customTargetTDSFileName="HMI_CH_HP_debug.bin" generateCustomFilesName="false" initFunVarsWithZero="false" enablePreprocessDirectives="false">
		<disabledWarnings>
			<warning>G0094</warning>
			<warning>G0091</warning>
			<warning>G0072</warning>
			<warning>G0130</warning>
		</disabledWarnings>
		<applicationDataBlocks/>
	</codegen>
	<simWorkspaces>
		<simWorkspace>test.WKSX</simWorkspace>
	</simWorkspaces>
	<debug watchRefresh="20" watchVarRefresh="0" watchMaxArray="20" autoSaveWatchList="true" watchFBLocalVars="true"/>
	<editor useOldGridSize="false"/>
	<userDef>
		<release>HMI_CH_HP</release>
		<author>Eliwell</author>
		<note/>
		<version>1.20</version>
		<password disabled="false"/>
	</userDef>
	<downloadSequence sourceCode="onPLCApplicationDownload" debugSymbols="onPLCApplicationDownload"/>
	<commands>
		<postbuild/>
		<postdown/>
		<predown/>
	</commands>
	<resources>
		<configuration template="EWApplication.pct" version="8">
			<data>
				<project_config nextID="2">
					<datacomment/>
					<persistentVariables/>
				</project_config>
				<TM172DC-L_659p8 template="TM172DC\AVP-L_659p8.pct" version="4" uniqueID="0" name="AVP Landscape" caption="AVP Landscape">
					<devConfig HMIProject="HMI\HMI_Touch_CH-HP-CR_1.20_Alarms_ReNamed.pajx" HMIProjectCRC="-576843644" TelevisDriverBuildEnable="0" TelevisDriverMask="12100">
						<params/>
						<paramsRO/>
						<enums nextID="0"/>
						<menus/>
						<ioMappings>
							<ioMappingsLocal>
								<ioMapping inout="in" idx="0">
									<name>NTC</name>
									<description>NTC thermistor sensor</description>
									<variable/>
									<type>INT</type>
								</ioMapping>
								<ioMapping inout="in" idx="1">
									<name>RH</name>
									<description>RH humidity sensor</description>
									<variable/>
									<type>INT</type>
								</ioMapping>
								<ioMapping inout="in" idx="2">
									<name>PIR</name>
									<description>PIR proximity sensor</description>
									<variable/>
									<type>INT</type>
								</ioMapping>
							</ioMappingsLocal>
						</ioMappings>
						<biosParams>
							<biosParam>
								<ipa>8207</ipa>
								<defval>3600</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8211</ipa>
								<defval>2</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8196</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8197</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8206</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8204</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8205</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8250</ipa>
								<defval>5</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8254</ipa>
								<defval>1</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8255</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8256</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8257</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8258</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8259</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8260</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8261</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8262</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8263</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8264</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8265</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8266</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8267</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8268</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8269</ipa>
								<defval>0</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
							<biosParam>
								<ipa>8194</ipa>
								<defval>1</defval>
								<addToTelevis>0</addToTelevis>
							</biosParam>
						</biosParams>
						<writes/>
						<televisPolis/>
						<dictionary>
							<PLA/>
							<GROUPS/>
							<UM/>
						</dictionary>
						<executionTime custom="0" disabled="1">20</executionTime>
					</devConfig>
					<RS485_OnBoard address="1" mode="1" baudRate="38400" serialMode="1"/>
					<cfgConfig>
						<config>
							<commstring>Modbus:1,1000,M#COM:9,38400,E,8,1,H</commstring>
							<values stopNodeParsing="true">
								<value ipa="8192" subidx="0">0</value>
								<value ipa="8193" subidx="0">1024</value>
								<value ipa="8194" subidx="0">1</value>
								<value ipa="8195" subidx="0">-1</value>
								<value ipa="8196" subidx="0">0</value>
								<value ipa="8197" subidx="0">0</value>
								<value ipa="8206" subidx="0">0</value>
								<value ipa="8198" subidx="0">1</value>
								<value ipa="8199" subidx="0">1</value>
								<value ipa="8200" subidx="0">8</value>
								<value ipa="8201" subidx="0">1</value>
								<value ipa="8202" subidx="0">2</value>
								<value ipa="8203" subidx="0">2</value>
								<value ipa="8204" subidx="0">0</value>
								<value ipa="8205" subidx="0">0</value>
								<value ipa="8207" subidx="0">3600</value>
								<value ipa="8250" subidx="0">5</value>
								<value ipa="8211" subidx="0">2</value>
								<value ipa="8208" subidx="0">239</value>
								<value ipa="8209" subidx="0">272</value>
								<value ipa="8210" subidx="0">-32767</value>
								<value ipa="8212" subidx="0">38</value>
								<value ipa="8213" subidx="0">20</value>
								<value ipa="8214" subidx="0">22</value>
								<value ipa="8215" subidx="0">5</value>
								<value ipa="8216" subidx="0">5</value>
								<value ipa="8217" subidx="0">1</value>
								<value ipa="8218" subidx="0">0</value>
								<value ipa="8219" subidx="0">0</value>
								<value ipa="8220" subidx="0">0</value>
								<value ipa="8221" subidx="0">0</value>
								<value ipa="8222" subidx="0">0</value>
								<value ipa="8223" subidx="0">0</value>
								<value ipa="8224" subidx="0">1</value>
								<value ipa="8225" subidx="0">1</value>
								<value ipa="8226" subidx="0">0</value>
								<value ipa="8227" subidx="0">0</value>
								<value ipa="8254" subidx="0">1</value>
								<value ipa="8255" subidx="0">0</value>
								<value ipa="8256" subidx="0">0</value>
								<value ipa="8257" subidx="0">0</value>
								<value ipa="8258" subidx="0">0</value>
								<value ipa="8259" subidx="0">0</value>
								<value ipa="8260" subidx="0">0</value>
								<value ipa="8261" subidx="0">0</value>
								<value ipa="8262" subidx="0">0</value>
								<value ipa="8263" subidx="0">0</value>
								<value ipa="8264" subidx="0">0</value>
								<value ipa="8265" subidx="0">0</value>
								<value ipa="8266" subidx="0">0</value>
								<value ipa="8267" subidx="0">0</value>
								<value ipa="8268" subidx="0">0</value>
								<value ipa="8269" subidx="0">0</value>
							</values>
							<commDisabled>0</commDisabled>
							<downloadVolume>0</downloadVolume>
							<alignTargetRTC>0</alignTargetRTC>
						</config>
						<application>
							<HMI_Touch_CH2DHP2DCR_1p20_Alarms_ReNamed template="%PCNPATH%\HMI_Touch_CH-HP-CR_1.20_Alarms_ReNamed.PCT" version="1" uniqueID="1"/>
						</application>
						<recipes/>
					</cfgConfig>
				</TM172DC-L_659p8>
			</data>
		</configuration>
	</resources>
</plcProject>