Results 1 to 5 of 5

Thread: IR micromouse sensors

  1. #1

    Default IR micromouse sensors

    Hai
    I want to make distance sensors using IR LED as emitter and IR photodiode as the detector

    I connected a 300ohm resistance in series to LED and connected it to PORTC which is always high and connected the photodiode in reverse bias with a 10k in series and gave its signal from the junction of diode and resistor to the adc

    i made those values appear on the LCD
    i am getting random values wat i need to do now

    my requirement is just 3cm
    plz anyone help me out
    thanks in advance

  2. #2
    Senior Member Android
    Join Date
    Apr 2008
    Location
    jaipur
    Posts
    129

    Default

    post your circuit and code

  3. #3

    Default crude image plz donn mind

    hai here is my code

    /*----------------------------------------------------------------
    -----------------HEADER FILES-------------------------------------
    -----------------------------------------------------------------*/
    #include "lcd.c"
    #include "serial.c"
    #include "adc.c"

    /*----------------------------------------------------------------
    -----------------MAIN FUNCTION------------------------------------
    -----------------------------------------------------------------*/

    void main()
    {
    unsigned int i,j,a,b,k;
    unsigned char del[2]={0x08,0X08}; //for deleting previous reading

    //Lcd startups
    Init_Ports();
    Init_Lcd();

    //ADC startups
    Init_ADC();
    //Read_ADC(void)




    b=0;

    do
    {
    a=Read_ADC();
    if(a!=b)
    {
    //first delete the previous values for uart
    for(i=0;i<2;i++)
    {
    TransmitByte(del[i]);
    }

    //for LCD we require initialiatization
    Init_Lcd();
    for(i=0;i<12;i++)
    Lcd_Send(str[i]);




    j=a%10;

    k=a/10;
    k=k%10;
    Lcd_Send((k+0x30));
    TransmitByte((k+0x30));

    Lcd_Send((j+0x30)); //since both will display ASCII values, we convert decimal to ASCII
    TransmitByte((j+0x30));

    b=a; //for next value
    //delay sometime (1s) otherwise LCD display will run
    delay(1000);
    }

    }
    while(1);


    }
    void Init_ADC(void);
    int Read_ADC(void);




    void Init_ADC(void)
    {


    ADMUX|=(_BV(ADLAR) | _BV(REFS1)| _BV(REFS0)) ;
    // RFS1 and RFS0 are for Internal Reference voltage of 2.56V AND 8 BIT CONVERSION
    ADMUX&=~(_BV(MUX0)|_BV(MUX1)|_BV(MUX2)|_BV(MUX3)|_ BV(MUX4)); //SELECTING CHANNEL0
    ADCSRA|=(_BV(ADEN) | _BV(ADPS2) | _BV(ADPS0)) ; //normal conversion without interrupt
    ADCSRA&=~(_BV(ADSC)|_BV(ADATE)|_BV(ADIF)|_BV(ADIE) |_BV(ADPS1));//clock/32 speed

    }

    int Read_ADC(void)
    {
    ADCSRA|=_BV(ADSC); //start conversion
    while(!((ADCSRA&_BV(ADIF))>>ADIF));
    return ADCH;
    }


    [/img]

  4. #4

    Default

    *i didnt go through you code.

    How random are the values ?? There will be some minute error, due to electical conditions , power lines, adc precision etc... If the error level is not too much you should not worry.

    Another thing is have you properly isolated the led and the photodiode ? Is any stray light falling on the photodiode ?? You can get the correct reading only in a dark room.

    So ineffect this sensor is no gud unless u use it in place where there is no light , or u use some clever code.. :roll:

  5. #5
    Senior Member T-1000
    Join Date
    Mar 2005
    Location
    Bangalore
    Posts
    728
    Blog Entries
    7

    Default

    you are driving (sourcing) an IR led directly from the microcontroller. (you did not mention which) !!

    Always use a driver (a simple transistor) to drive an IR LED at high currents.

    Make sure the IR LED is glowing enough. use a mobile phone camera.

    Connect a pot to the ADC, and rotate the POT and see if the adc values are correct. IF not, correct it.


    that will solve it.
    .... I didnt do it ! ....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •