<lib version="1.0.1" name="basic" fullXml="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>FALSE</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
AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5l
dCA0LjAuMjHxIGmVAAAD2ElEQVR4Xu3awXHTTBiA4bRAAVxogSNXWmDogAZoghtnWmBohRL4
S6CAn4OZj2iJIinSOrY/fxbPM7NJbCnJMrvvSHa4OwAXJzRIIDRIIDRIIDRIIDRIIDRIIDRI
IDRIIDRIIDRIIDRIIDRIUD60u7u7PwNumdAgQekd3CITG7dOaJCg7O6dRtYG3CKhQYLyO1dg
7IHQIIHQIIHQIIHQIIHQIIH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ADoYEQoMEQoME
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
	ANDN	m
	ST		q

	LDN		clk
	ST		m
]]>
			</sourceCode>
			<images>
				<image name="f_trig.png" width="218" height="117">
					<![CDATA[iVBORw0KGgoAAAANSUhEUgAAANoAAAB1CAYAAAAoV//gAAAAAXNSR0IArs4c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w/v94I7QN4jg5ViXtP5Wv
X++H/+XL8ImJleeFtkEcJ8eqpP2n0q5YEdSSFlq8boHQNojj5FiVtP9UhJYnjpNjVdL+U1m5
NVx7XmgbxHFyrErafyrbfxnyiNA2iOPkWJWUM5Wn/Xr/D6FtILSycqYSV6vpP1hHdP7B+rKE
VlbeVJb+C1asiO0MoW3QjinlHDuV9vNZ3Dqu/Yxm9S/KOX4q8VvH8S3lhNCesCin/FT+hgZX
TGiQQGiQQGiQQGiQQGiQQGiQQGiQQGiQQGhwxqXOP6HBGe38e+55uNsZPN2gZd3S2kpolvWE
tdVuoV3KU/9icAnjuJ5zHgoNzrjU+Sc0SCA0SCA0SCA0SCA0SCA0SCA0SOAMhgRCgwRCgwRC
gwRCgwRCgwRCgwRCgwRCgwRCgwRCg92dTr8BUO8SN3cafNMAAAAASUVORK5CYII=]]>
				</image>
				<image icon="true" name="ftrig34.png" width="34" height="34">
					<![CDATA[iVBORw0KGgoAAAANSUhEUgAAACIAAAAiCAYAAAA6RwvCAAAAqElEQVRYhe2VYQqAIAyF34tO
V4eqDtX51o9aRJQ5S1iwDwQR3R5vToEgCIJ3UEQqROVdUELzkcAhd/O9ijJsQsh1GE5s42Mh
FbELsd6pzP0/dqQSboRQAC0icT0vR2TtmNS7suVx5YgL3DjS5vQ5+6nUOMo8gP0EmQeNBV0D
sM8dOWIj96MxO/hbR/Zap9D6W3DjSAg5Q3Sj5a9h5h1Jdc1lHjeOBMETC4IUMr87wVtwAAAA
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+OnEwAAAAAAAAAAAAAAAAAAA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B7sZp2xceID6NEnSNN+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/9jzEqZuM44vygwSoAe4U0iATsOg
JwSb5DzttFnbvE3y62zdV1qwWQnK3mZ9D/aD3mI5m039kJ7N0n5R9JmvzUHL3NVGP3Wzv82S
67LNCFD29uw/0Be5N12ATiJA/+eQG58l101bA/2U/c/C1/j7pXaH+7PuteFDleIlvip6zlel
hsKvaqA1lJUR692EP0gpytQYoLNH23/OPMNzEgkYJXciARQSoACFBChAIQEKUEiAAhQSoACF
BChAIQEKUEiAAhQSoACFBChAIQEKUKiGB6C0DxI52zXsPDB2zT//MkuS2T/+8/35n80///J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9D3wBd9X1uv1TpIl+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/ZLnqEfL4Ar
QgkUAIxCLtEda/cM+ZgBXBFKoABgFGpp7lSve6jHDeCKUAIFgB5jHCiAIFECBQAjAhQAjAhQ
ADAiQAHAiAAFACMCFACMCFAAMCJAAcCIAAUAIwIUAIwaDdBcmuTSRy7lxfKWS6Mm3wPokzzP
ledcqXz1irB8rwZmLr0WQXpXb9dcCw+bypd5qIsL0Uv/onA5Rckzz6X0wHOvRan0xr57zi/Y
BBCQBCi+V5Q83488l9YshRKgMNsJKt+lqF6btj29EKA9ULsNtCh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CpJGDtkKA5kKIfa4Xv4oGAT4PdyE2
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
HvhC2fa5OvI8AFwvhjEhVNXebu9tK73wTaMXHjvywwPpH2sOYSp2w/kFm0YCtIUrhQjQfmi0
QzCXJnJLtbS5kvQ72baVGnZLgqK2xPdkb/USyyTp+ymdJHJfFD7rsWn1mIvS6HOxep9IC9tu
CFDUdvYfaCfXphOgvQjQ/7a580Ra5K4E+qz6vfAx/n4Ru/b+rL123NZRdPFV4bkelRgOviyB
xnCsCJh3Fb6Vo7CJMUCTvf2fs47m0YkEIEhciQQARgQoABgRoABgRIACgBEBCgBGBCgAGBGg
AGBEg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9/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[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" 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[iVBORw0KGgoAAAANSUhEUgAAAVAAAADICAYAAAC+qrlDAAAKr0lEQVR4nO3dzXHiwBqF4aNb
NwFPCNwQTAajCYEJwd4zC7yj2NmLYW+HYEKwJgMIwYRgh6C7aAkEBkN/+qFbvE+VyiNAQnjk
Q/9JLQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF95sQBAUP5z6QMAgFgllz6AE/ZLnqEfL4Ar
QgkUAIxCLtEda/cM+ZgBXBFKoABgFGpp7lSve6jHDeCKUAIFgB5jHCiAIFECBQAjAhQAj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ACbcpt1cXW
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[iVBORw0KGgoAAAANSUhEUgAAASIAAACSCAYAAADhA8d3AAAG4klEQVR4nO3d4U3jSBjG8ec9
7eeTsiWEEkIJuwUcEkhcAVwJUAKUAAUcEkhcAWwJpIRNCYvuGpj7MPbieOM4TsZ5x/b/J1kh
cTaZDebJ6/F4LAEAAAAAnFnTihBCf29qVr649fk+APJkth49vzm1Q1IMu3qDAEzP0YOoUg2t
/QxgulwrohJVETBtRw2ihgqIqgiYuCwqIgDT9unI71fug4XafQATdtQgKg/VV/uEOHwPgF0z
A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C4+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
ANwRRADcEUQA3BFEANwRRADcEUQA3B16HBEwDXmeJ2ka6XCYeQdRnhsT2o32A4dmm3fNzMpl
IbM7mYXKciezo8pj6stSZo8yuzng7wJ4sAyW0WvrIzqS9FrcHiv+0se1n1edSXop1p0lbemw
vDcklpl84NCsLYjKiuZc0lvx7zdJXyW9S3qsPHYp6UrSStLnhG0E8haC7zIB2/qIjhSrmnvF
0Km7VwyqI8VwWkk6KdYtErbxMCbyB5005q2arG0V0bK4XW1YX1ZIX9I1B8AcbQuisv+nqRqq
Gl/1AyArDGgE4G5bEJW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BEAdwQRAHdTO8Vj
b2bKboRlCJy6khu2k7SoiAC46x1EZlqY6c5MobI8mk1rMv0QZN6L93uAdt7bSHU7MftYxqZX
EJlpIelV8QoeJ5U3YiHpZWphlIuxblxAV30rojPFCyzeh6BV+cMQ9FXSu7je2WA4NxhdhDDO
baVvZ/WiuG260uv9nm0BMFO9pgEpdr1eJX0rqqDdXjTjaUDKoyE59NFUjsxYZm/T7LGd7Gev
aUCK3bFzSUdm+mGmGzMdJWwfgBnqfdQsBD2FoGPFa54tJH0306uZLpO3DsAsJJmh0Uw3ipeg
vg5h40UZK49n16xPWzSiknsu2E72U98169tHdBXX/Ro2ZnqRtAxBnzs0giDq0RaNaAObC7aT
/ew7VexS0lUxnggAkugbRNeK44XWRlIXldIXcQgfwA76HjV7k3QiaSXptTzFQ3Gg43UIuh6g
jQAmjssJ1bDvjy7YTvbD5YQAZIcgAuDOeWK0EDirvBPeJ3TRazspdyvru3Zt94dARbQBH3x0
wXaShnNFZKb8ZtzMRr0jlI0+Hzl1CifoMK///7b7yVERAXDnPnl+Tt8suTIb74RXyF99u2q7
PwQqohEggDB1BFHG6BPCXBBEGaMSwlwQRADcEUQA3BFEANwRRADcEUQA3BFEANy5j6wGMF1d
J0GkIgJwCMHMQn1mxlLPywkZQ+wApLCWPVREANz17SNKdfbTz/3GRM8HIE/1vajGzzyd1QAO
YWvR0SuIUl36p9phldvlhACkYw290yGEXy4nREUE4CC2FR0EEYDBdN3j4agZAHcEEQB3BBEA
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+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c0lDYx6zSOexnHp/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[iVBORw0KGgoAAAANSUhEUgAAAOYAAACSCAYAAABR2bZsAAAHoUlEQVR4nO3d7W3bSB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qph1/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
X6DtDK/V4kUXBfPJpbxUtLuMYv5Q2ydQ1kOPAXZDuwSu7yF02/DmxYzlCvwyM3VJbvcFFmon
vhEb8CDuwx1YGc9+xU84ia9wCP8skN+eE1iO7XgRw210VsZvDcbxG97HBGZ79N/THHgSp/G6
FPypkEcVxReXtJI8Gs9O4daQTwdHT6iSwAA+wH7pzR7DCO7BTnyNc0365+LeztAZwdGw3R9c
A9XCL5/AAA7gBZzH87g/kmigVntKWiCKkJtxDOvD9nxwHVAxibIJTGCjNHZHsVe10qIWtqP4
PTjfrcBTKoEn8JI0JB7C8SoOW3AcD+MvbA0fpZCbwHLsDvkVnCjrqAmbpLdfX9hP4OWQd4ev
bOQmsB0rpPG7t4yDFmzCFLZgsun+lDSxV4SvbOQkMCit8/Cq6uV0Pfh6SX6y6VktuIWvwVzS
nATGpHX+R62rTT5ag9+CD1t0vsUP4Wsslzg3ATiYS9qCnODrqPvYkEueU0qsiuvRTM5BvImn
cROWxf0aNuOjDrZ1H6s66FyGnATuAkUxjkcUS3a4OHexg/4bUs3Tis7BF8Un+CPOFXdmxJXM
2j1oKqdbJ223Hs9ZDLXc+xM3d7G7wk9OOb1YB5q//yvinARmkKrKongrQ3/fPPfaTdoGimK/
oqjvDTMZfpA3B85gWK22W6oqu2GHNMyeif/78FpXq1T0rZeKvDMZfpD3Bb6L67pMzgvYJs2D
oZAvZNqOxPX7TP2sBA7H9dFc0h6wscVnV+QmcFY6jKytEFQu1uJeafwfyjXKSeAC3gt5l/Kt
8hwUwU06oeUOuexldALT0unruVKh5WFTcM+Er2zkJjCrsbu+jdVlnHTBao3T2LiSnYoyG9ln
UjtkKb6U2iS9Yk1wLQvuT8sSlN2Jt0kV4xCOSMOpypwowvZIcB0M7tIom8AcHsceqdKcxDda
94hUmNVQC7kZ66QNcTI49gTnXMlYUK0zNyedmo5KY7fe5zmFz6VDz9Im/aV4IAJ/DHfH/Wnp
rZceNs3otbm7XDqQb8UtmT7PSuP9HV0m7GI0d2elNuEu6RQ1ptHcXRE60xrN3cPxy17n++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+5Svg8wF851RjHYTxHmYzDvfZSFAD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o6NNdtM4Nc0j0z7bbu3HsWmnlOM9SjG0Mn91ThdR5wSD
NFdW7/ePsdNbSgAsGRrmC0l/xpyRVJor+JBHSY4Fbci8nlrG5nMhbTKm3XK0cYmfYypDw3wv
6WPX5jbSKPVLBmUYGuZbSRtJX9jcBsow5mj2raq7V8xicxv9UP3nZ3CYvdez2NyeDQ5q2Tfq
PLP3+izpu9jcBiYX46KRz6o2t2fVMf4Ssels2+jLOb3Xs3O6l9jUBqYU5XLOxuY2gInEvDb7
NuK0APRkrnfO+hc9sa+nTjXd1Bq/cHJdTR3yN2P+PtZrLaN3TgA7hBkwYuLOCbyf24UMqTs/
mFjOz2N2n329i9Xe5eoaVmtXwrm0pwepzIARE1dm55So0I39FjxSNWZWR3rJtmx9DyB2Ve/A
A3VRNabnQoZTzUcXKjNgxOQd+pV6eqLU+Uqh5GUdM2+lLFeu+aAyA0YQZsAIwgwYQZgBIwgz
YARhBowgzIARhBkwgjADRkx+BRiwJCk75qAyA9Pwzjkfo4eRWq9ugxrfKgDiGp1qKjNgRN99
5ljbBLv9hkjTA+aivXUbLQMcAAOmEb2Q9QpzrKNvzZ3+lF36AgU6GmK62gWwQ5gBIwgzYARh
BowgzIARhBkAAAAAAACm/Q+8ohpTstSuawAAAABJRU5ErkJggg==]]>
				</image>
				<image icon="true" name="tof1.png" width="48" height="58">
					<![CDATA[iVBORw0KGgoAAAANSUhEUgAAADAAAAA6CAYAAAD2mdrhAAAD50lEQVRoge3ZT4jVVRQH8M9P
a2ikxTDluHEV1a4CIURQs4HGop1FRdRq0P4Yai3cRATiqqgmqRyZWglNSUirQAOLMRCRgpqN
YLRy00xTtijNGF+Le57zfL437/5+b1KU94XH78y9537POb/fPfeee4ceeuihhx566KGHyija
dfy++u5ag04reUns5GLw7M8t25d1S3y9ccsifUWG3AlVvlYp3PBfoBfA9cZiObCUKJML7Va9
lrl3w3+BtitKrRaBFwWt5FJWKo67gqK1q+0DKGuhSwc7oV0AN/cUWr1y67X05SqcnZ24LLf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		</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>