OpenPLC-version1-with-LDmicro/C3/TON-and-TOFF-Instructions/English
|
|
Slide 1: | Welcome to the spoken tutorial on TON & TOFF instructions |
Slide 2: Learning Objectives
|
In this tutorial we’ll learn about working of
|
Slide 3: System Requirements
|
To record this tutorial I am using:
|
Slide 4: Pre-requisites
|
|
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 from the launcher bar | Let us open LDmicro. |
Click on Instructions -> Timers | Click on Instructions and then on Timers.
In LDmicro, we have 3 different types of timers. They are Delayed turn ON, Delayed turn OFF and Retentive delayed turn ON. |
First, we will learn the working of a Delayed turn ON timer. | |
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 TON | We will now add a 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 TON. |
Double-click on Tnew | Double-click on the timer. |
In the name column, type ON | In the Name column, type ON.
Note that the name will be prefixed by T by default. |
In the delay box type 5000
Click the OK button |
In the Delay column we can enter the desired delay.
Note that the delay is in milliseconds. We’ll have a delay of 5s. So type 5000. 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 TON in the I/O list | Initially, the state of Xswitch, YLED and TON are 0. |
Double click on Xswitch | Double-click on Xswitch to change its state to 1. |
Highlight the state of TON and YLED | The state of TON will change to 20ms but the state of YLED is still 0. |
Highlight the state of TON and YLED | We can observe that the state of YLED will change to 1 after 5s.
The state of TON changes to 4.990s. |
The TON variable counts up from zero in the units of PLC scan cycle, which is 10ms. | |
Double click on Xswitch in the I/O list | Now, change the state of Xswitch to 0. |
Highlight the state of YLED | We can observe the state of YLED and TON changes to 0 immediately. |
That is, when TON is given logic 0, it outputs logic 0 immediately. | |
Double click on Xswitch >> Double click on Xswitch | Again change the state of Xswitch to 1.
Within 5s, change it back to 0. |
Highlight the state of TON | We can observe the state of TON goes back to 0. |
Thus, for TON to output logic 1, it should be given logic 1 for at least the delay time. | |
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 Xswitch 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 pin PA0 to YLED. |
Click on Compile >> Click on Compile >> rename it as ‘timeron.hex’ >> Go to Desktop/LDmicro folder >> Click on Save.
Click OK button |
Compile the logic as timeron.hex |
Click on File >> Click on Save >> Rename it as ‘timeron.ld’ >> Go to Desktop/LDmicro folder >> Click on Save | Save the ladder diagram as timeron.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:timeron.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. |
timeron.png | Let us see the connection details now. |
timeron.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 PA0 pin of the Mainboard. |
timeron.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. Make the connections as shown in the picture. |
After making all the connections properly, turn ON the power supply. | |
Initially the red LED will not glow. | |
Press the switch NO1.
Remember NO1 should be pressed for at least 5s for LED to turn ON. | |
The red LED should turn ON 5s after the NO1 is pressed. | |
You can use latched action switches to avoid long pressing of switches. | |
Red LED will go OFF immediately when you release the switch NO1. | |
Thus the LED will glow after the switch is pressed for delay time. | |
Turn OFF the power supply.
Remove the connections made for this example. | |
We will now learn about the working of Delayed turn off timer. | |
Slide 6: Delayed turn off timer
|
For a Delayed turn off timer when given logic 1, it outputs logic 1 immediately.
When given logic 0 it takes at least the delay time provided to output logic 0. Its variable counts up from zero in the units of PLC scan cycle. |
Switch back to LDmicro. | Switch back to LDmicro.
I’ll open the timeroff.ld which I have created and saved already. |
timeroff.ld logic on LDmicro interface | Here, I have replaced the Delayed turn on timer with Delayed turn off timer.
I have renamed it as TOFF and given delay as 5s. |
Hardware setup before connections | Then compiled the logic as ‘timeroff.hex’ and uploaded the same to the Mainboard. |
Slide 7:
Code file - timeroff.ld |
|
timeroff.png | The connections will be the same as in the Delayed turn ON timer example. |
Hardware setup after connections | We can see that the red LED turns ON immediately after NO1 is pressed. |
It will take 5s to turn OFF once you release the switch NO1. | |
Thus the LED goes off, after the delay time once the switch is released. | |
Note the difference between Delayed turn on and Delayed turn off timers. | |
This brings us to the end of this tutorial.
Let us summarize. | |
Slide 8: Summary
|
In this tutorial we learnt about working of
|
Slide 9: Assignment
|
|
Slide 10:
About Spoken Tutorial project |
The video at the following link summarises the Spoken Tutorial project.
Please download and watch it. |
Slide 11:
Spoken Tutorial workshops |
The Spoken Tutorial Project team:
For more details, please write to us |
Slide 12:
Forum for specific questions: |
|
Slide 13:
Forum for specific questions: |
Do you have any general / technical questions on OpenPLC?
Please visit the FOSSEE forum and post your question. |
Slide 14:
Acknowledgement |
Spoken Tutorial Project is funded by MHRD, Government of India. |
Slide 15:
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. |