Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

AVR programming help with ADC and display

Status
Not open for further replies.

naz83

New Member
Hello,

I am new to AVR and so have a few questions about programming it. its an 8 bit avr kit. I need to take the voltage output from the analog circuit and convert it to ADC and then display it using LCD. the input is in volts and the output on the lcd should be displayed in m/s. the ADC is 10 bit.

do i need to write and feed any look up table for all possible values or how do i go about it. i just need to use one channel on the ADC.

could someone please help me as to how to go about programming for the ADC and also to get the display..

Thanks
 
hi naz,
Pleased to see you are making progress with anemometer project.

What the Min and Max mtr/sec of airflow that you want to display.? and what are the voltage levels that represent the min/max
 
What the Min and Max mtr/sec of airflow that you want to display.? and what are the v

I have used 2 ptr1000 and have made 2 anemometers n a simple bridge arrangement, and one s used as sensor and the other as a reference, the output from these two is given to a diff amplifier, so as of now the diff amp output at no airflow = 0.01v and depending on air flow it goes up to 2.5v,
o/p of 1st anemometer is 3.95v at no air flow and decreases when air s blown over it
o/p of 2nd anemometer is 3.94v at no air flow and stays at that temp

I still am not able to caliberate it as i wasnt able to get some Air of a known velocity, however i am planning to set the ref of diff amp as 0.5v so that an air blown over will increase the voltage of the diff amp from 0,5v upwards.. i cant caliberate it for 2/3 weeks so i am going ahead with the ADC/LCD display on AVR and then will get everything together.............

Plz do help me as to how to get about further as i am new to AVR

Thanks
 
What kind of LCD you'll use ?
The easiest way is, to use a DOT MARIX LCD with internal controller ( HD44780 ).
Most IDE has an library to drive this kind of displays.
The most popular are 2x16 character displays.

Measurement:
You should create a formula to convert the A/D results into wind speed.
e.g. wind=(a_d*345)/678;
The result should be factored by 10 of the real result.
So you can insert an comma ( point ) later very easaly.

output=result/10; // calculates the whole numbers
// Then insert a "."
output2=result%10; // calculates the number after the dot.

When it is not possible to create a formula for the whole measuring range ( because nonlinearity ), you can split it in different formula's that will be calculated dependent of the A/D result.
e.g.
if (result>100 && result<201)
{
// formula 1
}
if (result>200 && result<301)
{
// formula 2
}...
That will be shorter than a look up table for 1024 results.
 
Last edited:
What kind of LCD you'll use ?

I will be using the LCD that is present in the AVR kit, i dont really know what kind it is.
The AVR kit had ADC, oscillator, LCD, LED etc so i have to use that, its an 8 bit avr kit from micro electronics.

Thanks
 

Attachments

  • AAesp03.gif
    AAesp03.gif
    101.1 KB · Views: 519
OK i think thats clear now.

Look into the help topics of your compiler.
There should be found LCD FUNCTIONS.

A short "C" description
You have to include the according LCD include file.
#include <lcd???.h>
In most compilers must be defined the connection / port between the AVR an the LCD
#define LDCDATA4 PORTB.4
#define LCDDATA5 PORTB....

The next step is to init the LCD in the main routine
lcd_init();

Now you can use the LCD Functions.
lcd_gotoxy(0,2);
lcd_putsf("Text");

The includes, comands and definitions can vary of this "C" description.
It depends of the included LCD file.
The right ones could be found in the help topics of your compiler / include file.

When you'll using assembler, you can search for an display routine in the internet.
AVR Studio ( assembler ) has no LCD routines included.
 
HD44780 Hitachi Controller

Hi Eric,

Thanks, it is the hitachi controller HD44780 and it is exactly what i have to use...

Wkrug,
Thanks for your help, i will try out what you have told me...
 
Soldering pt1000 problems

Hi all,
My anemometer works fine with pt1000, but when i soldered pt1000 so that it can be mounted on a probe it has stopped working as a sensor anymore, i don know if we can solder a pt1000 or not? any suggestions and also any idea as to how to mount the sensor as the pt1000 is very fragile.
Thanks
 
Hi
could you please help me with this part of the coding...

my initial value is 2.88v that should display 0 m/s i.e the velocity.. and for every 0.15v increase in voltage thereby should increase the velocity by 1m/s..

Please do help me as to how to include this in my code and perform the above function..

Thanks
 
You don't get real Voltages, you'll get A/D Conversation Results.

What is your reference Voltage? 2.56V, 5V or what else?

In princip is that a math calculation.
You should compute best with whole numbers.

e.g. 1V = value 100.

First subtract the Start Voltage,

Voltage = Measured Voltage - 288

No multiply with 100/15 = 6.67
The easyest way to do that is to multiply by 20 and then divide by 3

Voltage = Voltage * 20
Voltage = Voltage / 3 = Speed multiplyed by 100

Example

Measured Voltage = 3.22V
322-288=34
34*20/3=227
So Wind speed is 2.27m/s

The whole calculation is possible with integers that increases speed, in opposite of floats.
 
Status
Not open for further replies.

Latest threads

Back
Top