Difference between revisions of "OpenPLC-version1-with-LDmicro/C3/AD-Converter-Read-Instruction/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
m (Nancyvarkey moved page OpenPLC-version1-with-LDmicro/C3/A/D-Converter-Read-Instruction/English to OpenPLC-version1-with-LDmicro/C3/AD-Converter-Read-Instruction/English without leaving a redirect: There was a slash in the topic name which was c...)
 
Line 38: Line 38:
  
 
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]
|| * To follow this tutorial, you should be familiar with  
+
||  
 
+
* To follow this tutorial, you should be familiar with  
* Heater module and
+
** '''Heater module''' and
* '''Compare''' instructions.
+
** '''Compare''' instructions.
  
 
* 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.
Line 58: Line 58:
 
* ADC of ATmega16 is of 10-bit resolution i.e. it outputs value from 0 to 1023
 
* ADC of ATmega16 is of 10-bit resolution i.e. it outputs value from 0 to 1023
  
|| This instruction reads the data collected by '''ADC''' built within a microcontroller.
+
|| This instruction reads the '''data''' collected by '''ADC''' built within a '''microcontroller'''.
  
The data collected will be stored in a variable.
+
The '''data''' collected will be stored in a '''variable'''.
  
This ADC variable can be manipulated using '''Compare''' and '''Arithmetic''' operations.
+
This '''ADC variable''' can be manipulated using '''Compare''' and '''Arithmetic''' operations.
  
The '''ADC''' of '''ATmega16''' is of 10-bit resolution i.e. it outputs values from 0 to 1023.
+
The '''ADC''' of '''ATmega16''' is of '''10-bit resolution''' i.e. it outputs values from 0 to 1023.
 
|-
 
|-
 
||  
 
||  
|| We will learn about the working of this instruction using a simple analog example.
+
|| We will learn about the working of this instruction using a simple '''analog''' example.
 
|-
 
|-
 
|| Slide: Example
 
|| Slide: Example
Line 77: Line 77:
  
 
Output: fan is OFF and heat is ON
 
Output: fan is OFF and heat is ON
|| In this tutorial we will control the temperature of the resistor.
+
|| In this tutorial we will control the temperature of the '''resistor'''.
  
 
That is, the heating element of the '''OpenPLC Heater module'''.
 
That is, the heating element of the '''OpenPLC Heater module'''.
  
We will have the conditions as follows.
+
We will have the '''conditions''' as follows.
  
If the '''ADC''' value is less than 800, turn on the fan and turn off the heating element.
+
If the '''ADC''' value is less than 800, turn '''on''' the fan and turn '''off''' the heating element.
  
If the '''ADC''' value is greater than 900, turn off the fan and turn on the heating element.
+
If the '''ADC''' value is greater than 900, turn '''off''' the fan and turn '''on''' the heating element.
  
 
You can set the limit values according to your requirements.
 
You can set the limit values according to your requirements.
 
|-
 
|-
 
||  
 
||  
|| Recall that the temperature sensor used in the '''Heater''' module is a '''NTC thermistor'''.
+
|| Recall that the '''temperature sensor''' used in the '''Heater module''' is a '''NTC thermistor'''.
  
Thus, the resistance of the thermistor is inversely proportional to the temperature.
+
Thus, the '''resistance''' of the '''thermistor''' is inversely proportional to the temperature.
 
|-
 
|-
 
|| Open the LDmicro from the launcher bar
 
|| Open the LDmicro from the launcher bar
Line 103: Line 103:
 
|| Double-click on '''Read ADC'''.
 
|| Double-click on '''Read ADC'''.
  
We can see a box to enter the destination variable.
+
We can see a box to enter the destination '''variable'''.
  
Type '''‘temp’''' and click the OK button.
+
Type '''‘temp’''' and click the '''OK''' button.
 
|-
 
|-
 
|| Highlight Atemp in I/O list
 
|| Highlight Atemp in I/O list
 
|| We can see that the name '''‘temp’''' is prefixed by '''A'''.
 
|| We can see that the name '''‘temp’''' is prefixed by '''A'''.
  
