OpenPLC-version1-with-LDmicro/C3/OneShot-Instructions/English
|
|
Slide 1: | Welcome to the spoken tutorial on OneShot - Instructions. |
Slide 2: Learning Objectives
|
In this tutorial we’ll learn about
|
Slide 3: System Requirements
|
To record this tutorial I am using:
|
Slide 4: Pre-requisites
|
To follow this tutorial, you should know the working of
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. |
First we’ll see the working of an OSR instruction. | |
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
Double click on the coil >> Rename it as ‘LED1’ >> Click OK button |
Rename the Contact as ‘switch’ and rename the Coil as ‘LED’. |
Place the cursor to the right of the contact >> Click ‘Instructions -> Insert OSR instruction’ | Add an OSR instruction to the right of Xswitch. |
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. |
Observe the state of Xswitch and YLED in the I/O list.
Initially the state of both Xswitch and YLED are 0. | |
Double-click on ‘Xswitch’ in the I/O list | Change the state of ‘Xswitch’ to 1. |
Highlight rung | We can notice that YLED energises for a brief moment. |
This is because OSR generates a pulse on each rising edge of its input signal.
The pulse width is equal to one PLC scan cycle. | |
For a close observation, let us increase the PLC cycle time. | |
Click on Simulate -> Halt simulation >> Click on 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 on Settings -> MCU parameters >> Set cycle time to 5000 ms >> Click the OK button | Click on Settings and then on MCU parameters.
Change the ‘cycle time’ to ‘3000 ms’. |
Click Simulate -> Simulation mode >>
Click Simulate -> Real-time simulation |
Now again start real-time simulation. |
Double-click on ‘Xswitch’ | Change the state of Xswitch to 1. |
Highlight rung | We can observe that within 3s YLED will get energised.
Also it stays energised for about 3 seconds. |
Double-click on ‘Xswitch’ in the I/O list
Highlight state of YLED in the I/O list |
After that, change the state of Xswitch to 0.
We can see that the falling edge has no effect on the state of YLED. |
Click on Simulate -> Halt simulation >> Click on 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. Let the cycle time be 3000ms and change crystal frequency to 16 MHz. |
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.
Then assign pin PA0 to YLED. |
Click on Compile >> Click on Compile >> Go to Desktop/LDmicro folder >> Rename it as ‘osr.hex’ >> Click on Save.
Click OK button |
Compile the logic as ‘osr.hex’. |
Click on File >> Click on Save >> Go to Desktop/LDmicro folder >> Rename it as ‘osr.ld’ >> Click on Save | Save the ladder diagram as osr.ld as shown. |
We will now 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:osr.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. |
Text box: Turn off the power supply.
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. |
osr.png | Let us see the connection details now. |
osr.png | Connect GND pin of the red LED of Traffic Light module to GND of the Mainboard.
Then connect +5V pin of the red LED to PA0 pin of the Mainboard. |
osr.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. | |
Point to the output | Press NO1 for about 3 seconds.
After releasing the switch NO1, the red LED glows for about 3 seconds. |
The time for which the LED glows depends on PLC cycle time or scan cycle. | |
Turn off the power supply.
Remove the connections made for this example. | |
Now, we’ll look at the working of OSF instruction. | |
Switch back to LDmicro | Switch back to LDmicro. |
Instead of creating a new file, we will make changes in the previous file itself. | |
We will replace OSR with OSF instruction. | |
Select OSR >> Click ‘Edit -> Delete selected element’ >> Click on ‘instructions -> Insert OSF’ | For that, select OSR then click ‘Edit -> Delete selected element’.
Now, to the right of Xswitch insert OSF as shown. |
We will now check the working of this logic. | |
Click Simulate -> Simulation mode >>
Click Simulate -> Real-time simulation |
Start real-time simulation as shown. |
Initially the state of both Xswitch and YLED are 0 | |
Double click on Xswitch | Now, change the state of Xswitch to 1.
We can observe there is no change in the state of YLED. |
Change the state of Xswitch to 0.
We can observe that the state of YLED changes to 1 for about 3 seconds. | |
Highlight cycle time at the bottom of the screen | Remember that, we have changed the cycle time to 3s. |
Highlight the rung | Thus OSF generates the pulse on each falling edge of its input signal.
Note that rising edge doesn’t have any effect on it. |
Click on Simulate -> Halt simulation >> Click on Simulate -> Simulation Mode | Turn off the simulation mode as shown. |
Now let us compile the logic. | |
Highlight I/O list and status bar | We can observe that microcontroller and its parameters are already set.
Pin assignment is also already done. |
Click on Compile >> Click on Compile As >> Go to Desktop/LDmicro folder >> Rename it as ‘osf.hex’ >> Click on Save.
Click OK button |
Compile the logic as osf.hex using the ‘Compile As’ option. |
Click on File >> Click on Save As >> Go to Desktop/LDmicro folder >> Rename it as ‘osf.ld’ >> Click on Save | Save the ladder diagram as ‘osf.ld’ using the ‘Save As’ option. |
We will now 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:osf.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. |
osf.png | Let us see the connection details now. |
osf.png | Make the connections the same as in the OSR example. |
After making all the connections properly, turn on the power supply. | |
Press the switch NO1.
After the switch NO1 is released, we can observe that the red LED glows for about 3s. | |
Thus the LED glows for PLC scan cycle time, only after NO1 is released. | |
Turn off the power supply. | |
This brings us to the end of this tutorial.
Let us summarize | |
Slide 5: Summary
|
In this tutorial, we learnt about
|
Slide 6: Assignment
Draw a ladder diagram to detect both rising and falling edge of the input signal |
Try this assignment.
Draw a ladder diagram to detect both rising and falling edge of the input signal. |
Slide 7:
About Spoken Tutorial project |
The video at the following link summarises the Spoken Tutorial project.
Please download and watch it |
Slide 8:
Spoken Tutorial workshops |
The Spoken Tutorial Project team:
For more details, please write to us |
Slide 9:
Forum for specific questions: |
* Please post your timed queries in this forum. |
Slide 10:
Forum for specific questions: |
Do you have any general / technical questions on OpenPLC?
Please visit the FOSSEE forum and post your question. |
Slide 11: Acknowledgement | Spoken Tutorial Project is funded by MHRD, Government of India. |
Slide 12: 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. |