Discussion in "Electronics" started by    akashbudhia    Nov 1, 2010.
Mon Nov 01 2010, 12:08 pm
#1
I need to count visitors using AT89C51. The sensor i got from the market has SM0038 printed on it.Kindly answer the following questions:

1. Is SM0038 same as TSOP 1738?

2. SM0038 senses 38kHz IR, right?(this is what is felt from the 38 at the end of sm0038)

3. For achieving 38kHz frequency at IR LED, i planned to use my AT89C51 itself, rather than 555 timers. This is the code i have written as of now:

ORG 0
LJMP MAIN
ORG 000BH
CPL P1.2;INPUT LINE FOR THE IR-LED
RETI
ORG 0100H
MAIN:
MOV IE,#10000010;TIMER-0 INTERRUPT ENABLE
MOV TMOD,#00000010B ; TIMER-0, MODE 2
MOV TH0,#F4H ;FOR f=38kHz =>
 T=0.026ms =>
 0.013ms TIMER =>
 F4
SETB TR0; START THE TIMER
HERE:SJMP HERE


As evident from datasheet of TL17xx above should not work because it will generate CONTINUOUS pulse of IR at 38kHz rather than BURSTS of square wave with gaps.

Now for the bursts and gaps what should be appropriate number of cycles to achieve Visitor Count?

Another doubt, my projects key concept is that the IR is blocked when a visitor is there and TSOP should go high, but on other side we give cycles(high and low alternatively during bursts, and low during gaps) of IR, won't the low states of IR be counted as visitor.

Or is it that when a visitor is passing, absence of IR rays on TSOP for such a long time only makes it high and during the remaining time TSOP will remain low, although pulses of IR is being sent.

4. There' no library in Proteus for IR LED and TSOP! How do i simulate it?

5. Will the following circuit work fine:



Mon Nov 01 2010, 12:16 pm
#2
Hey sorry, by mistake i posted the thread in the news and announcements column.
Can the admin move it to the apt. cateogry.
Actually it's my first visit to the forum.
Mon Nov 01 2010, 01:21 pm
#3
hi akashbudhia

Is SM0038 same as TSOP 1738?


yes it is same in pin configuration

SM0038 senses 38kHz IR, right?(this is what is felt from the 38 at the end of sm0038)


yes it sense 38 khz frequency
code is as
ORG 0000H
LJMP MAIN
ORG 000BH
CPL P1.2;INPUT LINE FOR THE IR-LED
RETI
MAIN:
MOV IE,#10000010b ;TIMER-0 INTERRUPT ENABLE
MOV TMOD,#00000010B ; TIMER-0, MODE 2
MOV TH0,#0F4H ;FOR f=38kHz =>
 T=0.026ms =>
 0.013ms TIMER =>
 F4
MOV TL0,#0F4H
SETB TR0; START THE TIMER
HERE:SJMP HERE
END

As evident from datasheet of TL17xx above should not work because it will generate CONTINUOUS pulse of IR at 38kHz rather than BURSTS of square wave with gaps.

Now for the bursts and gaps what should be appropriate number of cycles to achieve Visitor Count?


this type of configuration u used it is normally used in sending and receiving digital data in the form of zero and one
see this link too
http://www.rentron.com/Infrared_Communication.htm
see these links
http://www.ikalogic.com/ir_prox_sensors.php
http://www.ikalogic.com/ir_prox_sensors_40khz.php
see this site on the same projects threads
http://www.8051projects.net/forum-t37642.html

There' no library in Proteus for IR LED and TSOP! How do i simulate it?


proteus has no such library u can check ur logic in coding using bush button instead of ir reciever

Will the following circuit work fine:


its ans is just try and has good hope that it will work prefer to use 74hc132 diagram as in the first link i provide

Can the admin move it to the apt. cateogry.


yes admin move it in appropriate place
if u want to use just an interrupt u can use other circuits too
i has one circuit that i use often when i just need interruption thats range is 1.5 to 2 meter almost when completely align if u need then u can update here
Mon Nov 01 2010, 08:25 pm
#4
hi akashbudhia
here r the circuit that can be used in interrupt method when ir beam is cut relay turn on otherwise it will be off its range is almost 1.5 to 2 meter i used it
diagram r in live wire software as well as in jpg format too
to check it in live wire software u can download from here

1) http://ifile.it/a0tpecf
2) http://ifile.it/a0tpecf/Livewire%201.11.rar
Wed Nov 03 2010, 12:58 pm
#5
Thanks a lot for your reply.

With respect to the datasheet available here, i am using the following code to generate bursts of 20 cycles(R3=40) and then a gap of length 25 cycles(R2=50) at the LED connected to P1.2.

The code also is counting up (fm 0 to 9 and back to 0 if more) on a common anode 7-segment display connected to port P2 whenever TSOP goes high(in absence of IR, i.e a visitor)

