OpenPLC-version1-with-LDmicro/C3/RTO-Timer-Instruction/English

From Script | Spoken-Tutorial
Revision as of 20:08, 9 January 2021 by Nancyvarkey (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Visual Cue Narration
Slide 1: Welcome to the spoken tutorial on RTO timer instruction.
Slide 2: Learning Objectives
  • Retentive Delayed turn ON (RTO) timer
In this tutorial we’ll learn about working of Retentive Delayed Turn ON timer.
Slide 3: System Requirements* Ubuntu 18.04 OS
  • LDmicro
  • OpenPLC V1 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


  • To follow this tutorial, you should know the working of a Contact and a 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 the LDmicro Let us open LDmicro.
Insert ‘Instructions -> Insert Contact’ >>

Place the cursor to the right of the contact >>

Insert ‘Instructions -> Insert Coil’

Insert a Contact and a Coil as shown.
Double-click on contact >> Type switch in name box >> Click OK button Rename the Contact as ‘switch’.
Double click on the coil >> Rename it as ‘LED1’ >> Click OK button Then rename the Coil as ‘LED’.
Place the cursor to the right of the contact >> Click Instructions -> Timers -> Insert RTO We will now add a Retentive Delayed turn on timer to the right of Xswitch.

For that, place the cursor to the right of Xswitch.

Click on Instructions then Timers and then Insert RTO.

Double-click on Tnew >> Type RTO in the name box >> Type 5000 in the delay box >> Click the OK button Rename it as ‘RTO’ and enter the delay as 5s.

Note that the name will be prefixed by T by default.

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 Xswitch, YLED and TRTO in the IO list Initially the state of Xswitch, YLED and TRTO are 0.
Double click on Xswitch Double click on Xswitch to change the state to 1.

We can observe that the state TRTO is 20ms.

Double click on Xswitch Within 5s change the state of Xswitch back to 0.
Highlight the state of TRTO We can observe that the state of TRTO doesn’t go to 0.

Instead it shows the accumulated delay value just before Xswitch is 0.

Double click on Xswitch in the IO list

Highlight the state of TRTO

Change the state of Xswitch to 1.

We can observe that the timer starts.

The count starts from where it was before and not from 0.

Highlight the state of TRTO and YLED After 5s the state of YLED changes to 1 and TRTO to 4.990s
Double click on Xswitch Now change the state of Xswitch to 0.
Highlight the state of TRTO and YLED We can observe neither YLED nor TRTO changes its state.
This is because the RTO timer retains its state when Xswitch turns 0.
Thus it must be reset manually using the RESET instruction.


We will now see how to RESET.

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.

Click Edit -> Insert rung below Insert a new rung below.
Place the cursor near the new rung >> Click Instructions -> Insert Contact >> Place the cursor to the right of the contact >> Click Instructions -> Insert Reset Place a Contact and RESET instruction in the new rung as shown.
Double click on Xnew >> Type reset in the name box >> Click the OK button Rename the Contact as ‘reset’.
Double-click reset instruction Now double-click on RESET instruction.
Highlight the type column Under the column Type we can find two options Timer and Counter.

That means with this instruction we can reset only timer and counter variables.

By default, it is set to Timers.

Don’t change it.

Type RTO in the name box The name should be the name of the timer variable that needs to be reset.

So type RTO.

Click the OK button Click the OK button.
Click Simulate -> Simulation mode >>

Click Simulate -> Real-time simulation

Start real-time simulation as shown.
Double click on Xswitch Change the state of Xswitch to 1.
Highlight the state of TRTO After 5s the state of TRTO changes to 4.990s.

Change the state of Xswitch back to 0.

Double click on Xreset Now change the state of Xreset to 1.
Highlight the state of TRTO We can observe the timer TRTO resets.
Click Simulate -> Halt Simulation >> Click Simulate -> Simulation Mode Turn off the simulation mode as shown.
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 Xswitch in I/O list >> Select PC0 >> Click OK button

Double-click on Xreset 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 Xswitch and PC1 to Xreset.

Assign pin PA0 to YLED.

Click on Compile >> Click on Compile >> Go to Desktop/LDmicro folder >> Rename it as ‘timeron.hex’ >> Click on Save.

Click OK button

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

laptop-usbasp.jpg

Text box: Turn on the power supply

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:rto.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.

rto.png Let us see the connection details now.
rto.png which shows all the connections as per the narration 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 PA0 pin of the Mainboard.

rto.png which shows all the connections as per the narration Connect GND and 5V of Switchboard to GND and 5V of the Mainboard respectively.

Connect NO1 to PC0 of the Mainboard.

Then, connect NO2 to PC1 of the Mainboard.

Make the connections as shown in the picture.

Turn on the power supply. After making all the connections properly, turn on the power supply.
Point to red LED Initially the red LED will not glow.
Press the switch NO1 for 5 seconds Press the switch NO1.

Remember NO1 should be pressed for at least 5s for LED to turn ON.

Red LED glows. The red LED should turn ON 5s after the NO1 is pressed.
Release the switch NO1 Once we release the NO1 it doesn't turn off the red LED.
Release the switch NO2 For that we need to press the switch NO2.
Thus, an RTO timer retains the accumulated value even after the switch is released.
Turn off the power supply Turn off the power supply.
This brings us to the end of this tutorial.

Let us summarize.

Slide 5: Summary
  • Retentive Delayed turn ON (RTO) timer
In this tutorial we’ll learnt about working of Retentive Delayed turn ON timer
Slide 6: Evaluation

1. RES instruction is used with:

  • RTO timer
  • TON timer
  • TOFF timer
  • all of these

2. An RTO timer retains the present accumulated value when the rung goes false* True

  • False

3. What timer instruction would be best suited for the below process?

Track the time to make a product.

It needs to track even if the process is halted and then started again.* TON

  • TOFF
  • RTO
Here are some self assessment questions for you.

1. RES instruction is used with_______

The options are

  • RTO timer
  • TON timer
  • TOFF timer
  • all of these

2. An RTO timer retains the present accumulated value when the rung goes false

  • True or
  • False

3. What timer instruction would be best suited for the below process?

Track the time to make a product.

It needs to track even if the process is halted and then started again.

The options are:

  • TON
  • TOFF
  • RTO
Slide 7: Answers to Assignment
  1. RTO timer
  2. True
  3. RTO
Now let us look at the answers.

The answer to the first question is RTO timer

The answer to the second question is true.

The answer to the third question is RTO.

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, Nirmala Venkat