1. 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.
    Dismiss Notice

anemometer interface with AVR

Discussion in 'AVR' started by naz83, Jul 13, 2010.

  1. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,189
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi naz,
    Screenshot as requested.
     

    Attached Files:

    Last edited: Aug 25, 2010
  2. naz83

    naz83 New Member

    Joined:
    Jun 29, 2010
    Messages:
    59
    Likes:
    0
    Location:
    uk
    simulation results

    Hi Eric,

    I have attched the simulation results using two different values of resistors... plz do comment as to what you think of the circuit..

    Thank u for the screenshot of the file, could u also plz post the screen shot of the graph for the same pt1000 circuit...

    Thanks
     

    Attached Files:

  3. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,189
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi naz,
    The doc file you have posted is the same as the other day,?? it dosnt work.

    EDIT:
    Try to simulate this option.
     

    Attached Files:

  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. naz83

    naz83 New Member

    Joined:
    Jun 29, 2010
    Messages:
    59
    Likes:
    0
    Location:
    uk

    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
     
  6. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,189
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi naz.
    Can you post the program code that you have already written.?
     
  7. naz83

    naz83 New Member

    Joined:
    Jun 29, 2010
    Messages:
    59
    Likes:
    0
    Location:
    uk
    hi Eric

    The code is as shown below... even though it compiles fine it does not display anything on the lcd... I am not sure of the functions used to write to LCD and the library used as this is new to me...

    #include <avr/io.h>
    #include "lcd_lib.h"
    #include <util/delay.h>
    void init(void)
    {
    LCDinit(); //initialises LCD
    LCDGotoXY(0, 0); //Cursor Home

    }
    void delay1s(void)
    {
    uint8_t i;
    for(i=0;i<100;i++)
    {
    _delay_ms(10);
    }
    }
    int main (void)
    {
    int buffer[7];
    int num ;
    init ();


    DDRB |= (1 << 2); // Set LED1 as output
    DDRC = (1 << 0); // Set LED2 as output

    ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); // Set ADC prescalar
    ADMUX |= (1 << REFS0) | (1 << REFS1); // Set ADC reference to 2.56V
    ADMUX |= (1 << ADLAR); // Left adjust ADC result

    // No MUX values needed to be changed to use ADC0

    ADCSRA |= (1 << ADATE); // Set ADC to Free-Running Mode
    ADCSRA |= (1 << ADEN); // Enable ADC
    ADCSRA |= (1 << ADSC); // Start A2D Conversions
    for(; ;) // Loop Forever
    {
    ADCH = num ; // convert integer into string
    Itoa ( num , buffer, 10);
    Printf ("The velocity is");
    Printf ("%d", ADCH);

    if(ADCH < 128)
    {
    PORTB|= (1 << 2); // Turn on LED1
    PORTC &= ~(1 << 0); // Turn off LED2
    }

    else
    {
    PORTB &= ~(1 << 2); // Turn off LED1
    PORTC|= (1 << 0); // Turn on LED2
    }
    }
    delay1s();
    delay1s();
    }


    The code above is written to perform the analogue to digital conversion and for the display on the LCD. The first part of the code is to initialise the LCD for it to be ready to display. Then the ADC is initialised by setting the various bits of the ADCSRA register and ADMUX register. The result is left adjusted to read only the eight bits of the register. Only eight bits of the ADC is used so the resolution is only 256 bits. I have set port B and Port D LEDs just to indicate if the value contained in ADCH is above 128 or below 128.
     
  8. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,189
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi naz,
    I dont do 'C' sorry,
    If you post the hex file I can run that.
     
  9. wkrug

    wkrug Active Member

    Joined:
    May 30, 2010
    Messages:
    271
    Likes:
    29
    Location:
    Germany
    The Code can't run, because there is a hardware problem.

    You write you are using the reference of the A/D Converter of 2.56V.
    The measured Voltage must been lower then 2.56V.
    All higher voltages will be shown as 0xFF.

    You could insert an resistor divider that divides the sensor Voltage by 2.

    I won't use the ADLAR Bit. You have a resolution of 8Bit ( 256 Steps ) only.
    The A/D Converter has an full resolution of 10Bit ( 1024 Steps ).
    The results has lower steps when using 10Bit.

    In 10 Bit resoluten one Step has an voltage increasing of 2.5mV ( 2,56V/1024 ).
    75mV ( 1m/s; 150mV/2 ) generates 30 Steps.
    A Voltage of 1.44V ( 2,88 /2 ) generates an A/D Output value of 576.

    OK i try to built a Speed formula with an 10 Bit A/D Converter.
    if(AD_Result>576)
    {
    Speed= ((AD_Result-576)*10)/30; /*Speed must been divided by 10 finally. First Subtract Zero Voltage Value from AD_Result.
    Then multiply by 10 to get one Number after Point. Then Divide by 30 to get real wind speed Values*/
    }
    else
    {
    Speed=0; //Avoid negative Results
    };
    /* Now you only have to format the Result */
    speedl=Speed%10; //Get the Number after point
    speedh=Speed/10; //Get the Numbers before point
    itoa(speedh,string);
    lcd_puts(string);
    lcd_putsf(".");
    itoa(speedl,string);
    lcd_puts(string);
    lcd_putsf(" m/s");

    I'll hope I've calculated right...
     
    Last edited: Sep 2, 2010

Share This Page