<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Input pulse counting</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/f2eeddd37b/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/f2eeddd37b/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/f2eeddd37b/</id><updated>2020-02-27T22:42:51.940000Z</updated><subtitle>Recent posts to Input pulse counting</subtitle><entry><title>Input pulse counting</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f2eeddd37b/?limit=25#6c00" rel="alternate"/><published>2020-02-27T22:42:51.940000Z</published><updated>2020-02-27T22:42:51.940000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.com6222fa8189ba50c11b5457d05564cc4ef32bae3b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;easy one, oja still newbie.&lt;/p&gt;
&lt;p&gt;i would recommend a course at plcs.net.&lt;/p&gt;
&lt;p&gt;if sensor 1 on and sensor 2 off then someone enters.&lt;/p&gt;
&lt;p&gt;if sensor 2 on and sensor 1 off somenone leaves.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Input pulse counting</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f2eeddd37b/?limit=25#fb40" rel="alternate"/><published>2020-02-27T22:42:50.246000Z</published><updated>2020-02-27T22:42:50.246000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.come866a5fb15ab25abea9a0f4c359387d5ccdad7bb</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; H87&lt;/p&gt;
&lt;p&gt;Thank you very much guys. Its working perfect.&lt;/p&gt;
&lt;p&gt;But now i have another case: I have tryed manny diferent things, but it wont work as atended.&lt;/p&gt;
&lt;p&gt;Case is: i dont want a reset button annymore. so i installed a second movment sensor at the door. so they are standing next to each other.&lt;/p&gt;
&lt;p&gt;So i want the sensors to detect how manny is going in and how manny is going out&lt;/p&gt;
&lt;p&gt;-So if signal for sensor 1 is detected first = someone is going in to the room (count 1 up)&lt;/p&gt;
&lt;p&gt;-But if signal from sensor 2 is detected first = someone is leaving the room (count 1 down)&lt;/p&gt;
&lt;p&gt;Sorry for bothering you guys. But I'm still a newbi. Promise to get bether&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Henrik&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Input pulse counting</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f2eeddd37b/?limit=25#2af2" rel="alternate"/><published>2020-02-27T22:42:45.773000Z</published><updated>2020-02-27T22:42:45.773000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.comdb11466f20157313ee85ed820d3d176c9d2acf21</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;and to finish rolf &lt;/p&gt;
&lt;p&gt;Sensor  at %IX0.0  : BOOL;&lt;/p&gt;
&lt;p&gt;Reset   at %IX0.1  : BOOL; &lt;/p&gt;
&lt;p&gt;just to be sure you have inputs from the PLC.&lt;/p&gt;
&lt;p&gt;yes rolf is my teacher i am always a little short in the corners.&lt;/p&gt;
&lt;p&gt;and norman is also correct, but timers do not come in lecture 1 but in lecture 3.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Input pulse counting</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f2eeddd37b/?limit=25#883c" rel="alternate"/><published>2020-02-27T22:42:44.145000Z</published><updated>2020-02-27T22:42:44.145000Z</updated><author><name>ndzied1</name><uri>https://forge.codesys.com/u/ndzied1/</uri></author><id>https://forge.codesys.com821f4ca763adbd91428ad71e3cafbd7d5d94646d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;You may want a short time delay on the count in case the signal bounces a few times as the person starts to actuate the sensor.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Input pulse counting</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f2eeddd37b/?limit=25#7cbd" rel="alternate"/><published>2020-02-27T22:42:39.706000Z</published><updated>2020-02-27T22:42:39.706000Z</updated><author><name>Rolf-Geisler</name><uri>https://forge.codesys.com/u/rolf-geisler/</uri></author><id>https://forge.codesys.com98e45e1fe81116b8dd228ad8b67334375360ca1f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Henrik,&lt;/p&gt;
&lt;p&gt;Shooter is almost right, however, you need to declare instances of the R_TRIGs and F_TRIGs, then it will work&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;VAR&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="n"&gt;Sensor&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;Reset&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="n"&gt;CountTrig&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;R_TRIG&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="n"&gt;catch&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;rising&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt; &lt;span class="n"&gt;edge&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="n"&gt;ClearTrig&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;F_TRIG&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="n"&gt;catch&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;falling&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt; &lt;span class="n"&gt;edge&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;Count&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;END_VAR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;CountTrig&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;CLK&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;Sensor&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;; (* finds the counting up events *)&lt;/span&gt;
&lt;span class="nv"&gt;ClearTrig&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;CLK&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;Reset&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;; (* finds the clear commands *)&lt;/span&gt;
&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;CountTrig&lt;/span&gt;.&lt;span class="nv"&gt;Q&lt;/span&gt;
&lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="nv"&gt;Count&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;Count&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;END_IF&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;ClearTrig&lt;/span&gt;.&lt;span class="nv"&gt;Q&lt;/span&gt;
&lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="nv"&gt;Count&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;END_IF&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;That's quite easy to understand I hope. &lt;/p&gt;
&lt;p&gt;Details of the standard FBs such as R_TRIG or F_TRIG you should find in the CoDeSys online help, or on the internet at IEC61131 related websites.&lt;/p&gt;
&lt;p&gt;Regards &lt;/p&gt;
&lt;p&gt;Rolf&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Input pulse counting</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f2eeddd37b/?limit=25#43b4" rel="alternate"/><published>2020-02-27T22:42:38.116000Z</published><updated>2020-02-27T22:42:38.116000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.coma8cba372da38f1df6f6be76f65ab686ef93c6f03</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;the line should be something like &lt;/p&gt;
&lt;p&gt;IF R_TRIG (pulse) then counter:= counter+1; END_IF;&lt;/p&gt;
&lt;p&gt;IF R_TRIG (reset) then counter:=0;END_IF;&lt;/p&gt;
&lt;p&gt;also F_TRIG is possible.&lt;/p&gt;
&lt;p&gt;lots of other possibilities like using a function block CNT etc.&lt;/p&gt;
&lt;p&gt;in simulation you will not see this pulse as it is only one cycle.&lt;/p&gt;
&lt;p&gt;if you want to know how many people are in then you will need two pulsemachines and check the sequence of them.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Input pulse counting</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/f2eeddd37b/?limit=25#6d1c" rel="alternate"/><published>2020-02-27T22:42:36.343000Z</published><updated>2020-02-27T22:42:36.343000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comf6db1201faec507ae5d60c41febf82e014bb7c14</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; H87&lt;/p&gt;
&lt;p&gt;i'm new at CoDeSys. and i'm wondering how to make a program counting input pulses.&lt;/p&gt;
&lt;p&gt;This is the case:&lt;/p&gt;
&lt;p&gt;I got a movment sensor placed at my door. And i wanna see on my plc program how manny has enterd the room. So every time the input is high i want the program to count 1. and if it gets high again, then is 2 and so on.&lt;/p&gt;
&lt;p&gt;And ofc a reset button. &lt;/p&gt;
&lt;p&gt;Would be awsome if someone can help me.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Henrik&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>