OpenPLC-version1-with-LDmicro/C2/SET-and-RESET-Coils/English

From Script | Spoken-Tutorial
Jump to: navigation, search
Visual Cue
Narration
Slide 1: Welcome to the spoken tutorial on SET & RESET Coils.
Slide 2:

Learning Objectives

  • SET-only Coil
  • RESET-only Coil
In this tutorial, we will learn about working of
  • SET-only Coil and
  • RESET-only Coil
Slide 3: System Requirements
  • Ubuntu 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
  • Switchboard module
Slide 4: Pre-requisites To follow this tutorial, you should know the
  • working of Normal Contact and Normal Coil
  • 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 Let us open LDmicro.
First we will learn about working of a SET-only Coil.
Click Instructions -> Insert Contact >> Place the cursor to the right of the Contact >> Click Instructions -> Insert Coil Insert a Contact and a Coil as shown.
Double-click on contact >> Type ON in name box >> Click OK button Rename the Contact as ‘ON’.
Double-click on coil >> Type LED in name box >> Select ‘SET-only’ option >> Click OK button Double-click on the Coil.

In the Type column, select ‘SET-only’ option.

Rename the Coil as ‘LED’.

Click the OK button.

We will now 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 the state of XON and YLED Observe the state of the Contacts and Coils in the I/O list.

Initially the state of XON and YLED are 0.

Double-click on XON >> Highlight the state of the ‘YLED’ Change the state of XON to 1.

The state of YLED should change to 1.

Double-click on XON >>

Highlight the state of the ‘YLED’

Change the state of XON again to 0.

We can observe the state of YLED is still 1.

Highlight the state of the ‘YLED’ That is, SET-only Coil sets its state to 1 when it identifies the 0 to 1 transition.

1 to 0 transition has no impact on 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 on Settings and select the microcontroller AVR ATmega16 40-PDIP.

Adjust its parameters as shown here.

Double-click on XON in I/O list >> Select PC0 >> Click OK button

Double-click on YLED in I/O list >> Select PA0 >> Click OK button

Assign pin PC0 to XON and PA0 to YLED.
Click on Compile >> Click on Compile >> Go to Desktop/LDmicro folder >> Rename it as ‘setonlycoil.hex’ >> Click on Save.

Click OK button

Compile the logic as ‘setonlycoil.hex’.
Click on File >> Click on Save >> Go to Desktop/LDmicro folder >> Rename it as ‘setonlycoil.ld’ >> Click on Save Then save the ladder diagram as ‘setonlycoil.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.

Open terminal >> Type cd Desktop/LDmicro >> Press ENTER >> type ‘avrdude -c usbasp -p m16 -U flash:w:setonlycoil.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 to upload the 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.

setonlycoil.png Let us see the connection details now.
setonlycoil.png


Connect GND pin of the red LED of Traffic Light module to GND of the Mainboard.

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

setonlycoil.png


Connect GND and 5V of Switchboard to GND and 5V of the Mainboard respectively.

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

Turn on the power After making all the connections properly, turn on the power supply.
Point to the output The red LED starts glowing when the NO1 is pressed.

It will be still glowing even after the switch is released.

Recall, this was not the case with Normal Coil which we learnt earlier.

Only narration That is once the LED is set, it will remain set irrespective of the input state.
Turn off the power Turn off the power supply.

Remove the connections made for this example.

Slide 5: How to turn off the LED
  • By turning off the power supply
  • By resetting the program in the microcontroller
  • By using a RESET-only coil


There are three ways to turn off the LED which is set.

First one is turning off the power supply.

Second, is to reset the program in the microcontroller using the Reset button.

And the third is with the help of a RESET-only Coil.

Now, we’ll see how that third option works.
Open LDmicro Switch back to LDmicro.
Instead of creating a new file, we will make changes in the previous file itself.
Click Instructions -> Insert Contact >> Place the cursor to the right of the contact >> Click ‘Instructions -> Insert Coil Insert a rung below.

Add a Contact and a Coil in the newly added rung as shown.

