Difference between revisions of "OpenPLC-version1-with-LDmicro/C2/Normal-Contact/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with " {| style="border-spacing:0;" | style="border:1pt solid #000000;padding:0.176cm;"| <center>'''Visual Cue'''</center> | style="border:1pt solid #000000;padding:0.176cm;"| <cent...")
 
 
Line 13: Line 13:
 
* Normal Contact
 
* Normal Contact
  
| style="border:1pt solid #000000;padding:0.176cm;"| In this tutorial, we will learn about the working of
+
| style="border:1pt solid #000000;padding:0.176cm;"| In this tutorial, we will learn about the working of '''Normal Contact'''
 
+
* '''Normal Contact'''
+
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Slide 3: System Requirements
 
| style="border:1pt solid #000000;padding:0.176cm;"| Slide 3: System Requirements
  
* Ubuntu Linux 18.04''' '''OS
+
* '''Ubuntu Linux 18.04''' OS
* LDmicro
+
* '''LDmicro'''
* OpenPLC version 1 Mainboard
+
* ''''OpenPLC''' version 1 '''Mainboard'''
* 24V, 2A SMPS
+
* 24V, 2A '''SMPS'''
* USBasp programmer
+
* '''USBasp programmer'''
* Traffic Light module
+
* '''Traffic Light module'''
* Switchboard module
+
* '''Switchboard module'''
  
 
| style="border:1pt solid #000000;padding:0.176cm;"| To record this tutorial I am using:
 
| style="border:1pt solid #000000;padding:0.176cm;"| To record this tutorial I am using:
  
* '''Ubuntu Linux 18.04''' operating system
+
* '''Ubuntu Linux''' 18.04 operating system
 
* '''LDmicro'''
 
* '''LDmicro'''
* '''OpenPLC version1 Mainboard'''
+
* '''OpenPLC''' version1 '''Mainboard'''
 
* 24V, 2A '''SMPS'''
 
* 24V, 2A '''SMPS'''
* '''USBasp''' programmer
+
* '''USBasp programmer'''
* '''Traffic Light''' module and  
+
* '''Traffic Light module''' and  
* '''Switchboard''' module
+
* '''Switchboard module'''
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Slide 4: Pre-requisites
 
| style="border:1pt solid #000000;padding:0.176cm;"| Slide 4: Pre-requisites
  
* Program OpenPLC V1 Mainboard and
+
* '''Program OpenPLC''' V1 '''Mainboard''' and
* Interface OpenPLC modules with Mainboard.  
+
* '''Interface OpenPLC modules''' with '''Mainboard'''.  
  
 
If not, please refer to the relevant tutorials from [https://spoken-tutorial.org/ Home | spoken-tutorial.org]
 
If not, please refer to the relevant tutorials from [https://spoken-tutorial.org/ Home | spoken-tutorial.org]
| style="border:1pt solid #000000;padding:0.176cm;"| * To follow this tutorial, you should know how to  
+
| style="border:1pt solid #000000;padding:0.176cm;"|  
** program '''OpenPLC V1 Mainboard''' and
+
* To follow this tutorial, you should know how to  
** interface '''OpenPLC''' modules with the '''Mainboard'''.  
+
** '''program OpenPLC V1 Mainboard''' and
 +
** '''interface OpenPLC modules''' with the '''Mainboard'''.  
 
* If not, please refer to the relevant tutorials in this series on this website.
 
* If not, please refer to the relevant tutorials in this series on this website.
  
Line 66: Line 65:
  
 
|-
 
|-
| style="border:1pt solid #000000;padding:0.176cm;"| Rename the coil as LED. Click the OK button.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Rename the '''coil''' as '''LED'''. Click the OK button.
 
| style="border:1pt solid #000000;padding:0.176cm;"| Rename the''' Coil''' as '''LED '''as shown.  
 
| style="border:1pt solid #000000;padding:0.176cm;"| Rename the''' Coil''' as '''LED '''as shown.  
  
Line 75: Line 74:
 
| style="border:1pt solid #000000;padding:0.176cm;"| Place the cursor to the left of the '''Coil'''.
 
| style="border:1pt solid #000000;padding:0.176cm;"| Place the cursor to the left of the '''Coil'''.
  
Insert a '''Contact''' from Instructions.
+
Insert a '''Contact''' from '''Instructions'''.
  
 
|-
 
|-
Line 83: Line 82:
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
| style="border:1pt solid #000000;padding:0.176cm;"| A dialogue box opens.
+
| style="border:1pt solid #000000;padding:0.176cm;"| A dialog box opens.
  
 
|-
 
|-
Line 90: Line 89:
 
| style="border:1pt solid #000000;padding:0.176cm;"| We can find a check-box called ‘'''Negated'''’ just below the name box.
 
| style="border:1pt solid #000000;padding:0.176cm;"| We can find a check-box called ‘'''Negated'''’ just below the name box.
  
If it is checked then the Contact is a '''Negated Contact'''.
+
If it is checked then the '''Contact''' is a '''Negated Contact'''.
  
If it is unchecked then the Contact is a '''Normal Contact.'''
+
If it is unchecked then the '''Contact''' is a '''Normal Contact.'''
  
'''Normal Contact''' will pass the signal when its state is logic 1.
+
'''Normal Contact''' will pass the '''signal''' when its '''state''' is '''logic 1'''.
  
Thus, we have two types of Contacts.
+
Thus, we have two types of '''Contacts'''.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight Source column
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight Source column
| style="border:1pt solid #000000;padding:0.176cm;"| These Contacts have three source types which are '''Internal Relay, Input pin, '''and''' Output pin'''.
+
| style="border:1pt solid #000000;padding:0.176cm;"| These '''Contacts''' have three '''source types''' which are '''Internal Relay, Input pin, '''and''' Output pin'''.
  
 
|-
 
|-
Line 106: Line 105:
  
 
Highlight Input pin
 
Highlight Input pin
| style="border:1pt solid #000000;padding:0.176cm;"| By default, '''Negated''' is unchecked with source as ‘'''Input pin'''’.
+
| style="border:1pt solid #000000;padding:0.176cm;"| By default, '''Negated''' is unchecked with '''source''' as ‘'''Input pin'''’.
  
‘'''Input pin'''’ represents that Contact reads an input pin of the microcontroller.
+
‘'''Input pin'''’ represents that '''Contact''' reads an '''input pin''' of the '''microcontroller'''.
  
 
Don't change them.
 
Don't change them.
  
Keep the default settings as it is.
+
Keep the default '''settings''' as it is.
|-
+
 
+
|-
+
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
| style="border:1pt solid #000000;padding:0.176cm;"| We will learn about other types of '''Contact''' and sources in the later tutorials.
+
| style="border:1pt solid #000000;padding:0.176cm;"| We will learn about other '''types''' of '''Contact''' and '''sources''' in the later tutorials.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Rename it as ‘switch’ >> Click OK button
 
| style="border:1pt solid #000000;padding:0.176cm;"| Rename it as ‘switch’ >> Click OK button
| style="border:1pt solid #000000;padding:0.176cm;"| Rename the Contact as ‘'''switch'''’ and click the OK button.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Rename the '''Contact''' as ‘'''switch'''’ and click the '''OK''' button.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
| style="border:1pt solid #000000;padding:0.176cm;"| Now we will check the working of this logic.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Now we will check the working of this '''logic'''.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Click ‘Simulate -> Simulation mode’ >> Click ‘Simulate -> Real-time simulation’
 
| style="border:1pt solid #000000;padding:0.176cm;"| Click ‘Simulate -> Simulation mode’ >> Click ‘Simulate -> Real-time simulation’
| style="border:1pt solid #000000;padding:0.176cm;"| Let us turn on the simulation mode.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Let us turn on the '''simulation mode'''.
  
 
For that, click '''Simulate''' and then on '''Simulation mode.'''
 
For that, click '''Simulate''' and then on '''Simulation mode.'''
  
Next, start real-time simulation as shown.
+
Next, start '''real-time simulation''' as shown.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight state of Xswitch and YLED
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight state of Xswitch and YLED
| style="border:1pt solid #000000;padding:0.176cm;"| Observe the state of '''Xswitch''' and '''YLED''' in the '''I/O list'''.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Observe the '''state''' of '''Xswitch''' and '''YLED''' in the '''I/O list'''.
  
Initially, the state of '''Xswitch''' and '''YLED''' are 0.
+
Initially, the '''state''' of '''Xswitch''' and '''YLED''' are 0.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double-click on Xswitch
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double-click on Xswitch
| style="border:1pt solid #000000;padding:0.176cm;"| The input to the '''Xswitch''' is logic 1 as it is connected to positive rail.
+
| style="border:1pt solid #000000;padding:0.176cm;"| The '''input''' to the '''Xswitch''' is '''logic 1''' as it is connected to '''positive rail'''.
  
Change the state of '''Xswitch''' to 1 by double clicking on it.
+
Change the '''state''' of '''Xswitch''' to 1 by double-clicking on it.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight state of YLED
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight state of YLED
| style="border:1pt solid #000000;padding:0.176cm;"| We can observe that the state of the '''YLED''' has changed to 1.
+
| style="border:1pt solid #000000;padding:0.176cm;"| We can observe that the '''state''' of the '''YLED''' has changed to 1.
  
That means input to '''YLED''' is logic 1.
+
That means '''input''' to '''YLED''' is '''logic 1'''.
  
This in turn indicates that output of '''Xswitch''' is logic 1.
+
This in turn indicates that '''output''' of '''Xswitch''' is '''logic 1'''.
  
Thus, when the state of a '''Normal Contact''' is 1, it passes the signal through it.
+
Thus, when the '''state''' of a '''Normal Contact''' is 1, it passes the '''signal''' through it.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Click Simulate -> Halt Simulation >> Click Simulate -> Simulation Mode
 
| style="border:1pt solid #000000;padding:0.176cm;"| Click Simulate -> Halt Simulation >> Click Simulate -> Simulation Mode
| style="border:1pt solid #000000;padding:0.176cm;"| Now, turn off the simulation mode.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Now, turn off the '''simulation mode'''.
  
 
For that, click '''Simulate''' and then on '''Halt Simulation.'''
 
For that, click '''Simulate''' and then on '''Halt Simulation.'''
Line 169: Line 165:
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
| style="border:1pt solid #000000;padding:0.176cm;"| Now let us compile the logic.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Now let us '''compile''' the '''logic'''.
  
The detailed steps on how to compile and save the logic are explained in the earlier tutorials.  
+
The detailed steps on how to '''compile''' and save the '''logic''' are explained in the earlier tutorials.  
  
 
|-
 
|-
Line 177: Line 173:
  
 
Click on Settings >> Click on MCU parameters >> Change Crystal frequency to 16 >>Click OK button
 
Click on Settings >> Click on MCU parameters >> Change Crystal frequency to 16 >>Click OK button
| style="border:1pt solid #000000;padding:0.176cm;"| Click on '''Settings''' and select microcontroller '''AVR ATmega16 40-PDIP.'''  
+
| style="border:1pt solid #000000;padding:0.176cm;"| Click on '''Settings''' and select '''microcontroller  AVR ATmega16 40-PDIP.'''  
  
Adjust its parameters as shown here.
+
Adjust its '''parameters''' as shown here.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double-click on Xswitch in I/O list >> Select PC0 >> Click OK button
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double-click on Xswitch in I/O list >> Select PC0 >> Click OK button
| style="border:1pt solid #000000;padding:0.176cm;"| Assign '''pin''' '''PA0''' to the Coil '''YLED'''.  
+
| style="border:1pt solid #000000;padding:0.176cm;"| Assign '''pin PA0''' to the '''Coil YLED'''.  
  
 
|-
 
|-
Line 193: Line 189:
  
 
Click OK button
 
Click OK button
| style="border:1pt solid #000000;padding:0.176cm;"| Compile it as ‘'''normalcontact.hex'''’.
+
| style="border:1pt solid #000000;padding:0.176cm;"| '''Compile''' it as ‘'''normalcontact.hex'''’.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Click on File >> Click on Save As >> Go to Desktop/LDmicro folder>> Rename it as ‘normalcontact.ld’ >> Click on Save
 
| style="border:1pt solid #000000;padding:0.176cm;"| Click on File >> Click on Save As >> Go to Desktop/LDmicro folder>> Rename it as ‘normalcontact.ld’ >> Click on Save
| style="border:1pt solid #000000;padding:0.176cm;"| Then save the ladder diagram as ‘'''normalcontact.ld'''’.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Then save the '''ladder diagram''' as ‘'''normalcontact.ld'''’.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
| style="border:1pt solid #000000;padding:0.176cm;"| Now we will see the working of this logic on hardware.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Now we will see the working of this '''logic''' on '''hardware'''.
  
 
|-
 
|-
| style="border:1pt solid #000000;padding:0.176cm;"| Connect Mainboard to PC using USBasp
+
| style="border:1pt solid #000000;padding:0.176cm;"| Connect '''Mainboard''' to PC using USBasp
  
 
laptop-usbasp.jpg
 
laptop-usbasp.jpg
Line 210: Line 206:
 
| style="border:1pt solid #000000;padding:0.176cm;"| Connect the '''Mainboard''' to your laptop using '''USBasp'''.
 
| style="border:1pt solid #000000;padding:0.176cm;"| Connect the '''Mainboard''' to your laptop using '''USBasp'''.
  
Turn on the power supply.
+
Turn on the '''power supply'''.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Go to terminal >> type '''avrdude -c usbasp -p m16 -U flash:w:normalcontact.hex '''>> Press ENTER
 
| style="border:1pt solid #000000;padding:0.176cm;"| Go to terminal >> type '''avrdude -c usbasp -p m16 -U flash:w:normalcontact.hex '''>> Press ENTER
| style="border:1pt solid #000000;padding:0.176cm;"| Open the Terminal by pressing '''CTRL+ALT+T''' keys simultaneously.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Open the '''Terminal''' by pressing '''CTRL+ALT+T''' keys simultaneously.
  
Go to the folder where you have saved the hex file.
+
Go to the folder where you have saved the '''hex''' file.
  
Type the command as shown and upload this hex file to the '''Mainboard'''.
+
Type the '''command''' as shown and upload this '''hex''' file to the '''Mainboard'''.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Remove the '''USBasp''' connection from the laptop.
 
| style="border:1pt solid #000000;padding:0.176cm;"| Remove the '''USBasp''' connection from the laptop.
| style="border:1pt solid #000000;padding:0.176cm;"| Turn off the power supply.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Turn off the '''power supply'''.
  
 
Remove the '''USBasp''' connection from the laptop.
 
Remove the '''USBasp''' connection from the laptop.
  
This will prevent any hardware damage.
+
This will prevent any '''hardware''' damage.
  
 
|-
 
|-
Line 240: Line 236:
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| normalcontact-NO.png
 
| style="border:1pt solid #000000;padding:0.176cm;"| normalcontact-NO.png
| style="border:1pt solid #000000;padding:0.176cm;"| Connect '''GND pin''' of the red LED of '''Traffic Light module''' to '''GND''' pin of the '''Mainboard'''.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Connect '''GND pin''' of the red '''LED''' of '''Traffic Light module''' to '''GND''' pin of the '''Mainboard'''.
  
Then connect the +5V pin of the red LED to '''PA0 pin''' of the '''Mainboard'''.
+
Then connect the '''+5V pin''' of the red '''LED''' to '''PA0 pin''' of the '''Mainboard'''.
  
 
Make the connections as shown in the picture.
 
Make the connections as shown in the picture.
Line 248: Line 244:
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
| style="border:1pt solid #000000;padding:0.176cm;"| After making all the connections properly, turn on the power supply.
+
| style="border:1pt solid #000000;padding:0.176cm;"| After making all the connections properly, turn on the '''power supply'''.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
| style="border:1pt solid #000000;padding:0.176cm;"| We can observe the red LED is off initially.  
+
| style="border:1pt solid #000000;padding:0.176cm;"| We can observe the red '''LED''' is '''OFF''' initially.  
  
It is ON whenever the '''NO1''' is pressed.
+
It is '''ON''' whenever the '''NO1''' is pressed.
  
That is the corresponding switch LED and the red LED glows simultaneously.
+
That is the corresponding '''switch LED''' and the red '''LED''' glows simultaneously.
  
 
|-
 
|-
Line 264: Line 260:
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
| style="border:1pt solid #000000;padding:0.176cm;"| Let me show the live demo of the output.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Let me show the live demo of the '''output'''.
  
We can observe that the red LED glows even before the switch is pressed.
+
We can observe that the red '''LED''' glows even before the '''switch''' is pressed.
  
And turns off whenever the '''NC1''' is pressed.
+
And turns '''OFF''' whenever the '''NC1''' is pressed.
  
That is the corresponding switch LED and the red LED glows alternately.
+
That is the corresponding '''switch LED''' and the red '''LED''' glows alternately.
  
 
|-
 
|-
Line 278: Line 274:
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
| style="border:1pt solid #000000;padding:0.176cm;"| Initially, the red LED is off.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Initially, the red '''LED''' is off.
  
When '''L1''' is pressed, both''' L1 '''switch LED and the red LED turns on.
+
When '''L1''' is pressed, both''' L1 switch LED''' and the red '''LED''' turns '''ON'''.
  
The LED will turn off when we press '''L1''' one more time as these are latch switches.
+
The '''LED''' will turn '''OFF''' when we press '''L1''' one more time as these are '''latch switches'''.
  
Thus, the corresponding switch LED and the red LED glows simultaneously.
+
Thus, the corresponding '''switch LED''' and the red '''LED''' glows simultaneously.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
| style="border:1pt solid #000000;padding:0.176cm;"| This shows how a '''Normal''' '''Contact''' behaves with different types of switches.
+
| style="border:1pt solid #000000;padding:0.176cm;"| This shows how a '''Normal Contact''' behaves with different types of '''switches'''.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
| style="border:1pt solid #000000;padding:0.176cm;"| Turn off the power supply.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Turn '''OFF''' the '''power supply'''.
  
 
|-
 
|-
Line 305: Line 301:
 
* Normal Contact
 
* Normal Contact
  
| style="border:1pt solid #000000;padding:0.176cm;"| In this tutorial, we learnt about working of
+
| style="border:1pt solid #000000;padding:0.176cm;"| In this tutorial, we learnt about working of '''Normal Contact'''.
 
+
* '''Normal Contact'''
+
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Slide 6: Evaluation
 
| style="border:1pt solid #000000;padding:0.176cm;"| Slide 6: Evaluation
  
Suppose that the input to Normal Contact is logic 0 with its state as logic 1
+
Suppose that the '''input''' to '''Normal Contact''' is '''logic 0''' with its state as '''logic 1'''.
  
What will be the state/output of the Normal Coil?
+
What will be the '''state/output''' of the '''Normal Coil'''?
 
| style="border:1pt solid #000000;padding:0.176cm;"| Here is a self assessment question for you:
 
| style="border:1pt solid #000000;padding:0.176cm;"| Here is a self assessment question for you:
  
Suppose that the input to '''Normal Contact''' is logic 0 with its state as logic 1.
+
Suppose that the input to '''Normal Contact''' is '''logic 0''' with its '''state''' as '''logic 1'''.
  
What will be the state of the '''Normal Coil''' ?
+
What will be the '''state''' of the '''Normal Coil''' ?
  
 
|-
 
|-
Line 324: Line 318:
  
 
The state of the Normal Coil will be 0
 
The state of the Normal Coil will be 0
| style="border:1pt solid #000000;padding:0.176cm;"| The answer is the state of the '''Normal Coil''' will be 0.
+
| style="border:1pt solid #000000;padding:0.176cm;"| The answer is the '''state''' of the '''Normal Coil''' will be 0.
  
 
|-
 
|-

Latest revision as of 18:26, 5 October 2020

Visual Cue
Narration
Slide 1: Welcome to the spoken tutorial on Normal Contact.
Slide 2: Learning Objectives
  • Normal Contact
In this tutorial, we will learn about the working of Normal Contact
Slide 3: System Requirements
  • Ubuntu Linux 18.04 OS
  • LDmicro
  • 'OpenPLC version 1 Mainboard
  • 24V, 2A SMPS
  • USBasp programmer
  • Traffic Light module
  • Switchboard module
To record this tutorial I am using:
  • Ubuntu Linux 18.04 operating system
  • LDmicro
  • OpenPLC version1 Mainboard
  • 24V, 2A SMPS
  • USBasp programmer
  • Traffic Light module and
  • Switchboard module
Slide 4: Pre-requisites
  • Program OpenPLC V1 Mainboard and
  • Interface OpenPLC modules with Mainboard.

If not, please refer to the relevant tutorials from Home | spoken-tutorial.org

  • To follow this tutorial, you should know how to
    • program OpenPLC V1 Mainboard and
    • interface OpenPLC modules with the Mainboard.
  • If not, please refer to the relevant tutorials in this series on this website.
Slide 5: Prerequisites - Hardware setup

hardware-prerequisite.jpg

Connect SMPS and USBasp to the Mainboard as shown in the picture.

Keep these connections throughout this tutorial.

Open LDmicro Now let us open LDmicro.
Click ‘Instructions -> Insert Coil’ Insert a Coil from Instructions.
Rename the coil as LED. Click the OK button. Rename the Coil as LED as shown.
Place the cursor to the left of the coil

Click ‘Instruction -> Insert Contact’

Place the cursor to the left of the Coil.

Insert a Contact from Instructions.

Double-click on the contact Double-click on the Contact.
A dialog box opens.
Highlight Negated We can find a check-box called ‘Negated’ just below the name box.

If it is checked then the Contact is a Negated Contact.

If it is unchecked then the Contact is a Normal Contact.

Normal Contact will pass the signal when its state is logic 1.

Thus, we have two types of Contacts.

Highlight Source column These Contacts have three source types which are Internal Relay, Input pin, and Output pin.
Highlight unchecked Negated box

Highlight Input pin

By default, Negated is unchecked with source as ‘Input pin’.

Input pin’ represents that Contact reads an input pin of the microcontroller.

Don't change them.

Keep the default settings as it is.

We will learn about other types of Contact and sources in the later tutorials.
Rename it as ‘switch’ >> Click OK button Rename the Contact as ‘switch’ and click the OK button.
Now we will check the working of this logic.
Click ‘Simulate -> Simulation mode’ >> Click ‘Simulate -> Real-time simulation’ Let us turn on the simulation mode.

For that, click Simulate and then on Simulation mode.

Next, start real-time simulation as shown.

Highlight state of Xswitch and YLED Observe the state of Xswitch and YLED in the I/O list.

Initially, the state of Xswitch and YLED are 0.

Double-click on Xswitch The input to the Xswitch is logic 1 as it is connected to positive rail.

Change the state of Xswitch to 1 by double-clicking on it.

Highlight state of YLED We can observe that the state of the YLED has changed to 1.

That means input to YLED is logic 1.

This in turn indicates that output of Xswitch is logic 1.

Thus, when the state of a Normal Contact is 1, it passes the signal through it.

Click Simulate -> Halt Simulation >> Click Simulate -> Simulation Mode Now, turn off the simulation mode.

For that, click Simulate and then on Halt Simulation.

Then click Simulate and Simulation Mode

Now let us compile the logic.

The detailed steps on how to compile and save the logic are explained in the earlier tutorials.

Click on Settings >> Click on Microcontroller >> Select AVR ATmega16 40-PDIP

Click on Settings >> Click on MCU parameters >> Change Crystal frequency to 16 >>Click OK button

Click on Settings and select microcontroller AVR ATmega16 40-PDIP.

Adjust its parameters as shown here.

Double-click on Xswitch in I/O list >> Select PC0 >> Click OK button Assign pin PA0 to the Coil YLED.
Double-click on YLED in I/O list >> Select PA0 >> Click OK button Then assign the pin PC0 to Xswitch.
Click on Compile >> Click on Compile as >> Go to Desktop/LDmicro folder >> rename it as ‘normalcontact.hex’ >> Click on Save.

Click OK button

Compile it as ‘normalcontact.hex’.
Click on File >> Click on Save As >> Go to Desktop/LDmicro folder>> Rename it as ‘normalcontact.ld’ >> Click on Save Then save the ladder diagram as ‘normalcontact.ld’.
Now we will see the working of this logic on hardware.
Connect Mainboard to PC using USBasp

laptop-usbasp.jpg

Connect the Mainboard to your laptop using USBasp.

Turn on the power supply.

Go to terminal >> type avrdude -c usbasp -p m16 -U flash:w:normalcontact.hex >> Press ENTER Open the Terminal by pressing CTRL+ALT+T keys simultaneously.

Go to the folder where you have saved the hex file.

Type the command as shown and upload this hex file to the Mainboard.

Remove the USBasp connection from the laptop. Turn off the power supply.

Remove the USBasp connection from the laptop.

This will prevent any hardware damage.

normalcontact-NO.png Let us see the connection details now.
normalcontact-NO.png Connect GND and 5V of the Switchboard to GND and 5V of the Mainboard respectively.

Then connect NO1 of the Switchboard to PC0 of the Mainboard.

normalcontact-NO.png Connect GND pin of the red LED of Traffic Light module to GND pin of the Mainboard.

Then connect the +5V pin of the red LED to PA0 pin of the Mainboard.

Make the connections as shown in the picture.

After making all the connections properly, turn on the power supply.
We can observe the red LED is OFF initially.

It is ON whenever the NO1 is pressed.

That is the corresponding switch LED and the red LED glows simultaneously.

normalcontact-NC.png Now connect PC0 to NC1 instead of NO1 as shown in the picture.
Let me show the live demo of the output.

We can observe that the red LED glows even before the switch is pressed.

And turns OFF whenever the NC1 is pressed.

That is the corresponding switch LED and the red LED glows alternately.

normalcontact-L.png Now connect PC0 to L1 as shown in the picture.
Initially, the red LED is off.

When L1 is pressed, both L1 switch LED and the red LED turns ON.

The LED will turn OFF when we press L1 one more time as these are latch switches.

Thus, the corresponding switch LED and the red LED glows simultaneously.

This shows how a Normal Contact behaves with different types of switches.
Turn OFF the power supply.
This brings us to the end of this tutorial.

Let us summarize

Slide 5: Summary
  • Normal Contact
In this tutorial, we learnt about working of Normal Contact.
Slide 6: Evaluation

Suppose that the input to Normal Contact is logic 0 with its state as logic 1.

What will be the state/output of the Normal Coil?

Here is a self assessment question for you:

Suppose that the input to Normal Contact is logic 0 with its state as logic 1.

What will be the state of the Normal Coil ?

Slide 7: Answer

The state of the Normal Coil will be 0

The answer is the state of the Normal Coil will be 0.
Slide 8:

About Spoken Tutorial project

The video at the following link summarises the Spoken Tutorial project.

Please download and watch it.

Slide 9:

Spoken Tutorial workshops

The Spoken Tutorial Project team:
  • conducts workshops using spoken tutorials and
  • gives certificates on passing online tests.

For more details, please write to us

Slide 10:

Forum for specific questions:

* Please post your timed queries in this forum.
Slide 11:

Forum for specific questions:

Do you have any general / technical questions on OpenPLC?

Please visit the FOSSEE forum and post your question.

Slide 12:

Acknowledgement

Spoken Tutorial Project is funded by MHRD, Government of India.
Slide 13:

Thank you slide

This tutorial has been contributed by FOSSEE and Spoken Tutorial Project, IIT Bombay.

And this is Harsha Priyanka from FOSSEE team, signing off.

Thanks for watching.

Contributors and Content Editors

Nancyvarkey, Priyanka.guntaka123