Difference between revisions of "OpenPLC-version1-with-LDmicro/C2/Internal-Relay-and-Output-pin/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(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...")
 
 
Line 18: Line 18:
 
| style="border:1pt solid #000000;padding:0.176cm;"| In this tutorial we will learn about,
 
| style="border:1pt solid #000000;padding:0.176cm;"| In this tutorial we will learn about,
  
* Types of sources available for Contacts/Coils.
+
* Types of sources available for '''Contacts/Coils'''.
 
* (i.e) '''Internal Relay''' and '''Output pin.'''
 
* (i.e) '''Internal Relay''' and '''Output pin.'''
  
Line 39: Line 39:
 
* '''24V, 2A SMPS'''
 
* '''24V, 2A SMPS'''
 
* '''USBasp''' programmer
 
* '''USBasp''' programmer
* '''Traffic Light''' module and
+
* '''Traffic Light module''' and
* '''Switchboard''' module
+
* '''Switchboard module'''
  
 
|-
 
|-
Line 48: Line 48:
 
* Negated Contact and Coil
 
* Negated Contact and Coil
  
| style="border:1pt solid #000000;padding:0.176cm;"| * To follow this tutorial, you should know the working of  
+
| style="border:1pt solid #000000;padding:0.176cm;"|  
 +
* To follow this tutorial, you should know the working of  
  
 
# '''Normal Contact''' and '''Coil'''
 
# '''Normal Contact''' and '''Coil'''
Line 73: Line 74:
 
* It does not affect the external I/O’s of the PLC
 
* It does not affect the external I/O’s of the PLC
  
| style="border:1pt solid #000000;padding:0.176cm;"| * Internal relay can be thought of as a variable inside a '''PLC''' memory bit.
+
| style="border:1pt solid #000000;padding:0.176cm;"|  
* It does not affect the external I/O’s of the '''PLC'''.
+
* '''Internal relay''' can be thought of as a '''variable''' inside a '''PLC memory bit'''.
 +
* It does not affect the external '''I/O'''s of the '''PLC'''.
  
 
|-
 
|-
Line 86: Line 88:
 
| style="border:1pt solid #000000;padding:0.176cm;"| Insert a '''Contact '''from '''Instructions.'''
 
| style="border:1pt solid #000000;padding:0.176cm;"| Insert a '''Contact '''from '''Instructions.'''
  
Then to the right of it insert a '''Coil''' as shown.
+
Then to the right of it, insert a '''Coil''' as shown.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double click on the Contact >> Rename the contact as ‘switch’ >> Click OK button
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double click on the Contact >> Rename the contact as ‘switch’ >> 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 >> Select Internal Relay >> Rename it as ‘relay’ >> Click OK button
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double click on the coil >> Select Internal Relay >> Rename it as ‘relay’ >> Click OK button
| style="border:1pt solid #000000;padding:0.176cm;"| Double-click on the Coil.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Double-click on the '''Coil'''.
  
 
In the ‘'''Source'''’ column select ‘'''Internal Relay'''’.
 
In the ‘'''Source'''’ column select ‘'''Internal Relay'''’.
Line 104: Line 106:
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight the coil
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight the coil
| style="border:1pt solid #000000;padding:0.176cm;"| We can see that '''‘R’''' is prefixed instead of '''‘Y’''' in the name which indicates relay.
+
| style="border:1pt solid #000000;padding:0.176cm;"| We can see that '''‘R’''' is prefixed instead of '''‘Y’''' in the name which indicates '''relay'''.
  
 
|-
 
|-
Line 112: Line 114:
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Insert ‘Instructions -> Insert Contact’ >> Place the cursor to the right of the contact >> Insert ‘Instructions -> Insert Coil’
 
| style="border:1pt solid #000000;padding:0.176cm;"| Insert ‘Instructions -> Insert Contact’ >> Place the cursor to the right of the contact >> Insert ‘Instructions -> Insert Coil’
| style="border:1pt solid #000000;padding:0.176cm;"| Insert a Contact and a Coil in the newly added rung as shown.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Insert a '''Contact''' and a '''Coil''' in the newly added rung as shown.
  
 
|-
 
|-
Line 118: Line 120:
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double click on the '''Contact'''.
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double click on the '''Contact'''.
  
In the '''‘Source’''' column select '''‘Internal''' '''Relay’'''.
+
In the '''‘Source’''' column select '''‘Internal Relay’'''.
  
 
Then rename it as '''‘relay’'''.
 
