<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to using CTU block for uint counter</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/ee797a46cd/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/ee797a46cd/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/ee797a46cd/</id><updated>2020-02-27T22:21:15.540000Z</updated><subtitle>Recent posts to using CTU block for uint counter</subtitle><entry><title>using CTU block for uint counter</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/ee797a46cd/?limit=25#6ad5" rel="alternate"/><published>2020-02-27T22:21:15.540000Z</published><updated>2020-02-27T22:21:15.540000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.com6524e54d2b5d5281eb48e7603166a77e39405b30</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;indeed look at oscat for a double word counter, or make it yourself, you will learn a lot from it.&lt;/p&gt;
&lt;p&gt;if a DW is not enough, you will need to make a 8 byte counter, with for example an array.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>using CTU block for uint counter</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/ee797a46cd/?limit=25#ba60" rel="alternate"/><published>2020-02-27T22:21:13.937000Z</published><updated>2020-02-27T22:21:13.937000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com000e0a6d29e63309e17a18a4a013c1d99e58b665</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;Use two CTU blocks - one feeding into the other, with rollover mode. &lt;/p&gt;
&lt;p&gt;Or, just build your own (ST language may be easiest).  You simply need to increment your var on rising edge (R_TRIG). &lt;/p&gt;
&lt;p&gt;Or check into the OSCAT library (OSCAT.de). I think it has larger CTUs.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>using CTU block for uint counter</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/ee797a46cd/?limit=25#2160" rel="alternate"/><published>2020-02-27T22:21:09.453000Z</published><updated>2020-02-27T22:21:09.453000Z</updated><author><name>Hicham.M</name><uri>https://forge.codesys.com/u/hicham-m/</uri></author><id>https://forge.codesys.comeab27134ed0b8df52781065b4c91ff32551bbfc8</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;scott_cunningham hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
Ah, you are using version 2.3.  Sorry, missed that. So a WORD is "the same" as a UINT. You simply need to cast your variables WORD_TO_UINT() or UINT_TO_WORD(). In general programmers signal but coded usage with WORD and arithmetic with an UINT. Otherwise they are both 16 bit unsigned.... Embedded controller programmers and C programmers will often use BYTE WORD and LONG instead of USINT UINT UDINT.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Now I see, I'm an embedded software developer and have this small project using PLC.&lt;/p&gt;
&lt;p&gt;Based on codesys manual &lt;br/&gt;
WORD is the same as UINT : size 2 bytes with max value : 65535. &lt;br/&gt;
I need to use DWORD type to get my counter beyond 65535 which is not possible with CTU bloc !!&lt;/p&gt;
&lt;p&gt;is there a solution for that ?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>using CTU block for uint counter</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/ee797a46cd/?limit=25#2bc6" rel="alternate"/><published>2020-02-27T22:21:07.860000Z</published><updated>2020-02-27T22:21:07.860000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.coma80b1e4999783075e046b8e08511127175504010</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;Ah, you are using version 2.3.  Sorry, missed that. So a WORD is "the same" as a UINT. You simply need to cast your variables WORD_TO_UINT() or UINT_TO_WORD(). In general programmers signal but coded usage with WORD and arithmetic with an UINT. Otherwise they are both 16 bit unsigned.... Embedded controller programmers and C programmers will often use BYTE WORD and LONG instead of USINT UINT UDINT.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>using CTU block for uint counter</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/ee797a46cd/?limit=25#842b" rel="alternate"/><published>2020-02-27T22:21:03.504000Z</published><updated>2020-02-27T22:21:03.504000Z</updated><author><name>Hicham.M</name><uri>https://forge.codesys.com/u/hicham-m/</uri></author><id>https://forge.codesys.com3d5fc23c9c43f52553a806fe9c793a611e673ad6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;scott_cunningham hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
I deleted my first answer due to not understanding the question. &lt;br/&gt;
The CTU should work with UINT, INT, WORD. Check the help - it says what is supported. I don't think longs are, though (may be wrong)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Thank you for your answer, In the help it says the following&lt;/p&gt;
&lt;p&gt;Function block Incrementer (CTU):&lt;br/&gt;
The input variables CU and RESET as well as the output variable Q are type BOOL, the input variable&lt;br/&gt;
PV and the output variable &lt;strong&gt;CV are type WORD&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Also in the first chapters of the help, they mention that the size of type WORD variable is 16bit means it's max is  65535.&lt;/p&gt;
&lt;p&gt;Am I reading the help wronge ?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>using CTU block for uint counter</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/ee797a46cd/?limit=25#0817" rel="alternate"/><published>2020-02-27T22:21:01.844000Z</published><updated>2020-02-27T22:21:01.844000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com90d8453af8ab4e47cee1e7785c88875a3d449970</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;I deleted my first answer due to not understanding the question. &lt;/p&gt;
&lt;p&gt;The CTU should work with UINT, INT, WORD. Check the help - it says what is supported. I don't think longs are, though (may be wrong)&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>using CTU block for uint counter</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/ee797a46cd/?limit=25#88f1" rel="alternate"/><published>2020-02-27T22:20:57.370000Z</published><updated>2020-02-27T22:20:57.370000Z</updated><author><name>Hicham.M</name><uri>https://forge.codesys.com/u/hicham-m/</uri></author><id>https://forge.codesys.come300795998b576bb2c98ae90f776f2b54c3a124a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello,&lt;br/&gt;
I want to use the CTU block to count beyond WORD type max (65,535).&lt;br/&gt;
I put in the output of the CTU block an UINT variable, it compiles with no errors but I'm not sure if this would work or not ?&lt;/p&gt;
&lt;p&gt;What's the best way to do this ?&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>