PDA

View Full Version : Help with using TSOP1738 for line sensing using ATMEGA16



mohitkhanna3v_infinate
06-27-2008, 06:55 PM
Im using TSOP1738 and LED to detect difference in white and black line. Im trying to generate 38MHz frequency from Atmega16 using the Formula,

ORC0=((8000000)/38000)-1

where 8000000is the timer0 value. and 38000 is required frequency.

The LED is glowing but I dont have any device to confirm whether the produced frequency in correct or not. Im expecting that the TSOP1738 Voltage should go down if I bring the LED face to face ner it. But I dont Observe any kind of voltage variation in TSOP on bringing LED to any direction against TSOP even when touching, or far away. TSOp is just coutinously giving voltage of arnd 1.6 Volts without any variation.

My friend had tried it sometime back as well using TSOP1738 only, and yet he was also unable to do it. Is it some problem in frequency produced by Atmega16? or am I doing some other mistake?

PS> Im new to Robotics, so plz dont mind if im asking a silly question, but ive searched the forumns but cldnt get much help.

PS> Though I dont have problem using IC 555, but I would prefer using Atmega16 as manufactureres have provided in it the required feature, and Im not much keen in increasing my PCB size in using an extra IC.

mohitkhanna3v_infinate
06-27-2008, 06:57 PM
Sry, 1 mistake in typing....

In the formula above, its

((8000000/(2*38000)))-1

docel
06-28-2008, 12:03 AM
TSOP wont work for LFR. It is too sensitive and difficult to adjust at that height.

Check your OCR mode and the formula again.

mohitkhanna3v_infinate
06-28-2008, 12:39 AM
TSOP do work.... my friend did it, but he used IC555 for powering LED the required frequency. But I want to keep IC555 the last option. I want to do it via Atmega's internal frequency generator so as to save money as well as space.

Basic formula is right. Ive used: Frequency required= clock value / (2*OCR +1) , and have derived value of OCR from this keeping Frequency required =38khz, and Clock Value=8000kHz.

Im using CodeVision AVR

OCR mode is:

Timer 0
Clock Value: 8000 kHz
CTC Top=OCR0
Toggle on compare match

docel
06-28-2008, 08:18 AM
Well, why cant you post all the details in your first post??
It is your duty to let us know ALL the things you have done, BEFORE we solve your problem :!: You have been doing things without any understanding of the component. This will only lead to a lot of unnecessary problems.
Besides, you dont seem to understand what others tell you, too!!

1. The TSOP is working alright, if it is 1.6V at its output!
You cant see it because it is blinking at 38000 times per second ! It doesnt mean that the uC will read it.

2. If your friend made the line folllower using TSOPxxxx, then why not ask him , since he is an expert already??
In my opinion, TSOPs cannot be easily used for line following, more so with a 555 output.

It is time you guys stopped writing code first and trying it out on electronic components, of which you know little or nothing about.

mohitkhanna3v_infinate
06-28-2008, 04:42 PM
of course i know very less of components as yet, as im just a beginner.... but im trying to know them through the datasheets. Im sure you would had also been in my shoes sometime back when you were a beginner....

My friend is no expert either, but they use TSOP in dere college for line following , and thats where ive come to know of it. Dont you think that if TSOP are used then they would provide more accuracy because ambient light will have very less effect on its working.

Basicly thats the reason why I wanted to use TSOP. I might be wrong, but each wrong corrected could add to my proper knowledge.

shobhitkukreti
06-28-2008, 08:40 PM
Doc is right. TSOP1738 is too sensitive. Normally sensors are placed close to the surface where it has to detect black and white surface, so ambient light won't be that big a problem, untill you are planning to keep the sensors on height, which is not recomended

rao
06-29-2008, 12:53 AM
One thing I fail to understand is why do you want to use uC resources on running a TSOP rather than figuring out a good enough algorithm to make regular sensors or an array of regular sensors work better?

There is a lot to LFRs (well not that much, but still...) apart from the sensors... Instead of planning on what sensor to use, you could have spent time looking for a more efficient arrangement of sensors, better algorithms for line tracking, making a faster, smaller and powerful LFR.

Complexity might 'attract' people but in the end simplicity is what 'amazes' them.