ORG 0000H
LJMP MAIN
ORG 000BH
CJNE R3,#0,DOWN
DEC R2; WHEN R3=0
CLR P1.2
CJNE R2,#0,DOWN1
MOV R3,#40
MOV R2,#50
RETI
DOWN1:
RETI
DOWN:
CPL P1.2;INPUT LINE FOR THE IR-LED
DEC R3
RETI
ORG 0100H
MAIN:
MOV 30H,#0C0H; values for 7-seg display 0 to 9
MOV 31H,#0F9H
MOV 32H,#0A4H
MOV 33H,#0B0H
MOV 34H,#99H
MOV 35H,#92H
MOV 36H,#82H
MOV 37H,#0F8H
MOV 38H,#80H
MOV 39H,#98H
MOV 3AH,#00H; 0 for identifying the terminating condition
MOV R0,#30H; counter starting from 0
MOV A,R0
MOV P2,A; displaying 0 on the 7-seg
SETB P1.0; TSOP O/P to P1.0, configured as I/P pin
MOV IE,#10000010B;TIMER-0 INTERRUPT ENABLE
MOV TMOD,#00000010B ; TIMER-0, MODE 2
MOV TH0,#0F4H ;FOR f=38kHz =>
 T=0.026ms =>
 0.013ms TIMER =>
 F4
MOV TL0,#0F4H
MOV R3,#40; bursts of 20 cycles 
MOV R2,#50; gap of 25 cycles
SETB TR0; START THE TIMER
WAIT:JNB P1.0, WAIT; can skip the following, for counting up on detection
LCALL COUNTUP
LCALL DELAY
SJMP WAIT
	`
COUNTUP:
INC R0
MOV A,@R0
JNZ DISP
MOV R0,#30H
MOV A,@R0
DISP:
MOV P2,A
RET

DELAY:
MOV R4,#0FFH
DELAY2: MOV R5,#0FFH
DELAY1: DJNZ R5,DELAY1
	DJNZ R4,DELAY2
RET
END


Kindly verify whether the code is perfect for the IR LED transmitter for getting detected at TSOP 1738?

May ignore the 7-segment part(COUNT UP method and DELAY method).

As for now i am concentrating on the sensor part, but TSOP's Vout goes low(approx 2.2V) only for a second or two,on RESET of AT89C51 and remains 4.8V for remaining time.

Following is the TSOP's requirement from the datasheet
Wed Nov 03 2010, 02:10 pm
#6
hi akashbudhia
it cannot be said that code is perfect or not
check it on hardware that will be better answer
ru check voltage with meter if yes then it show almost 3,1.8,3.9 etc not zero becoz zer0 and 1 comes so fast and meter is slow

generate a 36 or 38 khz according to sensor using 8051 and sena a byte 8 to 10 times to some pin use 74hc132 for mixing both and then drive led and see results
Wed Nov 03 2010, 03:14 pm
#7
hi budhia,
it is much easier if u will use an IR sensor circuit to trigger the input of the controller. Ur code is easy to0 bcoz u will only monitor the output of the iR sensor circuit wether 0 or 1 logic.
Here how 8 works.
When IR beam is interrupted the IR sensor sends logic 0 to the controller and it counts then display every event of interruption.
Just make a code of that.
hope 8 helps.


[ Edited Wed Nov 03 2010, 03:20 pm ]
Sun Nov 14 2010, 06:44 am
#8
As you said i have been working on the hardware since so many days. But the code i have posted is not giving the expected output.

First i will explain my code:
I am generating 38kHz square bursts with 20 cycles/bursts.
Alternatively i am keeping it low for 25 cycles.

In absence of IR LED TSOP's output voltage is 4.9 V.
In presence of IR LED the output voltage of TSOP is dropping, but it is around 4.4 V (which should be around 0V as per datasheets).

Please read my code(I know it's painful, I will optimize it for you):

ORG 0000H
LJMP MAIN
ORG 000BH
CJNE R3,#0,DOWN
DEC R2; WHEN R3=0
CLR P1.2
CJNE R2,#0,DOWN1
MOV R3,#40
MOV R2,#50
RETI
DOWN1:
RETI
DOWN:
CPL P1.2;INPUT LINE FOR THE IR-LED
DEC R3
RETI
ORG 0100H
MAIN:
MOV IE,#10000010B;TIMER-0 INTERRUPT ENABLE
MOV TMOD,#00000010B ; TIMER-0, MODE 2
MOV TH0,#0F4H ;FOR f=38kHz =>
 T=0.026ms =>
 0.013ms TIMER =>
 F4
MOV TL0,#0F4H
MOV R3,#40; bursts of 20 cycles
MOV R2,#50; gap of 25 cycles
SETB TR0; START THE TIMER
WAIT:SJMP WAIT
Tue Nov 16 2010, 02:19 pm
#9
Hi again.. well sorry I dont know assembly hehe I only know C programming.. hehe lets wait for the others..
Tue Nov 16 2010, 08:49 pm
#10
@Akash
the code looks fine though you could reduce the gap from 25 to ~15 cycles as per the datasheet (which says "atleast 14 cycles")..

are you using the ckt from the 1st post?
how did you arrive at the resistor values?
with the 10k collector resistor,you get only ~0.4 mA drive current for the IR led... needless to say it is toooooo low.
so change the resistor to ~100 ohms for ~40mA current.If you find the range is not adequate decrease the value further to ~82 or 68 ohms... consult your IR led's datasheet for max. peak current rating.

also put the the ir led in series with the collector....

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Michailqfh
Fri Mar 29 2024, 01:53 am
Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm