OpenPLC-version1-with-LDmicro/C2/Internal-Relay-and-Output-pin/English
|
|
Slide 1: | Welcome to the spoken tutorial on Internal Relay and Output pin |
Slide 2: Learning Objectives
Types of sources available for Contacts/Coils
|
In this tutorial we will learn about,
|
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. |
First we will understand the working of an Internal Relay. | |
Slide 5: Internal Relay
|
|
Open 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 from Instructions.
Then to the right of it, insert a Coil as shown. |
Double click on the Contact >> Rename the contact as ‘switch’ >> Click OK button | Rename the Contact as ‘switch’. |
Double click on the coil >> Select Internal Relay >> Rename it as ‘relay’ >> Click OK button | Double-click on the Coil.
In the ‘Source’ column select ‘Internal Relay’. Then rename it as ‘relay’. Click the OK button. |
Highlight the coil | We can see that ‘R’ is prefixed instead of ‘Y’ in the name which indicates relay. |
Click ‘Edit -> Insert Rung After’ | Let us add a new rung after the current rung. |
Insert ‘Instructions -> Insert Contact’ >> Place the cursor to the right of the contact >> Insert ‘Instructions -> Insert Coil’ | Insert a Contact and a Coil in the newly added rung as shown. |
Double click on the contact >> Select Internal Relay >> Rename the contact as ‘switch’ >> Click OK button | Double click on the Contact.
In the ‘Source’ column select ‘Internal Relay’. Then rename it as ‘relay’. Click the OK button. |
Highlight ‘Rrelay’ in the IO list | In the I/O list we can observe there is only one ‘Rrelay’.
Both Contact and Coil are represented by the same internal relay. |
Double click on the coil >> Rename it as ‘LED’ >> Click OK button | Now rename the Coil as ‘LED’ as shown. |
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, Rrelay and YLED in the I/O list | Initially the state of Xswitch, YLED and Rrelay are 0. |
Double-click on Xswitch | Change the state of Xswitch to 1. |
Highlight the state of Rrelay and YLED | We can observe that the state of ‘YLED’ and ‘Rrelay' have changed to 1. |
Double-click on Rrelay
Highlight ‘Rrelay’ in the I/O list |
Now double click on Rrelay.
We can notice that we are not able to change the state of Rrelay. This is because the Internal relay operates in the internal logic of the PLC. It does not operate on the I/O pins directly. |
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 PC0 pin to ‘Xswitch’ and PA0 to ‘YLED’. |
Double-click on Rrelay in the I/O list
Highlight the text in the dialog box >> Click the OK button |
Double-click on Rrelay in the I/O list.
A dialog box opens. It says that ‘Can only assign pin number to input/output pins’. Recall that Internal relay represents a variable inside PLC memory. Click on the OK button. |
Thus working of this example is similar to the ‘Normal Contact’ example. | |
So we will skip the hardware part. | |
Click on File >> Click on Save >> Go to Desktop/LDmicro folder >> Rename it as ‘internalrelay.ld’ >> Click on Save | Save the file as ‘internalrelay.ld’ as shown. |
We will now learn about the source type ‘Output pin’ of the contact. | |
Click File >> Click New | Open a new file in 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 the Contact >> Rename the contact as ‘switch’ >> 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 ‘LED1’. |
Click Edit -> Insert Rung After >> Place the cursor in the newly added rung >> Click ‘Instructions -> Insert Contact’ >> Place the cursor to the right of the contact >> Insert ‘Instructions -> Insert Coil’ | Insert a rung below.
Again, insert a Contact and a Coil in the newly added rung. |
Double click on the contact >> Select Output pin >> Rename the contact as ‘LED1’ >> Click OK button | Double click on the Contact.
In the ‘Source’ column select ‘Output pin’. Then rename it as ‘LED1’. Click the OK button. |
Highlight the name of the contact viz. YLED1 | We can observe the name of the Contact is prefixed by Y and not X. |
Double click on the coil >> Check the ‘Negated’ box >> Click OK button | Double-click on the Coil.
Check the ‘Negated’ box and rename it as LED2. Click the OK button. |
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 states of all the instructions | Initially the state of Xswitch and YLED1 are 0 and YLED2 is 1. |
Double-click on Xswitch
Highlight the state of YLED1 and YLED2 |
Now change the state of Xswitch to 1.
We can observe that the state of the YLED1 changes to 1 and YLED2 to 0. |
That is the output of YLED1 is given as input to YLED2. | |
Click Simulate -> Halt Simulation
>> Click Simulate -> Simulation Mode |
Turn off the simulation mode as shown. |
Let us compile the logic. | |
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. |
Highlight Xswitch pin number
Double-click on YLED1 in I/O list >> Select PA0 >> Click OK button Double-click on YLED2 in I/O list >> Select PA1 >> Click OK button |
We can observe that Xswitch has already been assigned pin PC0.
Now, assign pin PA0 to ‘YLED1’ and PA1 to ‘YLED2’. |
Click on Compile >> Click on Compile >> rename it as ‘output-pin.hex’ >> Go to Desktop/LDmicro folder >> Click on Save.
Click OK button |
Compile the logic as ‘outputpin.hex’ as shown. |
Click on File >> Click on Save >> Rename it as ‘outputpin.ld’ >> Go to Desktop/LDmicro folder >> Click on Save | Then save the ladder diagram as ‘outputpin.ld’ as shown. |
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:outputpin.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. |
outputpin.png | Let us see the connection details now. |
outputpin.png | Connect GND and 5V of Switchboard to GND and 5V of the Mainboard respectively.
Then connect NO1 of the Switchboard to PC0 of Mainboard. |
outputpin.png
Point to the connections |
Beside the yellow LED of Traffic Light module, you will see a +5V pin.
Connect this +5V pin to 5V of the Mainboard. Connect the ‘EN' pin to the GND of the Mainboard. Connect the ‘L’ pin to PA0 of the Mainboard which represents YLED1. Connect the ‘Ri’ pin to PA1 of the Mainboard which represents YLED2. Make the connections as shown in the picture. |
Switch on the power | After making all the connections properly turn on the power supply. |
Point to green LED | Initially the left green LED will be glowing.
Recall that bottom LED connections should be given logic low for an LED to glow. |
Point the output | Now press the switch NO1.
The right green LED starts glowing and the left one goes off at the same time. |
Thus the output of the left green LED acts as input to the right green LED. | |
Switch off the power | Turn off the power supply. |
This brings us to the end of this tutorial.
Let us summarize | |
Slide 6: Summary
|
In this tutorial, we learnt about different source types such as
|
Slide 7: Assignment
Draw a ladder logic to latch an LED Hint:
|
As an assignment, draw a ladder logic to latch an LED.
Hint:
|
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:
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. |