And by the way, what is this obsession of yours with TSOP anyways. Is it only because your friend was able to make an LFR with TSOP that you want to stick to that one sensor and stop thinking about other aspects of LFR?? or just that you are intrigued by the awesome capabilities ( yeah, right) of TSOPs in the field of line following?

One final piece of wisdom. In the last 4 years of our functioning as an online Robotics Community, I have never come across an LFR that won prizes based on TSOP sensors. I am not asking you to stop your efforts, rather , I would be happy if you come up with a solution and post it here.


Rao

mohitkhanna3v_infinate
06-29-2008, 01:07 AM
thnx a lot! il definately try to keep my efforts on, and will also try for other techniques. Whatever I do, Il make its video n post it on youtube, n give its link here. and in case of further problems, il keep troubling you! :wink:

mohitkhanna3v_infinate
06-30-2008, 02:34 AM
Ive seen in some forumn here on roboticsindia a method of creating bursts. In it its said to create frequency using 1st 555 n then use 2nd 555 to create bursts by connecting it to the reset of 1st.

Is it not possible to create bursts using just 1 555? Im able to produce arnd 38kHz frequency, and TSOP is responding to it well for a few miliseconds. Not with continous signals. Reading the datasheet, and other Qs here, I feel its definately so due to lack of bursts. So all I need is to create bursts using same NE555

Im insisting on using same NE555 as ive just 1 NE555 at the moment and Market is closed tomorrow, so just wishing that I could do the sensor part of my project by tomorrow.

In case its not possible to do it using just 1 NE555, then please can you give me circuit diagram of producing bursts? And how would we define that after how many cycles we need burst and equvalen to how many cycles. As i read in some post here that we require approx 14 cycle burst after 10 cycles. I cant figure it out easily from the datasheet.

And can you explain me what exactly we mean by the term duty cycle.

sharad
07-01-2008, 12:35 AM
{The LED is glowing but I dont have any device to confirm whether the produced frequency in correct or not.}

i wonder!! if your digital multimeter has no frequency measurement option,
if it is there ,put the probes in series with with LED,
I did the same (measuring output frequency & adjusting the POT.),while generating 38kHz using IC555 .[/u]

silly
08-29-2008, 04:22 AM
Well to check whether your TSOP is working the best and the simplest way is to check it using your tv remote control ( Not Sony as they work on other frequency ). Steps to check.
1.TSOP is getting appropriate voltage ( +5v and GND ) on proper pin.
2.Point remote on TSOP keep pressed a buutton on remote.
3.Check voltage at output if it drops Voila.


There are many different TSOP available 1738 means it works on 38 freq 1739 , 1740 etc etc so do check you have the right one.

robo_mech
06-18-2011, 04:59 PM
Use a photo-transistor and a set of bright white LEDS?
only drawback would be ambient light. either put you array under the bot and mask the front, or use a color filter and colored LEDs


/*
Author : Jithinbp AT GMAIL.COM
Free and open code.. if you couldn't code this on your own,
I do believe you deserve a peek for free.

MOTOR control port is D
Right Motor : 1 forward, 2 backward
Left Motor : 4 forward, 8 backward

Photo sensor:
left = ADC 5
mid = ADC 4
right = ADC 3
*/

#include <inttypes.h>
#include <avr/io.h>


#define RM 100 // 40
#define MM 100 // 51
#define LM 150 // 127

typedef uint8_t u8;

void
delay(y)
{
volatile uint16_t x = y;
while(x--) ;
}


u8 adval(u8 ch)
{
ADMUX = BV(ADLAR) | ch;
ADCSRA = BV(ADEN) | BV(ADSC) | 7; // Low clock speed
while ( !(ADCSRA & (1<<ADIF)) ) ; // wait for ADC conversion
ADCSRA |= BV(ADIF);
return ADCH;
}

void fwd()
{
u8 x;
PORTD=5;
for(x=0;adval(4) > MM && x < 10;x++)
delay(500);
PORTD = 10;
delay(50);
PORTD=0;
}

void sharpright()
{
u8 x;
PORTD = 6;
for(x=0;adval(3) > RM && x < 10;x++)
delay(50);
PORTD = 0;
}

void sharpleft()
{
PORTD = 9;
u8 x;
for(x=0;adval(5) > LM && x < 10;x++)
delay(50);
PORTD = 0;
}

