Difference between revisions of "OpenPLC-version1-with-LDmicro/C2/Programming-OpenPLC/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...")
 
 
(One intermediate revision by one other user not shown)
Line 15: Line 15:
 
* How to program the OpenPLC version 1 Mainboard
 
* How to program the OpenPLC version 1 Mainboard
  
| style="border:1pt solid #000000;padding:0.176cm;"| In this tutorial, we will learn
+
| style="border:1pt solid #000000;padding:0.176cm;"| In this tutorial, we will learn how to '''program''' the '''OpenPLC version 1 Mainboard'''
 
+
* How to program the '''OpenPLC''' '''version 1 Mainboard'''
+
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Slide 3:  
 
| style="border:1pt solid #000000;padding:0.176cm;"| Slide 3:  
Line 23: Line 21:
 
System Requirements
 
System Requirements
  
* Ubuntu Linux 18.04''' '''operating system
+
* '''Ubuntu Linux 18.04''' operating system
* OpenPLC version 1 Mainboard
+
* '''OpenPLC version 1 Mainboard'''
* 24V, 2A SMPS
+
* 24V, 2A '''SMPS'''
* USBasp programmer
+
* '''USBasp programmer'''
  
 
| style="border:1pt solid #000000;padding:0.176cm;"| To record this tutorial I am using:
 
| style="border:1pt solid #000000;padding:0.176cm;"| To record this tutorial I am using:
  
 
* '''Ubuntu Linux''' 18.04 operating system
 
* '''Ubuntu Linux''' 18.04 operating system
* '''OpenPLC''' '''version 1''' '''Mainboard'''
+
* '''OpenPLC version 1 Mainboard'''
 
* '''24V, 2A SMPS'''
 
* '''24V, 2A SMPS'''
* '''USBasp''' programmer
+
* '''USBasp programmer'''
  
 
|-
 
|-
Line 40: Line 38:
 
Pre-requisites
 
Pre-requisites
  
* How to generate a hex file of a ladder diagram in '''LDmicro'''.  
+
* How to generate a '''hex file''' of a '''ladder''' diagram in '''LDmicro'''.  
 