In the''' I/O''' list we can see its type as ‘'''adc input’'''.
+
In the''' I/O''' list we can see its '''type''' as ‘'''adc input’'''.
 
|-
 
|-
 
|| Click Edit -> Insert rung after
 
|| Click Edit -> Insert rung after
|| Now insert a rung below.
+
|| Now insert a '''rung''' below.
 
|-
 
|-
 
|| Place the cursor in the new rung >> Click on Instructions -> Comparison Operators -> Insert GRT
 
|| Place the cursor in the new rung >> Click on Instructions -> Comparison Operators -> Insert GRT
|| Insert a '''greater than compare''' instruction in the new rung as shown.
+
|| Insert a '''greater than compare''' instruction in the new '''rung''' as shown.
 
|-
 
|-
 
|| Double-click on GRT >> Type ‘Atemp’ in the first column >> Type 900 in the second column
 
|| Double-click on GRT >> Type ‘Atemp’ in the first column >> Type 900 in the second column
 
|| Double click on it.
 
|| Double click on it.
  
Set the variable to '''Atemp''' and compare it to 900.
+
Set the '''variable''' to '''Atemp''' and compare it to 900.
  
Click the OK button.
+
Click the '''OK''' button.
 
|-
 
|-
 
|| Place cursor to the right of GRT >> Click on Instructions -> Insert Coil
 
|| Place cursor to the right of GRT >> Click on Instructions -> Insert Coil
|| To the right of it insert a Coil.
+
|| To the right of it, insert a '''Coil'''.
 
|-
 
|-
 
|| Double-click on Ynew >> Type ‘heat’ in the name box >> Select ‘SET-only’ in type >> Click OK button
 
|| Double-click on Ynew >> Type ‘heat’ in the name box >> Select ‘SET-only’ in type >> Click OK button
|| Rename the Coil as '''‘heat’''' and configure it as '''SET-only Coil'''.
+
|| Rename the '''Coil''' as '''‘heat’''' and configure it as '''SET-only Coil'''.
 
|-
 
|-
 
|| Place the cursor parallel to Yheat >> Click on Instructions -> Insert Coil
 
|| Place the cursor parallel to Yheat >> Click on Instructions -> Insert Coil
|| Now, parallel to '''Yheat''' insert another Coil.
+
|| Now, parallel to '''Yheat''' insert another '''Coil'''.
 
|-
 
|-
 
|| Double-click on Ynew >> Type ‘fan’ in the name box >> Select ‘RESET-only’ in type >> Click OK button
 
|| Double-click on Ynew >> Type ‘fan’ in the name box >> Select ‘RESET-only’ in type >> Click OK button
|| Rename it as '''‘fan’''' and configure it as '''RESET-only''' Coil.
+
|| Rename it as '''‘fan’''' and configure it as '''RESET-only Coil'''.
 
|-
 
|-
 
|| Click Edit -> Insert rung after
 
|| Click Edit -> Insert rung after
|| Insert one more rung below.
+
|| Insert one more '''rung''' below.
 
|-
 
|-
 
|| Place the cursor in the new rung >> Click on Instructions -> Comparison Operators -> Insert LES
 
|| Place the cursor in the new rung >> Click on Instructions -> Comparison Operators -> Insert LES
|| Place a '''less than compare''' instruction in the new rung as shown.
+
|| Place a '''less than compare''' instruction in the new '''rung''' as shown.
  
 
|-
 
|-
Line 147: Line 147:
 
|| Double click on it.
 
|| Double click on it.
  
Set the variable as '''Atemp''' and compare it to 800.
+
Set the '''variable''' as '''Atemp''' and compare it to 800.
  
Click the OK button.
+
Click the '''OK''' button.
 
|-
 
|-
 
|| Place cursor to the right of GRT >> Click on Instructions -> Insert Coil
 
|| Place cursor to the right of GRT >> Click on Instructions -> Insert Coil
Line 155: Line 155:
 
|-
 
|-
 
|| Double-click on Ynew >> Type ‘heat’ in the name box >> Select ‘RESET-only’ in type >> Click OK button
 
|| Double-click on Ynew >> Type ‘heat’ in the name box >> Select ‘RESET-only’ in type >> Click OK button
|| Rename the Coil as '''‘heat’''' and configure it as '''RESET-only Coil'''.
+
|| Rename the '''Coil''' as '''‘heat’''' and configure it as '''RESET-only Coil'''.
 
|-
 
|-
 
|| Place the cursor parallel to Yheat >> Click on Instructions -> Insert Coil
 
|| Place the cursor parallel to Yheat >> Click on Instructions -> Insert Coil
|| Now, parallel to '''Yheat''' insert another Coil.
+
|| Now, parallel to '''Yheat''' insert another '''Coil'''.
 
|-
 
|-
 
|| Double-click on Ynew >> Type ‘fan’ in the name box >> Select SET-only’ in type >> Click OK button
 
|| Double-click on Ynew >> Type ‘fan’ in the name box >> Select SET-only’ in type >> Click OK button
Line 164: Line 164:
 
|-
 
|-
 
||  
 
||  
|| We will now check the working of this logic.
+
|| We will now check the working of this '''logic'''.
 
|-
 
|-
 
|| Click Simulate -> Simulation mode >>
 
|| Click Simulate -> Simulation mode >>
  
 
Click Simulate -> Real-time simulation
 
Click Simulate -> Real-time simulation
|| Let us turn on the simulation mode.
+
|| 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.
 
|-
 
|-
 
|| Highlight the state of Yheat, Yfan and Atemp in the I/O list
 
|| Highlight the state of Yheat, Yfan and Atemp in the I/O list
Line 186: Line 186:
 
|| A slider bar appears.
 
|| A slider bar appears.
  
We can change the ADC value by scrolling the pointer.
+
We can change the '''ADC''' value by scrolling the pointer.
 
|-
 
|-
 
||  
 
||  
|| '''ADC''' reading 0 represents the minimum resistance value of the thermistor.
+
|| '''ADC''' reading 0 represents the minimum '''resistance''' value of the '''thermistor'''.
  
'''ADC''' reading 1023 represents the maximum resistance value of the thermistor.
+
'''ADC''' reading 1023 represents the maximum '''resistance''' value of the '''thermistor'''.
 
|-
 
|-
 
|| Increase the value of Atemp
 
|| Increase the value of Atemp
Line 208: Line 208:
 
|-
 
|-
 
|| Click Simulate -> Halt simulation >> Click Simulate -> Simulation Mode
 
|| Click Simulate -> Halt simulation >> Click Simulate -> Simulation Mode
|| Now, turn off the simulation mode.
+
|| 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 215: Line 215:
 
|-
 
|-
 
||  
 
||  
|| Now let us compile the logic.
+
|| 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.  
 
|-
 
|-
 
|| Click on Settings >> Click on Microcontroller >> Select AVR ATmega16 40-PDIP  
 
|| 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 >> Click on MCU parameters >> Change Crystal frequency to 16
|| Click on '''Settings''' and select the microcontroller '''AVR ATmega16 40-PDIP.'''  
+
|| Click on '''Settings''' and select the '''microcontroller AVR ATmega16 40-PDIP.'''  
  
Adjust its parameters as shown here.
+
Adjust its '''parameters''' as shown here.
 
|-
 
|-
 
|| Double-click on Yfan in I/O list >> Select PC6 >> Click OK button
 
|| Double-click on Yfan in I/O list >> Select PC6 >> Click OK button
  
 
Double-click on Yheat in I/O list >> Select PC7 >> Click OK button
 
Double-click on Yheat in I/O list >> Select PC7 >> Click OK button
|| Assign pin '''PC6''' to '''Yfan''' and '''PC7''' to '''Yheat''' as shown.
+
|| Assign '''pin PC6''' to '''Yfan''' and '''PC7''' to '''Yheat''' as shown.
  
And PC7 to Yheat.
+
And '''PC7''' to '''Yheat'''.
  
 
|-
 