Then rename it as '''‘relay’'''.
Line 128: Line 130:
 
| style="border:1pt solid #000000;padding:0.176cm;"| In the '''I/O''' list we can observe there is only one '''‘Rrelay’'''.
 
| style="border:1pt solid #000000;padding:0.176cm;"| In the '''I/O''' list we can observe there is only one '''‘Rrelay’'''.
  
Both Contact and Coil are represented by the same '''internal''' '''relay'''.
+
Both '''Contact''' and '''Coil''' are represented by the same '''internal relay'''.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double click on the coil >> Rename it as ‘LED’ >> Click OK button
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double click on the coil >> Rename it as ‘LED’ >> Click OK button
| style="border:1pt solid #000000;padding:0.176cm;"| Now rename the Coil as ‘'''LED’''' as shown.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Now rename the '''Coil''' as ‘'''LED’''' as shown.
  
 
|-
 
|-
 
| 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 on the simulation mode.
+
| 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.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight the state of Xswitch, Rrelay and YLED in the I/O list
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight the state of Xswitch, Rrelay and YLED in the I/O list
| style="border:1pt solid #000000;padding:0.176cm;"| Initially the state of '''Xswitch''', '''YLED '''and''' Rrelay''' are 0.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Initially the state of '''Xswitch, YLED '''and''' Rrelay''' are 0.
  
 
|-
 
|-
Line 166: Line 168:
 
We can notice that we are not able to change the state of '''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'''.
+
This is because the '''Internal relay''' operates in the internal '''logic''' of the '''PLC'''.
  
It does not operate on the '''I/O''' pins directly.
+
It does not operate on the '''I/O pins''' directly.
  
 
|-
 
|-
 
| 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 off the simulation mode.
+
| 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 180: Line 182:
 
|-
 
|-
 
| 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 190: Line 192:
  
 
>> Change Crystal frequency to 16
 
>> Change Crystal frequency to 16
| style="border:1pt solid #000000;padding:0.176cm;"| Click on '''Settings''' and select the microcontroller '''AVR ATmega16 40-PDIP.'''  
+
| 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 198: Line 200:
  
 
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 '''PC0''' '''pin''' to '''‘Xswitch’''' and '''PA0''' to '''‘YLED’'''.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Assign '''PC0 pin''' to '''‘Xswitch’''' and '''PA0''' to '''‘YLED’'''.
  
 
|-
 
|-
Line 206: Line 208:
  
 
>> Click the OK button
 
>> Click the OK button
| style="border:1pt solid #000000;padding:0.176cm;"| Double-click on '''Rrelay''' in the I/O list.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Double-click on '''Rrelay''' in the '''I/O''' list.
  
 
A dialog box opens.
 
A dialog box opens.
Line 212: Line 214:
 
It says that '''‘Can only assign pin number to input/output pins’'''.
 
It says that '''‘Can only assign pin number to input/output pins’'''.
  
Recall that, Internal relay represents a variable inside PLC memory.  
+
Recall that '''Internal relay''' represents a '''variable''' inside '''PLC memory'''.  
  
Click on the OK button.
+
Click on 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;"| Thus working of this example is similar to the '''‘Normal Contact’''' example'''.'''
+
| style="border:1pt solid #000000;padding:0.176cm;"| Thus working of this example is similar to the '''‘Normal Contact’''' example.
  
 
|-
 
|-
Line 230: Line 232:
 
|-
 
|-
 
| 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 source type '''‘Output''' '''pin’''' of the contact.
+
| style="border:1pt solid #000000;padding:0.176cm;"| We will now learn about the source type '''‘Output''' '''pin’''' of the '''contact'''.
  
 
|-
 
|-
Line 242: Line 244:
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double click on the Contact >> Rename the contact as ‘switch’ >> Click OK button
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double click on the Contact >> Rename the contact as ‘switch’ >> 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 ‘'''LED1'''’.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Then rename the '''Coil''' as ‘'''LED1'''’.
  
 
|-
 
|-
Line 258: Line 260:
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double click on the '''Contact'''.
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double click on the '''Contact'''.
  
In the '''‘Source’''' column select '''‘Output''' '''pin’'''.
+
In the '''‘Source’''' column select '''‘Output pin’'''.
  
 
Then rename it as '''‘LED1’'''.
 
Then rename it as '''‘LED1’'''.
  
