Difference between revisions of "OpenPLC-version1-with-LDmicro/C3/TON-and-TOFF-Instructions/English"
(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...") |
Nancyvarkey (Talk | contribs) |
||
Line 16: | Line 16: | ||
| style="border:1pt solid #000000;padding:0.176cm;"| In this tutorial we’ll learn about working of | | style="border:1pt solid #000000;padding:0.176cm;"| In this tutorial we’ll learn about working of | ||
− | * '''Delayed turn ON''' | + | * '''Delayed turn ON timer''' and |
− | * '''Delayed turn OFF''' | + | * '''Delayed turn OFF timer''' |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Slide 3: System Requirements | | style="border:1pt solid #000000;padding:0.176cm;"| Slide 3: System Requirements | ||
Line 35: | Line 35: | ||
* '''OpenPLC version1 Mainboard''' | * '''OpenPLC version1 Mainboard''' | ||
* '''24V, 2A SMPS''' | * '''24V, 2A SMPS''' | ||
− | * '''USBasp''' | + | * '''USBasp programmer''' |
− | * '''Traffic Light''' | + | * '''Traffic Light module''' and |
− | * '''Switchboard''' | + | * '''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 | ||
Line 64: | Line 64: | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Click on '''Instructions''' and then on '''Timers'''. | | style="border:1pt solid #000000;padding:0.176cm;"| Click on '''Instructions''' and then on '''Timers'''. | ||
− | In LDmicro, we have 3 different types of timers. | + | In '''LDmicro''', we have 3 different types of '''timers'''. |
They are '''Delayed turn ON, Delayed turn OFF '''and''' Retentive delayed turn ON'''. | They are '''Delayed turn ON, Delayed turn OFF '''and''' Retentive delayed turn ON'''. | ||
Line 70: | Line 70: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| | | style="border:1pt solid #000000;padding:0.176cm;"| | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| First, we will learn the working of a '''Delayed | + | | style="border:1pt solid #000000;padding:0.176cm;"| First, we will learn the working of a '''Delayed turn ON timer'''. |
|- | |- | ||
Line 80: | Line 80: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Double-click on contact >> Type switch in name box >> Click OK button | | style="border:1pt solid #000000;padding:0.176cm;"| Double-click on contact >> Type switch in name box >> Click OK button | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Rename the Contact as '''‘switch’.''' | + | | style="border:1pt solid #000000;padding:0.176cm;"| Rename the '''Contact''' as '''‘switch’.''' |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Double click on the coil >> Rename it as ‘LED1’ >> Click OK button | | style="border:1pt solid #000000;padding:0.176cm;"| Double click on the coil >> Rename it as ‘LED1’ >> Click OK button | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Then rename the Coil as '''‘LED'.''' | + | | style="border:1pt solid #000000;padding:0.176cm;"| Then rename the '''Coil''' as '''‘LED'.''' |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Place the cursor to the right of the contact >> Click Instructions -> Timers -> Insert TON | | style="border:1pt solid #000000;padding:0.176cm;"| Place the cursor to the right of the contact >> Click Instructions -> Timers -> Insert TON | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| We will now add a '''Delayed turn on ''' | + | | style="border:1pt solid #000000;padding:0.176cm;"| We will now add a '''Delayed turn on timer''' to the right of '''Xswitch'''. |
For that, place the cursor to the right of '''Xswitch'''. | For that, place the cursor to the right of '''Xswitch'''. | ||
Line 96: | Line 96: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Double-click on Tnew | | style="border:1pt solid #000000;padding:0.176cm;"| Double-click on Tnew | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Double-click on the timer. | + | | style="border:1pt solid #000000;padding:0.176cm;"| Double-click on the '''timer'''. |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| In the name column, type ON | | style="border:1pt solid #000000;padding:0.176cm;"| In the name column, type ON | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| In the | + | | style="border:1pt solid #000000;padding:0.176cm;"| In the '''Name''' column, type '''ON'''. |
− | Note that the name will be prefixed by T by default. | + | Note that the name will be prefixed by '''T''' by default. |
|- | |- | ||
Line 108: | Line 108: | ||
Click the OK button | Click the OK button | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| In the ''' | + | | style="border:1pt solid #000000;padding:0.176cm;"| In the '''Delay''' column we can enter the desired delay. |
Note that the delay is in milliseconds. | Note that the delay is in milliseconds. | ||
Line 116: | Line 116: | ||
So type 5000. | So type 5000. | ||
− | Click the OK button. | + | 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;"| We will now check the working of this logic. | + | | style="border:1pt solid #000000;padding:0.176cm;"| We will now 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 | + | | 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. |
|- | |- | ||
Line 150: | Line 150: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| | | style="border:1pt solid #000000;padding:0.176cm;"| | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| The '''TON''' | + | | style="border:1pt solid #000000;padding:0.176cm;"| The '''TON variable''' counts up from zero in the units of '''PLC scan cycle''', which is 10ms. |
|- | |- | ||
Line 162: | Line 162: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| | | style="border:1pt solid #000000;padding:0.176cm;"| | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| That is, when '''TON''' is given logic 0 it outputs logic 0 immediately. | + | | style="border:1pt solid #000000;padding:0.176cm;"| That is, when '''TON''' is given '''logic''' 0, it outputs '''logic''' 0 immediately. |
|- | |- | ||
Line 176: | Line 176: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| | | style="border:1pt solid #000000;padding:0.176cm;"| | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Thus, for TON to output logic 1 it should be given logic 1 for at least the delay time. | + | | style="border:1pt solid #000000;padding:0.176cm;"| Thus, for '''TON''' to output '''logic''' 1, it should be given '''logic''' 1 for at least the delay time. |
|- | |- | ||
| 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 | + | | 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 188: | Line 188: | ||
|- | |- | ||
| 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 196: | Line 196: | ||
Click on Settings >> Click on MCU parameters >> Change Crystal frequency to 16 | Click on Settings >> Click on MCU parameters >> Change Crystal frequency to 16 | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Click on '''Settings''' and select the | + | | style="border:1pt solid #000000;padding:0.176cm;"| Click on '''Settings''' and select the '''microcontroller AVR ATmega16 40-PDIP.''' |
− | Adjust its parameters as shown here. | + | Adjust its '''parameters''' as shown here. |
|- | |- | ||
Line 204: | Line 204: | ||
Double-click on YLED in I/O list >> Select PA0 >> Click OK button | Double-click on YLED in I/O list >> Select PA0 >> Click OK button | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Assign | + | | style="border:1pt solid #000000;padding:0.176cm;"| Assign '''pin PC0''' to '''Xswitch''' and '''pin PA0''' to '''YLED'''. |
|- | |- | ||
Line 210: | Line 210: | ||
Click OK button | Click OK button | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Compile the logic as '''timeron.hex''' | + | | style="border:1pt solid #000000;padding:0.176cm;"| '''Compile''' the '''logic''' as '''timeron.hex''' |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Click on File >> Click on Save >> Rename it as ‘timeron.ld’ >> Go to Desktop/LDmicro folder >> Click on Save | | style="border:1pt solid #000000;padding:0.176cm;"| Click on File >> Click on Save >> Rename it as ‘timeron.ld’ >> Go to Desktop/LDmicro folder >> Click on Save | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Save the ladder diagram as '''timeron.ld.''' | + | | style="border:1pt solid #000000;padding:0.176cm;"| Save the '''ladder diagram''' as '''timeron.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. |
|- | |- | ||
Line 227: | Line 227: | ||
| 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 | + | Turn '''ON''' the '''power supply'''. |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Open terminal >> Type cd Desktop/LDmicro >> Press ENTER >> type ‘'''avrdude -c usbasp -p m16 -U flash:w:timeron.hex’ '''>> Press ENTER | | style="border:1pt solid #000000;padding:0.176cm;"| Open terminal >> Type cd Desktop/LDmicro >> Press ENTER >> type ‘'''avrdude -c usbasp -p m16 -U flash:w:timeron.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 to upload the hex file to the '''Mainboard'''. | + | Type the '''command''' as shown to upload the '''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 | + | | 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. | ||
Line 251: | Line 251: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| timeron.png | | style="border:1pt solid #000000;padding:0.176cm;"| timeron.png | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Connect GND''' pin''' of the red LED of '''Traffic Light module''' to GND of the '''Mainboard'''. | + | | style="border:1pt solid #000000;padding:0.176cm;"| Connect GND''' pin''' of the red '''LED''' of '''Traffic Light module''' to '''GND''' of the '''Mainboard'''. |
− | Then connect the '''+5V''' | + | Then connect the '''+5V pin''' of the red '''LED''' to '''PA0 pin''' of the '''Mainboard'''. |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| timeron.png | | style="border:1pt solid #000000;padding:0.176cm;"| timeron.png | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Connect GND and 5V of '''switchboard''' to GND and 5V of the '''Mainboard''' respectively. | + | | style="border:1pt solid #000000;padding:0.176cm;"| 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'''. | Then connect '''NO1''' of the '''Switchboard''' to '''PC0''' of the '''Mainboard'''. | ||
Line 265: | Line 265: | ||
|- | |- | ||
| 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 | + | | 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;"| Initially the red LED will not glow. | + | | style="border:1pt solid #000000;padding:0.176cm;"| Initially the red '''LED''' will not glow. |
|- | |- | ||
Line 275: | Line 275: | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Press the switch '''NO1'''. | | style="border:1pt solid #000000;padding:0.176cm;"| Press the switch '''NO1'''. | ||
− | Remember '''NO1''' should be pressed for at least 5s for LED to turn ON. | + | Remember '''NO1''' should be pressed for at least 5s for '''LED''' to turn '''ON'''. |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| | | style="border:1pt solid #000000;padding:0.176cm;"| | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| The red LED should turn ON 5s after the '''NO1''' is pressed. | + | | style="border:1pt solid #000000;padding:0.176cm;"| The red '''LED''' should turn '''ON''' 5s after the '''NO1''' is pressed. |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| | | style="border:1pt solid #000000;padding:0.176cm;"| | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| You can use latched action switches to avoid long pressing of switches. | + | | style="border:1pt solid #000000;padding:0.176cm;"| You can use '''latched action switches''' to avoid long pressing 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;"| Red LED will go | + | | style="border:1pt solid #000000;padding:0.176cm;"| Red '''LED''' will go '''OFF''' immediately when you release the '''switch NO1'''. |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| | | style="border:1pt solid #000000;padding:0.176cm;"| | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Thus the LED will glow after the switch is pressed for delay time. | + | | style="border:1pt solid #000000;padding:0.176cm;"| Thus the '''LED''' will glow after the '''switch''' is pressed for delay time. |
|- | |- | ||
| 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 | + | | style="border:1pt solid #000000;padding:0.176cm;"| Turn '''OFF''' the '''power supply'''. |
Remove the connections made for this example. | Remove the connections made for this example. | ||
Line 301: | Line 301: | ||
|- | |- | ||
| 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 now learn about the working of '''Delayed turn off ''' | + | | style="border:1pt solid #000000;padding:0.176cm;"| We will now learn about the working of '''Delayed turn off timer'''. |
|- | |- | ||
Line 311: | Line 311: | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| For a | + | | style="border:1pt solid #000000;padding:0.176cm;"| 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. | + | 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. | + | Its '''variable''' counts up from zero in the units of '''PLC scan cycle'''. |
|- | |- | ||
Line 325: | Line 325: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| timeroff.ld logic on LDmicro interface | | style="border:1pt solid #000000;padding:0.176cm;"| timeroff.ld logic on LDmicro interface | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Here, I have replaced the '''Delayed turn on ''' | + | | style="border:1pt solid #000000;padding:0.176cm;"| 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. | + | I have renamed it as '''TOFF '''and given '''delay''' as 5s. |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Hardware setup before connections | | style="border:1pt solid #000000;padding:0.176cm;"| Hardware setup before connections | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Then compiled the logic as''' ‘timeroff.hex’ '''and uploaded the same to the '''Mainboard'''. | + | | style="border:1pt solid #000000;padding:0.176cm;"| Then '''compiled''' the '''logic''' as''' ‘timeroff.hex’ '''and uploaded the same to the '''Mainboard'''. |
|- | |- | ||
Line 348: | Line 348: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Hardware setup after connections | | style="border:1pt solid #000000;padding:0.176cm;"| Hardware setup after connections | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| We can see that the red LED turns ON immediately after '''NO1''' is pressed. | + | | style="border:1pt solid #000000;padding:0.176cm;"| We can see that the red '''LED''' turns '''ON''' immediately after '''NO1''' is pressed. |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| | | style="border:1pt solid #000000;padding:0.176cm;"| | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| It will take 5s to turn OFF once you release the | + | | style="border:1pt solid #000000;padding:0.176cm;"| It will take 5s to turn '''OFF''' once you release the '''switch NO1'''. |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| | | style="border:1pt solid #000000;padding:0.176cm;"| | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Thus the LED goes off, after the delay time once the switch is released. | + | | style="border:1pt solid #000000;padding:0.176cm;"| Thus the '''LED''' goes '''off''', after the delay time once the '''switch''' is released. |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| | | style="border:1pt solid #000000;padding:0.176cm;"| | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Note the difference between Delayed turn on and Delayed turn off timers. | + | | style="border:1pt solid #000000;padding:0.176cm;"| Note the difference between '''Delayed turn on''' and '''Delayed turn off timers'''. |
|- | |- | ||
Line 378: | Line 378: | ||
* '''Delayed turn ON timer''' and | * '''Delayed turn ON timer''' and | ||
− | * '''Delayed turn OFF''' | + | * '''Delayed turn OFF timer''' |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Slide 9: Assignment | | style="border:1pt solid #000000;padding:0.176cm;"| Slide 9: Assignment | ||
− | * Draw a ladder diagram to blink an LED. | + | * Draw a '''ladder diagram''' to blink an '''LED'''. |
− | * Hint: Use both | + | * Hint: Use both '''Delayed turn ON''' and '''Delayed turn OFF timers'''. |
| style="border:1pt solid #000000;padding:0.176cm;"| | | style="border:1pt solid #000000;padding:0.176cm;"| | ||
− | * As an assignment, draw a ladder diagram to blink an LED. | + | * As an assignment, draw a '''ladder diagram''' to blink an '''LED'''. |
− | * Hint: Use both | + | * Hint: Use both '''Delayed turn ON''' and '''Delayed turn OFF timers'''. |
|- | |- |
Revision as of 13:21, 3 December 2020
|
|
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. |