<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=OpenPLC-version1-with-LDmicro%2FC3%2FCTC-Counter%2FEnglish</id>
		<title>OpenPLC-version1-with-LDmicro/C3/CTC-Counter/English - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=OpenPLC-version1-with-LDmicro%2FC3%2FCTC-Counter%2FEnglish"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=OpenPLC-version1-with-LDmicro/C3/CTC-Counter/English&amp;action=history"/>
		<updated>2026-05-13T15:05:32Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=OpenPLC-version1-with-LDmicro/C3/CTC-Counter/English&amp;diff=54673&amp;oldid=prev</id>
		<title>Nancyvarkey at 19:05, 10 January 2021</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=OpenPLC-version1-with-LDmicro/C3/CTC-Counter/English&amp;diff=54673&amp;oldid=prev"/>
				<updated>2021-01-10T19:05:41Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://script.spoken-tutorial.org/index.php?title=OpenPLC-version1-with-LDmicro/C3/CTC-Counter/English&amp;amp;diff=54673&amp;amp;oldid=54609&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Nancyvarkey</name></author>	</entry>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=OpenPLC-version1-with-LDmicro/C3/CTC-Counter/English&amp;diff=54609&amp;oldid=prev</id>
		<title>Nirmala Venkat: Created page with &quot; {| border=&quot;1&quot; |-  | align=center| '''Visual Cue''' | align=center| '''Narration''' |-  || Slide 1:  || Welcome to the spoken tutorial on '''CTC Counter''' |-  || Slide 2:   L...&quot;</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=OpenPLC-version1-with-LDmicro/C3/CTC-Counter/English&amp;diff=54609&amp;oldid=prev"/>
				<updated>2020-12-23T12:44:19Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot; {| border=&amp;quot;1&amp;quot; |-  | align=center| &amp;#039;&amp;#039;&amp;#039;Visual Cue&amp;#039;&amp;#039;&amp;#039; | align=center| &amp;#039;&amp;#039;&amp;#039;Narration&amp;#039;&amp;#039;&amp;#039; |-  || Slide 1:  || Welcome to the spoken tutorial on &amp;#039;&amp;#039;&amp;#039;CTC Counter&amp;#039;&amp;#039;&amp;#039; |-  || Slide 2:   L...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| align=center| '''Visual Cue'''&lt;br /&gt;
| align=center| '''Narration'''&lt;br /&gt;
|- &lt;br /&gt;
|| Slide 1: &lt;br /&gt;
|| Welcome to the spoken tutorial on '''CTC Counter'''&lt;br /&gt;
|- &lt;br /&gt;
|| Slide 2: &lt;br /&gt;
&lt;br /&gt;
Learning Objectives&lt;br /&gt;
* Count circular(CTC) counter&lt;br /&gt;
|| &lt;br /&gt;
&lt;br /&gt;
In this tutorial, we’ll learn about working of &lt;br /&gt;
* '''Count circular '''counter&lt;br /&gt;
|- &lt;br /&gt;
|| Slide 3: System Requirements&lt;br /&gt;
* Ubuntu 18.04''' '''OS&lt;br /&gt;
* LDmicro&lt;br /&gt;
* OpenPLC V1 Mainboard&lt;br /&gt;
* 24V, 2A SMPS&lt;br /&gt;
* USBasp programmer&lt;br /&gt;
* Traffic Light module&lt;br /&gt;
* Switchboard module&lt;br /&gt;
&lt;br /&gt;
|| To record this tutorial I am using:&lt;br /&gt;
* '''Ubuntu Linux 18.04''' operating system&lt;br /&gt;
* '''LDmicro'''&lt;br /&gt;
* '''OpenPLC version1 Mainboard'''&lt;br /&gt;
* '''24V, 2A SMPS'''&lt;br /&gt;
* '''USBasp''' programmer&lt;br /&gt;
* '''Traffic Light''' module and&lt;br /&gt;
* '''Switchboard''' module&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Slide 4: Pre-requisites* Working of CTU and CTD counters&lt;br /&gt;
* If not, please refer to the relevant tutorials from [https://spoken-tutorial.org/ Home | spoken-tutorial.org]&lt;br /&gt;
&lt;br /&gt;
|| * To follow this tutorial, you should know the working of '''CTU''' and '''CTD''' counters.&lt;br /&gt;
* If not, please refer to the relevant tutorials in this series on this website.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|| Slide 5: Prerequisites - Hardware setup&lt;br /&gt;
&lt;br /&gt;
hardware-prerequisite.jpg&lt;br /&gt;
|| Connect''' SMPS''' and '''USBasp''' to the '''Mainboard''' as shown in the picture.&lt;br /&gt;
&lt;br /&gt;
Keep these connections throughout this tutorial.&lt;br /&gt;
|- &lt;br /&gt;
|| Open the LDmicro&lt;br /&gt;
|| Let us open '''LDmicro'''.&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
|| In this tutorial, we will create a ladder logic to turn on an LED.&lt;br /&gt;
&lt;br /&gt;
The condition is when the switch is pressed for exactly 3 times.&lt;br /&gt;
|- &lt;br /&gt;
|| Click ‘Instructions -&amp;gt; Insert Contact’&lt;br /&gt;
&lt;br /&gt;
Double-click on Xnew &amp;gt;&amp;gt; Type ‘switch’ in name box &amp;gt;&amp;gt; Click OK button&lt;br /&gt;
|| Insert a '''Contact''' and then rename it as '''‘switch’''' as shown.&lt;br /&gt;
|- &lt;br /&gt;
|| Place the cursor to the right of Xswitch &amp;gt;&amp;gt; Click Instructions -&amp;gt; Counters -&amp;gt; Insert CTC&lt;br /&gt;
|| We will now insert a '''CTC''' to the right of '''Xswitch'''.&lt;br /&gt;
&lt;br /&gt;
For that place the cursor to the right of '''Xswitch'''.&lt;br /&gt;
&lt;br /&gt;
Click on Instructions, then Counters and then on ‘'''Insert CTC’'''.&lt;br /&gt;
|- &lt;br /&gt;
|| Double-click on Cnew&lt;br /&gt;
|| Double-click on the CTC.&lt;br /&gt;
|- &lt;br /&gt;
|| In the name column, type count&lt;br /&gt;
|| We can observe there are two columns.&lt;br /&gt;
&lt;br /&gt;
First one is for the name of the counter.&lt;br /&gt;
&lt;br /&gt;
Type '''‘count’''' in it.&lt;br /&gt;
|- &lt;br /&gt;
|| In the True if &amp;gt;= column type 3&lt;br /&gt;
&lt;br /&gt;
Click the OK button&lt;br /&gt;
|| Second column is the Max value i.e. maximum value of the counter.&lt;br /&gt;
&lt;br /&gt;
Here, we have to enter the desired count value.&lt;br /&gt;
&lt;br /&gt;
We will enter 3 as the count value.&lt;br /&gt;
&lt;br /&gt;
Click on the '''OK''' button.&lt;br /&gt;
&lt;br /&gt;
Note that the name is prefixed by C by default.&lt;br /&gt;
|- &lt;br /&gt;
|| Click Edit -&amp;gt; Insert rung below&lt;br /&gt;
|| Now, insert a rung below.&lt;br /&gt;
|- &lt;br /&gt;
|| Place the cursor in the new rung &amp;gt;&amp;gt; Click Instructions -&amp;gt; Comparison operators -&amp;gt; Insert EQU&lt;br /&gt;
&lt;br /&gt;
Place the cursor to the right of EQU &amp;gt;&amp;gt; Click Instructions -&amp;gt; Insert Coil &lt;br /&gt;
|| Insert '''equals''' compare instruction in the new rung as shown.&lt;br /&gt;
&lt;br /&gt;
Place the cursor to the right of '''EQU''' and insert a '''Coil'''.&lt;br /&gt;
|- &lt;br /&gt;
|| Double-click on EQU &amp;gt;&amp;gt; Type Ccount in the ‘Closed’ if column &amp;gt;&amp;gt; Type 3 in =: column &amp;gt;&amp;gt; Click the OK button&lt;br /&gt;
|| In the compare instruction, compare '''Ccount''' with 3.&lt;br /&gt;
&lt;br /&gt;
That is, in the '''‘Closed if’''' column type '''Ccount''' and in the '''‘equals’''' column type 3.&lt;br /&gt;
|- &lt;br /&gt;
|| Double click on the coil &amp;gt;&amp;gt; Rename it as ‘LED’ &amp;gt;&amp;gt; Click OK button&lt;br /&gt;
|| Rename the Coil as '''‘LED’'''.&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
|| We will now check the working of this logic.&lt;br /&gt;
|- &lt;br /&gt;
|| Click Simulate -&amp;gt; Simulation mode &amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Click Simulate -&amp;gt; Real-time simulation&lt;br /&gt;
|| Let us turn on the simulation mode.&lt;br /&gt;
&lt;br /&gt;
For that, click '''Simulate''' and then on '''Simulation mode.'''&lt;br /&gt;
&lt;br /&gt;
Next, start real-time simulation as shown.&lt;br /&gt;
|- &lt;br /&gt;
|| Highlight the state of Xswitch, YLED and TON in the IO list&lt;br /&gt;
|| Initially the state of '''Xswitch''', '''YLED''' and '''Ccount''' are 0.&lt;br /&gt;
|- &lt;br /&gt;
|| Double-click on Xswitch in the IO list&lt;br /&gt;
&lt;br /&gt;
Highlight the state of Ccount&lt;br /&gt;
|| Change the state of '''Xswitch''' to 1 by double clicking on it.&lt;br /&gt;
&lt;br /&gt;
We can observe the '''Ccount''' value changes to 1.&lt;br /&gt;
&lt;br /&gt;
Change the state of '''Xswitch''' back to 0.&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
|| Just like CTU &amp;amp; CTD, the '''Ccount''' value updates only with the rising edge of its input.&lt;br /&gt;
|- &lt;br /&gt;
|| Double-click on Xswitch for 5 times&lt;br /&gt;
&lt;br /&gt;
Highlight the state of YLED&lt;br /&gt;
|| Keep double clicking on '''Xswitch''' until the state of '''Ccount''' reaches 3.&lt;br /&gt;
&lt;br /&gt;
We can observe the state of '''YLED''' changes to 1. &lt;br /&gt;
|- &lt;br /&gt;
|| Double-click on Xswitch &lt;br /&gt;
&lt;br /&gt;
Highlight the state of Ccount&lt;br /&gt;
|| Once again change the state of '''Xswitch''' from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
We can observe the '''Ccount''' value goes back to 0.&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
|| That is there is no need of '''RESET''' instruction to reset the counter.&lt;br /&gt;
|- &lt;br /&gt;
|| Click Simulate -&amp;gt; Halt Simulation &amp;gt;&amp;gt; Click Simulate -&amp;gt; Simulation Mode&lt;br /&gt;
|| Now, turn off the simulation mode.&lt;br /&gt;
&lt;br /&gt;
For that, click '''Simulate''' and then on '''Halt Simulation.'''&lt;br /&gt;
&lt;br /&gt;
Then click '''Simulate''' and '''Simulation Mode.'''&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
|| Now let us compile the logic.&lt;br /&gt;
&lt;br /&gt;
The detailed steps on how to compile and save the logic are explained in the earlier tutorials.&lt;br /&gt;
|- &lt;br /&gt;
|| Click on Settings &amp;gt;&amp;gt; Click on Microcontroller &amp;gt;&amp;gt; Select AVR ATmega16 40-PDIP &lt;br /&gt;
&lt;br /&gt;
Click on Settings &amp;gt;&amp;gt; Click on MCU parameters &amp;gt;&amp;gt; Change Crystal frequency to 16&lt;br /&gt;
|| Click on '''Settings''' and select the microcontroller '''AVR ATmega16 40-PDIP.''' &lt;br /&gt;
&lt;br /&gt;
Adjust its parameters as shown here.&lt;br /&gt;
|- &lt;br /&gt;
|| Double-click on Xswitch in I/O list &amp;gt;&amp;gt; Select PC0 &amp;gt;&amp;gt; Click OK button&lt;br /&gt;
&lt;br /&gt;
Double-click on YLED in I/O list &amp;gt;&amp;gt; Select PA0 &amp;gt;&amp;gt; Click OK button&lt;br /&gt;
|| Assign pin '''PC0''' to '''Xswitch''' and '''PA0''' to '''YLED'''.&lt;br /&gt;
|- &lt;br /&gt;
|| Click on Compile &amp;gt;&amp;gt; Click on Compile &amp;gt;&amp;gt; Go to Desktop/LDmicro folder &amp;gt;&amp;gt; Rename it as ‘ctc.hex’ &amp;gt;&amp;gt; Click on Save.&lt;br /&gt;
&lt;br /&gt;
Click OK button&lt;br /&gt;
|| Compile the logic as '''ctc.hex'''&lt;br /&gt;
|- &lt;br /&gt;
|| Click on File &amp;gt;&amp;gt; Click on Save &amp;gt;&amp;gt; Go to Desktop/LDmicro folder &amp;gt;&amp;gt; Rename it as ‘ctc.ld’ &amp;gt;&amp;gt; Click on Save&lt;br /&gt;
|| Save the file as '''ctc.ld'''&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
|| We will now see the working of this logic on hardware.&lt;br /&gt;
|- &lt;br /&gt;
|| Connect Mainboard to PC using USBasp&lt;br /&gt;
&lt;br /&gt;
laptop-usbasp.jpg&lt;br /&gt;
&lt;br /&gt;
|| Connect the '''Mainboard''' to your laptop using '''USBasp'''.&lt;br /&gt;
&lt;br /&gt;
Turn on the power supply.&lt;br /&gt;
|- &lt;br /&gt;
|| Open terminal &amp;gt;&amp;gt; Type cd Desktop/LDmicro &amp;gt;&amp;gt; Press ENTER &amp;gt;&amp;gt; type ‘'''avrdude -c usbasp -p m16 -U flash:w:ctc.hex’ '''&amp;gt;&amp;gt; Press ENTER&lt;br /&gt;
|| Open the terminal by pressing''' CTRL+ALT+T '''keys simultaneously.&lt;br /&gt;
&lt;br /&gt;
Go to the folder where you have saved the hex file.&lt;br /&gt;
&lt;br /&gt;
Type the command as shown to upload the hex file to the '''Mainboard'''.&lt;br /&gt;
|- &lt;br /&gt;
|| Remove the '''USBasp''' connection from the laptop.&lt;br /&gt;
|| Turn off the power supply.&lt;br /&gt;
&lt;br /&gt;
Remove the '''USBasp''' connection from the laptop.&lt;br /&gt;
&lt;br /&gt;
This will prevent any hardware damage.&lt;br /&gt;
|- &lt;br /&gt;
|| ctc.png&lt;br /&gt;
|| Let us see the connection details now. &lt;br /&gt;
|- &lt;br /&gt;
|| ctc.png&lt;br /&gt;
|| Connect '''GND''' pin of the red LED of '''Traffic Light''' module to '''GND''' of the '''Mainboard'''.&lt;br /&gt;
&lt;br /&gt;
Then connect the '''+5V pin''' of the red LED to '''PA0''' pin of the '''Mainboard'''.&lt;br /&gt;
|- &lt;br /&gt;
|| ctc.png&lt;br /&gt;
|| Connect '''GND''' and '''5V''' of '''switchboard''' to GND and 5V of the '''Mainboard''' respectively.&lt;br /&gt;
&lt;br /&gt;
Then connect '''NO1''' of the '''Switchboard''' to '''PC0''' of the '''Mainboard'''.&lt;br /&gt;
&lt;br /&gt;
Make the connections as shown in the picture.&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
|| After making all the connections properly, turn on the power supply.&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
|| Initially the red LED will not glow.&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
|| It will glow only when NO1 is pressed for three times.&lt;br /&gt;
&lt;br /&gt;
So, press the NO1 for 3 times.&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
|| We can see the LED will be glowing even after NO1 is released.&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
|| Press the switch '''NO1''' for one more time.&lt;br /&gt;
&lt;br /&gt;
We can observe the LED goes off.&lt;br /&gt;
&lt;br /&gt;
Recall that it was not the case with '''CTU'''.&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
|| That is '''CTC''' counter resets automatically after reaching the desired count value.&lt;br /&gt;
&lt;br /&gt;
Thus the difference between '''CTU''' and '''CTC''' is auto reset.&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
|| Turn off the power supply.&lt;br /&gt;
|- &lt;br /&gt;
|| &lt;br /&gt;
|| This brings us to the end of this tutorial.&lt;br /&gt;
&lt;br /&gt;
Let us summarize.&lt;br /&gt;
|- &lt;br /&gt;
|| Slide 7: Summary* Count circular (CTC) counter&lt;br /&gt;
&lt;br /&gt;
|| In this tutorial we learnt about working of * '''Count circular '''counter&lt;br /&gt;
|- &lt;br /&gt;
|| Slide 8: Assignment&lt;br /&gt;
&lt;br /&gt;
Draw a ladder logic where the state of LED depends on switch press count&lt;br /&gt;
# count = 0, LED should RESET. &lt;br /&gt;
# count = 1, LED should start blinking&lt;br /&gt;
# count = 2, the LED should be SET&lt;br /&gt;
&lt;br /&gt;
|| As an assignment, do the following.&lt;br /&gt;
&lt;br /&gt;
Draw a ladder logic where the state of LED depends on switch press count.&lt;br /&gt;
&lt;br /&gt;
That is, when# count = 0, LED should RESET. &lt;br /&gt;
# count = 1 , LED should start blinking&lt;br /&gt;
# count = 2, the LED should be SET&lt;br /&gt;
|- &lt;br /&gt;
|| Slide 9:&lt;br /&gt;
&lt;br /&gt;
About Spoken Tutorial project&lt;br /&gt;
|| The video at the following link summarises the Spoken Tutorial project.&lt;br /&gt;
&lt;br /&gt;
Please download and watch it&lt;br /&gt;
|- &lt;br /&gt;
|| Slide 10:&lt;br /&gt;
&lt;br /&gt;
Spoken Tutorial workshops&lt;br /&gt;
|| The''' Spoken Tutorial Project''' team:* conducts workshops using spoken tutorials and&lt;br /&gt;
* gives certificates on passing online &lt;br /&gt;
tests.&lt;br /&gt;
&lt;br /&gt;
For more details, please write to us&lt;br /&gt;
|- &lt;br /&gt;
|| Slide 11:&lt;br /&gt;
&lt;br /&gt;
Forum for specific questions:&lt;br /&gt;
|| Please post your timed queries in this forum&lt;br /&gt;
|- &lt;br /&gt;
|| Slide 12:&lt;br /&gt;
&lt;br /&gt;
Forum for specific questions:&lt;br /&gt;
|| Do you have any general / technical questions on OpenPLC?&lt;br /&gt;
&lt;br /&gt;
Please visit the FOSSEE forum and post your question.&lt;br /&gt;
|- &lt;br /&gt;
|| Slide 13:&lt;br /&gt;
&lt;br /&gt;
Acknowledgement&lt;br /&gt;
|| Spoken Tutorial Project is funded by MHRD, Government of India.&lt;br /&gt;
|- &lt;br /&gt;
|| Slide 14:&lt;br /&gt;
&lt;br /&gt;
Thank you slide&lt;br /&gt;
|| This tutorial has been contributed by FOSSEE and Spoken Tutorial Project, IIT Bombay.&lt;br /&gt;
&lt;br /&gt;
And this is Harsha Priyanka from FOSSEE team, signing off.&lt;br /&gt;
&lt;br /&gt;
Thanks for watching.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Nirmala Venkat</name></author>	</entry>

	</feed>