Double-click on Xnew >> Type ON in name box >> Click OK button Rename the Contact as ‘OFF’.
Double-click on Ynew >> Type LED in name box >> Select ‘RESET-only’ option >> Click OK button Double click on the newly added Coil.

In the Type column select ‘RESET-only’ Coil option.

Then rename it as ‘LED’.

Click the OK button.

Highlight ‘YLED’ in the I/O list Observe in the I/O list that both the Coils represent the same Coil.
We will now check the working of this logic.
Click ‘Simulate -> Simulation mode’ >>

Click ‘Simulate -> Real-time simulation’

Start real-time simulation as shown.
Highlight the state of XON and YLED Observe the state of the Contacts and Coils in the I/O list.

Initially the state of XON, XOFF and YLED are 0.

Double-click on ‘XON’ >> Highlight the state of the ‘YLED’ >> Double-click on ‘XON’ Change the state of the Contact XON to 1.

We can observe the state of YLED is now set to 1.

Change the state of XON back to 0.

Double-click on ‘XOFF’ >> Highlight the state of the ‘YLED’ >> Double-click on ‘XOFF’ Now, change the state of XOFF to 1.

We can observe the state of YLED changes to 0.

Change the state of ‘XOFF’ back to 0.

It doesn’t have any effect on the state of the ‘YLED’.

Highlight the state of the ‘YLED’ So, we can conclude that RESET-only coil resets to 0 upon 0 to 1 transition.

1 to 0 transition doesn’t have any effect on it.

Click Simulate -> Halt Simulation >> Click Simulate -> Simulation Mode Turn off the simulation mode.
Let us now compile the logic.
Highlight status bar at the bottom of the screen We can see that the microcontroller and its parameters are already set.
Double-click on XOFF in I/O list >> Select PC1 >> Click OK button Assign pin PC1 to XOFF as shown.
Click on Compile >> Click on Compile As >> Go to Desktop/LDmicro folder >> Rename it as ‘resetonlycoil.hex’ >> Click on Save.

Click OK button

Compile the logic as ‘resetonlycoil.hex’ using the ‘Compile As’ option.
Click on File >> Click on Save As >> Go to Desktop/LDmicro folder >> Rename it as ‘resetonlycoil.ld’ >> Click on Save Then save the ladder diagram as ‘resetonlycoil.ld’ using the ‘Save As’ option.
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.

Open terminal >> Type cd Desktop/LDmicro >> Press ENTER >> type ‘avrdude -c usbasp -p m16 -U flash:w:resetonlycoil.hex’ >> Press ENTER Switch back to the terminal.

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

Type the command as shown to upload the 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.

resetonlycoil.png Let us see the connection details now.
resetonlycoil.png Make the connections as in the SET-only Coil example.

Additionally, connect pin PC1 to NO2 of the Switchboard.

Turn on the power After making all the connections properly, turn on the power supply.
Point to the output The red LED starts glowing when the NO1 is pressed.

To turn off the LED we have to press the switch NO2.

This shows that SET-only and RESET-only Coils come in pairs.
Turn off the power Turn off the power supply.
This brings us to the end of this tutorial.

Let us summarize.

Slide 8: Summary
  • SET-only coil
  • RESET-only coil


In this tutorial, we learnt about working of
  • SET-only Coil and
  • RESET-only Coil
Slide : Assignment

Implement reset-dominant SR flip-flop.

As an assignment, implement reset-dominant SR flip-flop.

Refer to the given truth table.

That is, if both the Set and Reset conditions are 1, the output should reset.

Here ‘Memory’ means output of the previous PLC scan cycle is retained.

Slide 9: About Spoken Tutorial project The video at the following link summarises the Spoken Tutorial project.

Please download and watch it

Slide 10:

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 11:

Forum for specific questions:

Please post your timed queries in this forum.
Slide 12:

Forum for specific questions:

Do you have any general / technical questions on OpenPLC?

Please visit the FOSSEE forum and post your question.

Slide 13:

Acknowledgement

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

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