void right()
{
PORTD = 4;
delay(500);
PORTD = 0;
}

void left()
{
PORTD = 1;
delay(500);
PORTD = 0;
}


void reverse()
{
right();
left();
PORTD=10;
delay(5000);
PORTD=0;

}
int main (void)
{
u8 lt, mid, rt,started=0,turn=0,x=0;

DDRB = 0; // configure portB as in
DDRC = 0;
DDRD = 255; // PORTD 3 LSBs are outputs


ADCSRA = BV(ADEN);

for(;;)
{
lt = adval(5);
mid = adval(4);
rt = adval(3);

if(lt >LM && rt > RM && mid > MM) //on total black surface
{
if(turn==1)
sharpleft();
else if(turn==2)
sharpright();
else
continue;

x++;
if(x==3)x=0,turn=0;

}


if(lt < LM && rt < RM && mid < MM) //on total white surface
{
if(started==0)
continue;
}
if(lt > LM && rt >RM && mid < MM)
sharpleft(); //fork in the track -> take the left one . add a forward step maybe

else
if( lt > LM && mid > MM) //left realignment
left(),x=0,turn=0;
else
if( rt > RM && mid >MM) //right realignment
right(),x=0,turn=0;


else
if( lt > LM && mid < MM)
{
sharpleft();
turn=1;
} //sharp left bend
else
if( rt > RM && mid < MM) //sharp right bend
{
sharpright();
turn=2;
}


else
if( mid > MM )
{
fwd(); //move forward

started=1; //record that bot has started
}




}
return 0;
}

avinash_g
06-19-2011, 08:44 AM
TSOP wont work for LFR. It is too sensitive and difficult to adjust at that height.

To confirm this fact.

Pick up a remote control of your TV, a black paper, a white paper.

Fire the remote on black paper such that the paper reflects the IR Radiation to the sensor of TV (Note the result, i.e if TV responds or NOT)

Replace black paper with white paper and repeat the experiment.

The result is that TV Responds in all cases. This proves the above fact.

Now how your friend made that stuff. The thing is becasue your friend used NE555, whose frequency is adjusted by a variable resistor. So your friend adjusted it for optimal results of Line detection. The fact to be noted at that point the NE555 is NOT at- all producing 38KHz it must be gererating something like 32 or 42KHz. Since TSOP looses its sensitivity when the frequency deviates from 38KHz.

If you use MCU to generate perfect 38KHz TSOP will become TOO sensitive for Line detection purpose. It can bounce upto 3 or 4 times traveling up-to 40 feets and reach IR sensor from any side and trigger it.

Long back I read on RI how to use TSOP to make a very cheap IR rangefinder. I made that using AVR.



#include <avr/io.h>
#include <util/delay.h>

#include "lcd.h"

void delay()
{
char i;
for(i=0;i<6;i++)
_delay_loop_2(0);
}
void SetFrequency(long fq)
{

OCR1A=(F_CPU/(2*fq));
}
void DrawBar(uint8_t n)
{
LCDGotoXY(0,1);
uint8_t i;
for(i=0;i<n;i++)
{
LCDData('*');
}
}
void main()
{
uint16_t i;
uint8_t range,out_of_range,r1,r2;
TCCR1A|=(1<<COM1A0); //Toggle OC1A on compare match
TCCR1B|=(1<<WGM12)|(1<<CS10); //CRC Mode Prescalar=1

DDRB|=(1<<PB1); //Set OC1A Pin as output


InitLCD(LS_BLINK|LS_ULINE);
while(1)
{
for(i=44000,range=1,out_of_range=1;i<57000;i+=1000,range++)
{
SetFrequency(i);
_delay_ms(1);
r1=(PINB & 0b00000001);
_delay_ms(1);
r2=(PINB & 0b00000001);
if((!r1) & (!r2))
{
out_of_range=0;
break;
}
}
LCDClear();
LCDWriteString("Distance - ");
if(!out_of_range)
{
LCDWriteIntXY(14,0,range,2);
DrawBar(range);
}
else
{
LCDWriteStringXY(14,0,"XX");
LCDWriteStringXY(0,1,"Out of Range");
}
delay();


}


}


The target is ATmega8 @ 12MHz