|-
Line 238: Line 238:
 
|| Double-click on '''Atemp '''in the I/O list.
 
|| Double-click on '''Atemp '''in the I/O list.
  
'''I/O''' '''pin''' dialog box opens.
+
'''I/O pin''' dialog box opens.
  
We can see there are only''' Port A '''pins as they are the '''ADC''' pins.
+
We can see there are only''' Port A '''pins as they are the '''ADC pins'''.
  
Select '''PA7''' and click the OK button.
+
Select '''PA7''' and click the '''OK''' button.
 
|-
 
|-
 
|| Click on Compile >> Click on Compile >> Go to Desktop/LDmicro folder >> Rename it as ‘adc.hex’ >> Click on Save.
 
|| Click on Compile >> Click on Compile >> Go to Desktop/LDmicro folder >> Rename it as ‘adc.hex’ >> Click on Save.
  
Click OK button
+
Click '''OK''' button
|| Compile the logic as '''adc.hex'''
+
|| '''Compile''' the '''logic''' as '''adc.hex'''
 
|-
 
|-
 
|| Click on File >> Click on Save >> Go to Desktop/LDmicro folder >> Rename it as ‘adc.ld’ >> Click on Save
 
|| Click on File >> Click on Save >> Go to Desktop/LDmicro folder >> Rename it as ‘adc.ld’ >> Click on Save
|| Then save the ladder diagram as '''adc.ld.'''
+
|| Then save the '''ladder diagram''' as '''adc.ld.'''
 
|-
 
|-
 
||  
 
||  
|| We will now see the working of this logic on hardware.
+
|| We will now see the working of this '''logic''' on hardware.
 
|-
 
|-
 
|| Connect Mainboard to PC using USBasp
 
|| Connect Mainboard to PC using USBasp
Line 261: Line 261:
 
|| Connect the '''Mainboard''' to your laptop using '''USBasp'''.
 
|| Connect the '''Mainboard''' to your laptop using '''USBasp'''.
  
Turn on the power supply.
+
Turn '''on''' the '''power supply'''.
 
|-
 
|-
 
|| Open terminal >> Type cd Desktop/LDmicro >> Press ENTER >> type ‘'''avrdude -c usbasp -p m16 -U flash:w:adc.hex’ '''>> Press ENTER
 
|| Open terminal >> Type cd Desktop/LDmicro >> Press ENTER >> type ‘'''avrdude -c usbasp -p m16 -U flash:w:adc.hex’ '''>> Press ENTER
|| Open the Terminal by pressing '''CTRL+ALT+T''' keys simultaneously.
+
|| 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'''.
 
|-
 
|-
 
|| Remove the '''USBasp''' connection from the laptop.
 
|| Remove the '''USBasp''' connection from the laptop.
|| Turn off the power supply.
+
|| Turn '''off''' the '''power supply'''.
  
 
Remove the '''USBasp''' connection from the laptop.
 
Remove the '''USBasp''' connection from the laptop.
Line 277: Line 277:
 
This will prevent any hardware damage.
 
This will prevent any hardware damage.
 
|-
 
|-
|| adc.png
+
|| adc.png - connect as explained in the narration
 
|| Let us see the connection details now.  
 
|| Let us see the connection details now.  
 
|-
 
|-
|| adc.png
+
|| adc.png - connect as explained in the narration
|| Power the '''Heater''' module through relimate connectors from the '''Mainboard'''.
+
|| Power the '''Heater module''' through '''relimate connectors''' from the '''Mainboard'''.
  
Connect pin '''PA7 '''of the '''Mainboard''' to''' temp''' '''MCU''' pin of the '''Heater''' module.
+
Connect '''pin PA7 '''of the '''Mainboard''' to''' temp MCU pin''' of the '''Heater module'''.
  
Connect pin '''PC7''' of the Mainboard to '''heat''' '''MCU''' pin of the '''Heater''' module.
+
Connect '''pin PC7''' of the '''Mainboard''' to '''heat MCU pin''' of the '''Heater module'''.
  
Connect pin '''PC6''' of the Mainboard to '''fan''' '''MCU''' pin of the '''Heater''' module.
+
Connect '''pin PC6''' of the '''Mainboard''' to fan '''MCU pin''' of the '''Heater module'''.
  
 
Make the connections as shown in the picture.
 
Make the connections as shown in the picture.
 
|-
 
|-
||  
+
|| Turn on the power
|| After making all the connections properly, turn on the power supply.
+
|| After making all the connections properly, turn '''on''' the '''power supply'''.
 
|-
 
|-
||  
+
||Point as explained in the narration
|| Depending on the initial temperature either the fan or resistor starts heating up.
+
|| Depending on the initial temperature either the fan or '''resistor''' starts heating up.
  
For the first time we can observe that '''Heaton LED '''is turned ON.
+
For the first time we can observe that '''Heaton LED '''is turned '''ON'''.
  
 
This is because its temperature of the heating element is low.
 
This is because its temperature of the heating element is low.
 
|-
 
|-
||  
+
|| Point to FanOn LED
|| After sometime when the resistor gets heated up, the fan will turn ON.
+
|| After sometime when the '''resistor''' gets heated up, the fan will turn '''ON'''.
  
It is also indicated by '''FanOn''' LED.
+
It is also indicated by '''FanOn LED'''.
 
|-
 
|-
 
||  
 
||  
|| Again when the resistor cools down, the resistor starts heating up.
+
|| Again when the '''resistor''' cools down, the '''resistor''' starts heating up.
 
|-
 
|-
 
||  
 
||  
|| Thus the process continues depending on the temperature of the resistor.
+
|| Thus the process continues depending on the temperature of the '''resistor'''.
 
|-
 
|-
 
||  
 
||  
|| Note that initially the fan might turn on if the resistor is already heated up.
+
|| Note that initially the fan might turn '''on''' if the '''resistor''' is already heated up.
 
|-
 
|-
||  
+
|| Turn off the power
|| Turn off the power supply.
+
|| Turn '''off''' the '''power supply'''.
 
|-
 
|-
 
||  
 
||  
Line 323: Line 323:
 
Let us summarize.
 
Let us summarize.
 
|-
 
|-
|| Slide 8: Summary* A/D converter read instruction
+
|| Slide 8: Summary
 +
* A/D converter read instruction
  
  
|| In this tutorial we learnt about working of  
+
|| In this tutorial we learnt about working of '''A/D converter read''' instruction.
* A/D converter read instruction
+
  
 
|-
 
|-
 
|| Slide : Assignment
 
|| Slide : Assignment
  
Change the limit values :* If ADC value < 750,  
+
Change the limit values :
 +
* If ADC value < 750,  
  
Output: fan is ON and heat is OFF* If ADC value > 950,  
+
Output: fan is ON and heat is OFF
 +
* If ADC value > 950,  
  
 
Output: fan is OFF and heat is ON
 
Output: fan is OFF and heat is ON
 
|| As an assignment, change the limit values and repeat the experiment.
 
|| As an assignment, change the limit values and repeat the experiment.
  
If ADC value < 750, the fan should turn on and the heating element should turn off.
+
If '''ADC''' value < 750, the fan should turn '''on''' and the heating element should turn '''off'''.
  
If ADC value > 950 , the fan should turn off and the heating element should turn on.
+
If ADC value > 950 , the fan should turn '''off''' and the heating element should turn '''on'''.
 
|-
 
|-
 
|| Slide 9:
 
|| Slide 9:
Line 362: Line 364:
  
 
Forum for specific questions:
 
Forum for specific questions:
|| * Please post your timed queries in this forum.
+
|| Please post your timed queries in this forum.
  
 
|-
 
|-

Latest revision as of 15:22, 12 January 2021


Visual Cue Narration
Slide 1: Welcome to the spoken tutorial on A/D Converter Read
Slide 2: Learning Objectives
  • A/D Converter read instruction
In this tutorial we’ll learn about the working of
  • A/D i.e. Analog to Digital Converter Read instruction
Slide 3: System Requirements
  • Ubuntu 18.04 OS
  • LDmicro
  • OpenPLC version 1 Mainboard
  • 24V, 2A SMPS
  • USBasp programmer
  • Heater module
To record this tutorial I am using:
  • Ubuntu Linux 18.04 operating system
  • LDmicro
  • OpenPLC version 1 Mainboard
  • 24V, 2A SMPS
  • USBasp programmer
  • Heater module
Slide 4: Pre-requisites
  • Heater module
  • Compare instructions

If not, please refer to the relevant tutorials from Home | spoken-tutorial.org

  • To follow this tutorial, you should be familiar with
    • Heater module and
    • Compare instructions.
  • 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.

Slide 6: A/D Converter Read
  • Reads the data collected by ADC built within a microcontroller
  • Can be manipulated with general variable operations
  • ADC of ATmega16 is of 10-bit resolution i.e. it outputs value from 0 to 1023
This instruction reads the data collected by ADC built within a microcontroller.

The data collected will be stored in a variable.

This ADC variable can be manipulated using Compare and Arithmetic operations.

The ADC of ATmega16 is of 10-bit resolution i.e. it outputs values from 0 to 1023.

We will learn about the working of this instruction using a simple analog example.
Slide: Example
  • Control the temperature of the resistor of the OpenPLC Heater module

Conditions:

  • If ADC value < 800,

Output: fan is ON and heat is OFF* If ADC value > 900,

Output: fan is OFF and heat is ON

In this tutorial we will control the temperature of the resistor.

That is, the heating element of the OpenPLC Heater module.

We will have the conditions as follows.

If the ADC value is less than 800, turn on the fan and turn off the heating element.

If the ADC value is greater than 900, turn off the fan and turn on the heating element.

You can set the limit values according to your requirements.

Recall that the temperature sensor used in the Heater module is a NTC thermistor.

Thus, the resistance of the thermistor is inversely proportional to the temperature.

Open the LDmicro from the launcher bar Let us open LDmicro.
Click Instructions -> Analog Operations -> Insert A/D converter read Insert a A/D converter read instruction as shown.
Double click on Read ADC >> Type ‘temp’ in the destination column >> Click OK button Double-click on Read ADC.

We can see a box to enter the destination variable.

Type ‘temp’ and click the OK button.

Highlight Atemp in I/O list We can see that the name ‘temp’ is prefixed by A.

In the I/O list we can see its type as ‘adc input’.

Click Edit -> Insert rung after Now insert a rung below.
Place the cursor in the new rung >> Click on Instructions -> Comparison Operators -> Insert GRT Insert a greater than compare instruction in the new rung as shown.
Double-click on GRT >> Type ‘Atemp’ in the first column >> Type 900 in the second column Double click on it.

Set the variable to Atemp and compare it to 900.

Click the OK button.

Place cursor to the right of GRT >> Click on Instructions -> Insert Coil To the right of it, insert a Coil.
Double-click on Ynew >> Type ‘heat’ in the name box >> Select ‘SET-only’ in type >> Click OK button Rename the Coil as ‘heat’ and configure it as SET-only Coil.
Place the cursor parallel to Yheat >> Click on Instructions -> Insert Coil Now, parallel to Yheat insert another Coil.
Double-click on Ynew >> Type ‘fan’ in the name box >> Select ‘RESET-only’ in type >> Click OK button Rename it as ‘fan’ and configure it as RESET-only Coil.
Click Edit -> Insert rung after Insert one more rung below.
Place the cursor in the new rung >> Click on Instructions -> Comparison Operators -> Insert LES Place a less than compare instruction in the new rung as shown.
Double-click on LES >> Type ‘Atemp’ in the first column >> Type 900 in the second column Double click on it.

Set the variable as Atemp and compare it to 800.

Click the OK button.

Place cursor to the right of GRT >> Click on Instructions -> Insert Coil To the right of it insert a Coil.
Double-click on Ynew >> Type ‘heat’ in the name box >> Select ‘RESET-only’ in type >> Click OK button Rename the Coil as ‘heat’ and configure it as RESET-only Coil.
Place the cursor parallel to Yheat >> Click on Instructions -> Insert Coil Now, parallel to Yheat insert another Coil.
Double-click on Ynew >> Type ‘fan’ in the name box >> Select SET-only’ in type >> Click OK button Rename it as ‘fan’ and configure it as SET-only Coil.
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 Yheat, Yfan and Atemp in the I/O list We can observe initially the value of Atemp is 0 i.e less than 800.

So the state of Yheat is 0 and Yfan is 1.

Double click on Atemp in the I/O list Double-click on Atemp in the I/O list.
Highlight the value changer A slider bar appears.

We can change the ADC value by scrolling the pointer.

ADC reading 0 represents the minimum resistance value of the thermistor.

ADC reading 1023 represents the maximum resistance value of the thermistor.

Increase the value of Atemp

Highlight the states of Yheat and Yfan

Slowly increase the value of Atemp.

We can observe the states of Yheat and Yfan will be the same until it reaches 900.

Decrease the value of Atemp

Highlight the states of Yheat and Yfan

Once it goes above 900 the state of Yheat will be 1 and Yfan will be 0.

These states will be the same until the ADC value goes below 800.

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 Yfan in I/O list >> Select PC6 >> Click OK button

Double-click on Yheat in I/O list >> Select PC7 >> Click OK button

Assign pin PC6 to Yfan and PC7 to Yheat as shown.

And PC7 to Yheat.

Double-click on Atemp in I/O list >> Select PA7 >> Click OK button Double-click on Atemp in the I/O list.

I/O pin dialog box opens.

We can see there are only Port A pins as they are the ADC pins.

Select PA7 and click the OK button.

Click on Compile >> Click on Compile >> Go to Desktop/LDmicro folder >> Rename it as ‘adc.hex’ >> Click on Save.

Click OK button

Compile the logic as adc.hex
Click on File >> Click on Save >> Go to Desktop/LDmicro folder >> Rename it as ‘adc.ld’ >> Click on Save Then save the ladder diagram as adc.ld.
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:adc.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.

adc.png - connect as explained in the narration Let us see the connection details now.
adc.png - connect as explained in the narration Power the Heater module through relimate connectors from the Mainboard.

Connect pin PA7 of the Mainboard to temp MCU pin of the Heater module.

Connect pin PC7 of the Mainboard to heat MCU pin of the Heater module.

Connect pin PC6 of the Mainboard to fan MCU pin of the Heater module.

Make the connections as shown in the picture.

Turn on the power After making all the connections properly, turn on the power supply.
Point as explained in the narration Depending on the initial temperature either the fan or resistor starts heating up.

For the first time we can observe that Heaton LED is turned ON.

This is because its temperature of the heating element is low.

Point to FanOn LED After sometime when the resistor gets heated up, the fan will turn ON.

It is also indicated by FanOn LED.

Again when the resistor cools down, the resistor starts heating up.
Thus the process continues depending on the temperature of the resistor.
Note that initially the fan might turn on if the resistor is already heated up.
Turn off the power Turn off the power supply.
This brings us to the end of this tutorial.

Let us summarize.

Slide 8: Summary
  • A/D converter read instruction


In this tutorial we learnt about working of A/D converter read instruction.
Slide : Assignment

Change the limit values :

  • If ADC value < 750,

Output: fan is ON and heat is OFF

  • If ADC value > 950,

Output: fan is OFF and heat is ON

As an assignment, change the limit values and repeat the experiment.

If ADC value < 750, the fan should turn on and the heating element should turn off.

If ADC value > 950 , the fan should turn off and the heating element should turn on.

Slide 9:

About Spoken Tutorial project

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

Please download and watch it

Slide 10:

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

Forum for specific questions:

Please post your timed queries in this forum.
Slide 12:

Forum for specific questions:

Do you have any general / technical questions on OpenPLC?

Please visit the FOSSEE forum and post your question.

Slide 13:

Acknowledgement

Spoken Tutorial Project is funded by MHRD, Government of India.
Slide 14:

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