Click the OK button.
+
Click the '''OK''' button.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight the name of the contact viz. YLED1
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight the name of the contact viz. YLED1
| style="border:1pt solid #000000;padding:0.176cm;"| We can observe the name of the Contact is prefixed by '''Y '''and not''' X.'''
+
| style="border:1pt solid #000000;padding:0.176cm;"| We can observe the name of the '''Contact''' is prefixed by '''Y '''and not''' X.'''
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double click on the coil >> Check the ‘Negated’ box >> Click OK button
 
| style="border:1pt solid #000000;padding:0.176cm;"| Double click on the coil >> Check the ‘Negated’ box >> Click OK button
| style="border:1pt solid #000000;padding:0.176cm;"| Double-click on the Coil.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Double-click on the '''Coil'''.
  
 
Check the '''‘Negated’''' box and rename it as '''LED2'''.
 
Check the '''‘Negated’''' box and rename it as '''LED2'''.
  
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;"| Start real-time simulation as shown.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Start '''real-time simulation''' as shown.
  
 
|-
 
|-
Line 304: Line 306:
  
 
>> Click Simulate -> Simulation Mode
 
>> Click Simulate -> Simulation Mode
| style="border:1pt solid #000000;padding:0.176cm;"| Turn off the simulation mode as shown.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Turn '''off''' the '''simulation mode''' as shown.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
| style="border:1pt solid #000000;padding:0.176cm;"| Let us compile the logic.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Let us '''compile''' the '''logic'''.
  
 
|-
 
|-
Line 316: Line 318:
  
 
>> Click on MCU parameters >> Change Crystal frequency to 16
 
>> Click on MCU parameters >> Change Crystal frequency to 16
| style="border:1pt solid #000000;padding:0.176cm;"| Click on '''Settings''' and select the microcontroller '''AVR ATmega16 40-PDIP.'''  
+
| 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 326: Line 328:
  
 
Double-click on YLED2 in I/O list >> Select PA1 >> Click OK button
 
Double-click on YLED2 in I/O list >> Select PA1 >> Click OK button
| style="border:1pt solid #000000;padding:0.176cm;"| We can observe that Xswitch has already been assigned pin PC0
+
| style="border:1pt solid #000000;padding:0.176cm;"| We can observe that '''Xswitch''' has already been assigned '''pin PC0'''.
  
Now, assign pin '''PA0''' to '''‘YLED1’''' and '''PA1''' to '''‘YLED2’'''.
+
Now, assign '''pin PA0''' to '''‘YLED1’''' and '''PA1''' to '''‘YLED2’'''.
  
 
|-
 
|-
Line 334: Line 336:
  
 
Click OK button
 
Click OK button
| style="border:1pt solid #000000;padding:0.176cm;"| Compile the logic as '''‘outputpin.hex’''' as shown.
+
| style="border:1pt solid #000000;padding:0.176cm;"| '''Compile''' the '''logic''' as '''‘outputpin.hex’''' as shown.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Click on File >> Click on Save >> Rename it as ‘outputpin.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 ‘outputpin.ld’ >> Go to Desktop/LDmicro folder >> Click on Save
| style="border:1pt solid #000000;padding:0.176cm;"| Then save the ladder diagram as '''‘outputpin.ld’''' as shown.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Then save the '''ladder diagram''' as '''‘outputpin.ld’''' as shown.
  
 
|-
 
|-
 
| 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 351: Line 353:
 
| 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 on the power supply.
+
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:outputpin.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:outputpin.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 off the power supply.
+
| 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 383: Line 385:
  
 
Point to the connections
 
Point to the connections
| style="border:1pt solid #000000;padding:0.176cm;"| Beside the yellow LED of '''Traffic''' '''Light''' module, you will see a +5V pin.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Beside the yellow '''LED''' of '''Traffic Light module''', you will see a '''+5V pin'''.
  
Connect this +5V pin to 5V of the '''Mainboard'''.
+
Connect this '''+5V pin''' to '''5V''' of the '''Mainboard'''.
  
Connect the '''‘EN’''' pin to the GND 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 '''‘L’ pin''' to '''PA0''' of the '''Mainboard''' which represents '''YLED1'''.
  
Connect the '''‘Ri’''' pin to '''PA1''' of the '''Mainboard''' which represents '''YLED2'''.
+
Connect the '''‘Ri’ pin''' to '''PA1''' of the '''Mainboard''' which represents '''YLED2'''.
  
 
Make the connections as shown in the picture.
 