* If not, please refer to the relevant tutorials from [https://spoken-tutorial.org/ Home | spoken-tutorial.org]
 
* If not, please refer to the relevant tutorials from [https://spoken-tutorial.org/ Home | spoken-tutorial.org]
  
 
| style="border:1pt solid #000000;padding:0.176cm;"| To follow this tutorial, you should know
 
| style="border:1pt solid #000000;padding:0.176cm;"| To follow this tutorial, you should know
  
* How to generate hex file of a ladder diagram in '''LDmicro'''.  
+
* How to generate '''hex file''' of a '''ladder''' diagram in '''LDmicro'''.  
 
* If not, please refer to the relevant tutorials in this series on this website.
 
* If not, please refer to the relevant tutorials in this series on this website.
  
 
|-
 
|-
 
| 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’ll see how to upload a program to '''OpenPLC version 1 Mainboard'''.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Now, we’ll see how to upload a '''program''' to '''OpenPLC version 1 Mainboard'''.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Slide 5: Code file - sample.hex
 
| style="border:1pt solid #000000;padding:0.176cm;"| Slide 5: Code file - sample.hex
  
* The files used in this tutorial are available in the Code Files link on this tutorial page
+
* The files used in this tutorial are available in the '''Code Files''' link on this tutorial page
 
* Please download and extract them
 
* Please download and extract them
 
* Make a copy and then use them while practising
 
* Make a copy and then use them while practising
Line 61: Line 59:
 
| style="border:1pt solid #000000;padding:0.176cm;"| We will use the '''sample.hex '''file which was created earlier.
 
| style="border:1pt solid #000000;padding:0.176cm;"| We will use the '''sample.hex '''file which was created earlier.
  
* The files used in this tutorial are available in the Code Files link on this tutorial page.
+
* The files used in this tutorial are available in the '''Code Files''' link on this tutorial page.
 
* Please download and extract them
 
* Please download and extract them
 
* Make a copy and then use them while practising
 
* Make a copy and then use them while practising
Line 69: Line 67:
  
 
USBasp-programmer.jpg
 
USBasp-programmer.jpg
| style="border:1pt solid #000000;padding:0.176cm;"| We are using a '''USBasp''', to program our '''Mainboard'''.
+
| style="border:1pt solid #000000;padding:0.176cm;"| We are using a '''USBasp''', to '''program''' our '''Mainboard'''.
 
+
  
 
|-
 
|-
Line 78: Line 75:
 
| style="border:1pt solid #000000;padding:0.176cm;"| Make the connections as shown in the picture.
 
| style="border:1pt solid #000000;padding:0.176cm;"| Make the connections as shown in the picture.
  
Connect SMPS and USBasp to the Mainboard as shown here.
+
Connect '''SMPS''' and '''USBasp''' to the '''Mainboard''' as shown here.
  
 
Recall that we have explained these connections in the earlier tutorials.
 
Recall that we have explained these connections in the earlier tutorials.
  
Turn on the power supply.
+
Turn on the '''power supply'''.
  
Make sure that one of the LEDs on USBasp is glowing.
+
Make sure that one of the '''LEDs''' on '''USBasp''' is glowing.
  
This indicates that the programmer is connected properly.
+
This indicates that the '''programmer''' is connected properly.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
| style="border:1pt solid #000000;padding:0.176cm;"| Open 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.
  
If you’re a '''Windows''' user open command prompt.
+
If you’re a '''Windows''' user open '''command prompt'''.
  
 
|-
 
|-
Line 98: Line 95:
  
 
Press ENTER
 
Press ENTER
| style="border:1pt solid #000000;padding:0.176cm;"| Type '''cd Desktop/LDmicro''' and press Enter.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Type '''cd Desktop/LDmicro''' and press '''Enter'''.
  
 
I have saved a file '''sample.hex '''in the above folder.
 
I have saved a file '''sample.hex '''in the above folder.
  
Go to the location where you’ve saved the hex file.
+
Go to the location where you’ve saved the '''hex file'''.
  
 
|-
 
|-
Line 108: Line 105:
  
 
'''avrdude -c usbasp -p m16 -U flash:w:sample.hex'''
 
'''avrdude -c usbasp -p m16 -U flash:w:sample.hex'''
| style="border:1pt solid #000000;padding:0.176cm;"| Now type the command as shown.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Now type the '''command''' as shown.
  
For uploading the program we are using a command line tool, '''AVRDUDE'''
+
For uploading the '''program''' we are using a '''command line tool, AVRDUDE'''
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight according to narration
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight according to narration
| style="border:1pt solid #000000;padding:0.176cm;"| -c indicates the programmer id of the programmer.
+
| style="border:1pt solid #000000;padding:0.176cm;"| '''hyphen c''' indicates the '''programmer id''' of the '''programmer'''.
  
Since we are using an USBasp programmer, here the id is given as '''usbasp'''.
+
Since we are using an USBasp programmer, here the '''id''' is given as '''usbasp'''.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight according to narration
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight according to narration
| style="border:1pt solid #000000;padding:0.176cm;"| '''-p''' indicates the part number of the microcontroller that we are using.
+
| style="border:1pt solid #000000;padding:0.176cm;"| '''hyphen p''' indicates the part number of the '''microcontroller''' that we are using.
  
 
In our case it is '''ATMEGA16'''.  
 
In our case it is '''ATMEGA16'''.  
Line 128: Line 125:
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight according to narration
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight according to narration
| style="border:1pt solid #000000;padding:0.176cm;"| '''-U''' handles all memory read and write operations.
+
| style="border:1pt solid #000000;padding:0.176cm;"| '''hyphen capital U''' handles all '''memory read''' and '''write''' operations.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Type flash
 
| style="border:1pt solid #000000;padding:0.176cm;"| Type flash
| style="border:1pt solid #000000;padding:0.176cm;"| '''flash '''indicates the flash memory and '''w '''indicates the write operations.
+
| style="border:1pt solid #000000;padding:0.176cm;"| '''flash '''indicates the '''flash memory''' and '''w '''indicates the '''write''' operations.
  
 
|-
 
|-
Line 144: Line 141:
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight red light
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight red light
| style="border:1pt solid #000000;padding:0.176cm;"| We can see another LED on the '''USBasp''' is blinking.
+
| style="border:1pt solid #000000;padding:0.176cm;"| We can see another '''LED''' on the '''USBasp''' is blinking.
  
 
This indicates that it is communicating with the '''Mainboard''' appropriately.
 
This indicates that it is communicating with the '''Mainboard''' appropriately.
Line 150: Line 147:
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight avrdude: 364 bytes of flash verified  
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight avrdude: 364 bytes of flash verified  
| style="border:1pt solid #000000;padding:0.176cm;"| In the terminal, we get
+
| style="border:1pt solid #000000;padding:0.176cm;"| In the '''terminal''', we get '''avrdude: 364 bytes of flash verified'''  
 
+
'''avrdude: 364 bytes of flash verified'''  
+
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight the output
 
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight the output
| style="border:1pt solid #000000;padding:0.176cm;"| Note that the number of bytes varies from program to program.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Note that the number of '''bytes''' varies from '''program''' to '''program'''.
  
 
|-
 
|-
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
 
| style="border:1pt solid #000000;padding:0.176cm;"|  
| style="border:1pt solid #000000;padding:0.176cm;"| If you don’t get either of the indications, it means that programming isn’t done properly.
+
| style="border:1pt solid #000000;padding:0.176cm;"| If you don’t get either of the indications, it means that '''programming''' isn’t done properly.
  
 
|-
 
|-
Line 166: Line 161:
  
 
Additional Reading Material
 
Additional Reading Material
| style="border:1pt solid #000000;padding:0.176cm;"| Refer to the Additional reading material of this tutorial to know more about:
+
| style="border:1pt solid #000000;padding:0.176cm;"| Refer to the '''Additional reading material''' of this tutorial to know more about:
  
# Precautions that should be taken before programming.
+
# Precautions that should be taken before '''programming'''.
# Ways of troubleshoot when the Mainboard is not programmed properly.
+
# Ways of troubleshoot when the '''Mainboard''' is not '''programmed''' properly.
  
 
|-
 
|-
 
| 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 see various part numbers for different controllers & programmers.
+
| style="border:1pt solid #000000;padding:0.176cm;"| Let us see various part numbers for different '''controllers''' & '''programmers'''.
  
 
|-
 
|-
Line 192: Line 187:
 
| style="border:1pt solid #000000;padding:0.176cm;"| In this tutorial, we have used '''ATmega16'''.  
 
| style="border:1pt solid #000000;padding:0.176cm;"| In this tutorial, we have used '''ATmega16'''.  
  
We can observe that the part id is '''m16 '''according to the list.
+
We can observe that the part '''id''' is '''m16 '''according to the list.
  
The part id of '''USBasp programmer''' as '''‘usbasp’'''.
+
The part '''id''' of '''USBasp programmer''' as '''‘usbasp’'''.
  
You can refer to this manual, if you are using a different microcontroller or programmer.
+
You can refer to this manual, if you are using a different '''microcontroller''' or '''programmer'''.
  
It also contains the information of the command line options to control AVRDUDE’s behavior.
+
It also contains the information of the '''command line''' options to '''control AVRDUDE’s''' behavior.
  
 
|-
 
|-
Line 213: Line 208:
 
We have learnt how to
 
We have learnt how to
  
* Program the OpenPLC version 1 Mainboard
+
* Program the '''OpenPLC version 1 Mainboard'''
  
| style="border:1pt solid #000000;padding:0.176cm;"| In this tutorial, we learnt to
+
| style="border:1pt solid #000000;padding:0.176cm;"| In this tutorial, we learnt to '''program''' the '''OpenPLC version 1 Mainboard'''
 
+
* Program the '''OpenPLC version 1 Mainboard'''
+
  
 
|-
 
|-

Latest revision as of 15:45, 10 August 2020

Visual Cue
Narration
Slide 1: Welcome to the spoken tutorial on Programming OpenPLC.
Slide 2:

Learning Objectives

  • How to program the OpenPLC version 1 Mainboard
In this tutorial, we will learn how to program the OpenPLC version 1 Mainboard
Slide 3:

System Requirements

  • Ubuntu Linux 18.04 operating system
  • OpenPLC version 1 Mainboard
  • 24V, 2A SMPS
  • USBasp programmer
To record this tutorial I am using:
  • Ubuntu Linux 18.04 operating system
  • OpenPLC version 1 Mainboard
  • 24V, 2A SMPS
  • USBasp programmer
Slide 4:

Pre-requisites

  • How to generate a hex file of a ladder diagram in LDmicro.
  • If not, please refer to the relevant tutorials from Home | spoken-tutorial.org
To follow this tutorial, you should know
  • How to generate hex file of a ladder diagram in LDmicro.
  • If not, please refer to the relevant tutorials in this series on this website.
Now, we’ll see how to upload a program to OpenPLC version 1 Mainboard.
Slide 5: Code file - sample.hex
  • The files used in this tutorial are available in the Code Files link on this tutorial page
  • Please download and extract them
  • Make a copy and then use them while practising
We will use the sample.hex file which was created earlier.
  • The files used in this tutorial are available in the Code Files link on this tutorial page.
  • Please download and extract them
  • Make a copy and then use them while practising
Slide6:

USBasp-programmer.jpg

We are using a USBasp, to program our Mainboard.
Slide 7:

Mainboard-computer-connection.jpg

Make the connections as shown in the picture.

Connect SMPS and USBasp to the Mainboard as shown here.

Recall that we have explained these connections in the earlier tutorials.

Turn on the power supply.

Make sure that one of the LEDs on USBasp is glowing.

This indicates that the programmer is connected properly.

Open the terminal by pressing CTRL+ALT+T keys simultaneously.

If you’re a Windows user open command prompt.

Type cd Desktop/LDmicro

Press ENTER

Type cd Desktop/LDmicro and press Enter.

I have saved a file sample.hex in the above folder.

Go to the location where you’ve saved the hex file.

Type,

avrdude -c usbasp -p m16 -U flash:w:sample.hex

Now type the command as shown.

For uploading the program we are using a command line tool, AVRDUDE

Highlight according to narration hyphen c indicates the programmer id of the programmer.

Since we are using an USBasp programmer, here the id is given as usbasp.

Highlight according to narration hyphen p indicates the part number of the microcontroller that we are using.

In our case it is ATMEGA16.

So we have specified it as m16.

Highlight according to narration hyphen capital U handles all memory read and write operations.
Type flash flash indicates the flash memory and w indicates the write operations.
Highlight according to narration sample.hex is the file that we want to upload.
Press ENTER Press ENTER.
Highlight red light We can see another LED on the USBasp is blinking.

This indicates that it is communicating with the Mainboard appropriately.

Highlight avrdude: 364 bytes of flash verified In the terminal, we get avrdude: 364 bytes of flash verified
Highlight the output Note that the number of bytes varies from program to program.
If you don’t get either of the indications, it means that programming isn’t done properly.
Slide 8:

Additional Reading Material

Refer to the Additional reading material of this tutorial to know more about:
  1. Precautions that should be taken before programming.
  2. Ways of troubleshoot when the Mainboard is not programmed properly.
Let us see various part numbers for different controllers & programmers.
Slide 9: Controller’s part number list

List of part number for Controllers and Programmers is given in the below link:

https://www.nongnu.org/avrdude/user-manual/avrdude_4.html#Option-Descriptions


Highlight with box

Go to the given link.
Highlight m16

Highlight usbasp

In this tutorial, we have used ATmega16.

We can observe that the part id is m16 according to the list.

The part id of USBasp programmer as ‘usbasp’.

You can refer to this manual, if you are using a different microcontroller or programmer.

It also contains the information of the command line options to control AVRDUDE’s behavior.

This brings us to the end of this tutorial.

Let us summarize.

Slide 10:

Summary

We have learnt how to

  • Program the OpenPLC version 1 Mainboard
In this tutorial, we learnt to program the OpenPLC version 1 Mainboard
Slide 12:

About Spoken Tutorial project

The video at the following link summarises the Spoken Tutorial project.

Please download and watch it.

Slide 13:

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 14:

Forum for specific questions:

  • Please post your timed queries in this forum.
Slide 15:

Forum for specific questions:

  • Do you have any general / technical questions on OpenPLC?
  • Please visit the FOSSEE forum and post your question.
Slide 16:

Acknowledgement

Spoken Tutorial project is funded by MHRD, Government of India.
Slide 17:

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, Nirmala Venkat, Priyanka.guntaka123