Make the connections as shown in the picture.
  
 
|-
 
|-
| style="border:1pt solid #000000;padding:0.176cm;"|  
+
| style="border:1pt solid #000000;padding:0.176cm;"| Switch on the power
| 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;"| 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;"| Point to green LED
| style="border:1pt solid #000000;padding:0.176cm;"| Initially the left green LED will be glowing.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Initially the left green '''LED''' will be glowing.
  
Recall that bottom LED connections should be given logic low for an LED to glow.
+
Recall that bottom '''LED''' connections should be given '''logic''' low for an '''LED''' to glow.
  
 
|-
 
|-
Line 409: Line 411:
 
| style="border:1pt solid #000000;padding:0.176cm;"| Now press the switch '''NO1'''.
 
| style="border:1pt solid #000000;padding:0.176cm;"| Now press the switch '''NO1'''.
  
The right green LED starts glowing and the left one goes off at the same time.
+
The right green '''LED''' starts glowing and the left one goes off at the same 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;"| Thus the output of the left green LED acts as input to the right green LED.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Thus the output of the left green '''LED''' acts as input to the right green '''LED'''.
  
 
|-
 
|-
| style="border:1pt solid #000000;padding:0.176cm;"|  
+
| style="border:1pt solid #000000;padding:0.176cm;"| Switch off the power
| style="border:1pt solid #000000;padding:0.176cm;"| Turn off the power supply.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Turn '''off''' the '''power supply'''.
  
 
|-
 
|-
Line 434: Line 436:
 
| style="border:1pt solid #000000;padding:0.176cm;"| In this tutorial, we learnt about different source types such as
 
| style="border:1pt solid #000000;padding:0.176cm;"| In this tutorial, we learnt about different source types such as
  
* Internal Relay
+
* '''Internal Relay'''
* Output pin
+
* '''Output pin'''
  
 
|-
 
|-
Line 447: Line 449:
 
* It should stay on even after it is released.
 
* It should stay on even after it is released.
  
| style="border:1pt solid #000000;padding:0.176cm;"| As an assignment, draw a ladder logic to latch an LED.
+
| style="border:1pt solid #000000;padding:0.176cm;"| As an assignment, draw a '''ladder logic''' to latch an '''LED'''.
  
 
Hint:
 
Hint:
  
* The LED should turn on when a switch is pressed  
+
* The '''LED''' should turn '''on''' when a '''switch''' is pressed  
* It should stay on even after it is released.
+
* It should stay '''on''' even after it is released.
  
 
|-
 
|-
Line 477: Line 479:
  
 
Forum for specific questions:
 
Forum for specific questions:
| style="border:1pt solid #000000;padding:0.176cm;"|  
+
| style="border:1pt solid #000000;padding:0.176cm;"| Please post your timed queries in this Forum
* Please post your timed queries in this Forum
+
  
 
|-
 
|-

Latest revision as of 06:46, 30 October 2020

Visual Cue
Narration
Slide 1: Welcome to the spoken tutorial on Internal Relay and Output pin
Slide 2: Learning Objectives

Types of sources available for Contacts/Coils

  • Internal Relay
  • Output pin
In this tutorial we will learn about,
  • Types of sources available for Contacts/Coils.
  • (i.e) Internal Relay and Output pin.
Slide 3: System Requirements
  • Ubuntu 18.04 OS
  • LDmicro
  • OpenPLC version 1 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
  • Normal Contact and Coil
  • Negated Contact and Coil
  • To follow this tutorial, you should know the working of
  1. Normal Contact and Coil
  2. Negated Contact and 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.

First we will understand the working of an Internal Relay.
Slide 5: Internal Relay
  • It can be thought of as a variable inside a PLC memory bit
  • It does not affect the external I/O’s of the PLC
  • Internal relay can be thought of as a variable inside a PLC memory bit.
  • It does not affect the external I/Os of the PLC.
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
  • Internal Relay
  • Output pin


In this tutorial, we learnt about different source types such as
  • Internal Relay
  • Output pin
Slide 7: Assignment

Draw a ladder logic to latch an LED

Hint:

  • The LED should turn on when a switch is pressed
  • It should stay on even after it is released.
As an assignment, draw a ladder logic to latch an LED.

Hint:

  • The LED should turn on when a switch is pressed
  • It should stay on even after it is released.
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, Priyanka.guntaka123