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.

coding using pic 16f877a with tsop4p38(proximity sensor)

Status
Not open for further replies.

ripingz

New Member
i have problem coding with using tsop4p38 as an receiver. and the transmitter will be put on the back of the user . the transmitter will produce 38khz. i have studied its data sheet where the closer the receiver with the transmitter. the bigger the length of the pulse.i want to make the motor stop while the receiver and transmitter is 30 cm between. as if the distance is more than that.the motor will move. but how im about to coding it. especially the condition coding i mentioned.concluded my trolley follows the user...can anyone help me please~ or give me an example of its coding:confused::confused::confused:
 
Last edited:
From my reading of the datasheet, simple 38KHz transmitter modulation isn't going to work.

View attachment 61214
Please give more information abut your circuit and the transmitter modulation you are using. I assume you are using the 16F877 to perform that function. If so, include the code.

John
 
Last edited:
From my reading of the datasheet, simple 38KHz transmitter modulation isn't going to work.

View attachment 61214
Please give more information abut your circuit and the transmitter modulation you are using. I assume you are using the 16F877 to perform that function. If so, include the code.

John
View attachment 61232 this is transmitter ... and then the receiver will be construted as in the labsheet data of the tsop4p38. and the output will attenuate two motor power window using this motor driver circuitView attachment 61233.. and now if u all can see....can this circuit make my applications works? im using about 3 tsop 4p38 to make sure it more acccurate from 1 direction of the transmitter. 3 tsop4p38 using about 3 analog input right? thats why i dont use the 16f877(which before i want to use it)

i have learn c++ languange. but i dont know how to make the microchip to read in analog signal..which means the conditions of...but in digital.. it is more easier to make on program

i should do this semester project with my partner. but she got expelled as she got discipline problem. i dont know how to make it works anymore... im in dead line.
 
Last edited:
You might check one of my old websites?



Note it used an OTP 12C508 PIC, as it predates F series 8 pin devices.

View attachment 61234

the receiver will detect the ir transmitter signal which is 38khz. by the pulse difference...it will make a distance comparison. for example . the pulse is more than 30 khz . the motor a and b will stop which in logic '0' both of it . but if the pulse is less than 30 khz then both of motor will move forward which is logic '1' both of it. but if not signal detected. one of the motor will stay in logic '0' and the other motor will be in logic '1' to make it turning until it get the signal..... ur circuit given is tx/rx board combined together right? but my transmitter will be separated and will be put on the back of user(human). how can i modified ur circuit....are my circuit given are not compatible... i just want to make it forward and turning only...not make it too much perfect...i dont have time anymore...really need help
 
Last edited:
A single 555 chip will not make the pulsed 38 KHz signal you need. That can be easily done with an MCU or use a second 555 to pulse the one set at 38 KHz on and off. The pulse pattern you need is explained well in the datasheet.


As for detection, I can't code in C. In Assembly, you would look for the beginning of the pulse and either start a timer or start counting delay loops (basically the same thing), then stop the process at the end of the pulse and see what you got. An alternative approach of measuring simply the percentage of time the pulse is on in a set period sufficient for several pulses will also work, but your response might be two slow, if the pulse rate is relatively slow.

An analog approach might use a pulse width to voltage converter. Loop up integrator.

John
 
Last edited:
A single 555 chip will not make the pulsed 38 KHz signal you need. That can be easily done with an MCU or use a second 555 to pulse the one set at 38 KHz on and off. The pulse pattern you need is explained well in the datasheet.


As for detection, I can't code in C. In Assembly, you would look for the beginning of the pulse and either start a timer or start counting delay loops (basically the same thing), then stop the process at the end of the pulse and see what you got. An alternative approach of measuring simply the percentage of time the pulse is on in a set period sufficient for several pulses will also work, but your response might be two slow, if the pulse rate is relatively slow.

An analog approach might use a pulse width to voltage converter. Loop up integrator.

John

so my transmitter circuit is not compatible right...so what do i have change the component in the circuit...why cant code in c+++..are u expert in machine languange...it is very hard to understand machine language
 
Last edited:
Deleted. Duplicate. I grabbed the wrong link for the image.

John
 
Last edited:
I don't know C++ and have never tried to learn it. I am just beginning with Assembly for Microchip products (MPAsm). I am not an expert in any language; although, I can communicate in English well enough not to starve.

Here is one example of what I meant by using one 555 to modulate another to give a pulsed sequence of 38 KHz packets. There are many other examples on the Internet.

ired-osillator-png.58814


John
 
Deleted. Duplicate. I grabbed the wrong link for the image.

John

the circuit u gave can use it???? for transmitter?? compatible with the receiver tsop 4p38?also are the receiver tsop4p38 are simple as in the lab sheet; jus need an capacitor and resistor and just connect it to the microchip?
 
Last edited:
I don't know C++ and have never tried to learn it. I am just beginning with Assembly for Microchip products (MPAsm). I am not an expert in any language; although, I can communicate in English well enough not to starve.

Here is one example of what I meant by using one 555 to modulate another to give a pulsed sequence of 38 KHz packets. There are many other examples on the Internet.

ired-osillator-png.58814


John

can i use this circuit for my transmitter....?? do i need modification in this circuit???
 
The TSOP4P38 is different from the digital TSOP receivers in that it utilizes suppression of sensitivity (i.e., AGC) of the detector to produce a signal that can be related to the strength of reflection and hence distance.
Source: Datasheet

Such a sensor is evaluating the time required by the AGC to suppress a quasi continuous signal. The time required to suppress such a signal is longer when the signal is strong than when the signal is weak, resulting in a pulse length corresponding to the distance of an object from the sensor.

The schematic I posted is an example of how to use one 555 to modulate the 38 KHz produced by another. In that example, the 38 KHz is produced by IC1A. The modulation is by IC1B. The modulation frequency I used was about 800 Hz, and the duty cycle was about 50%. For the TSOP4P38, you need to use a frequency of about 2 Hz and a duty cycle of 24% (as shown in the example posted above). I suspect the 24% duty cycle is not critical, but it is important to use a low frequency, so the AGC will kick in and reduce gain.

I suggest that you design the transmitter first. You might want to use an MCU to do that, since your project seems to be MCU-based. If you prefer to use just 555's, get a circuit for 38 KHz, which you have. Then get a circuit for 2 Hz with a duty cycle that can be adjusted to less than 50%. There are various ways to do that. I prefer to use diodes to bypass resistors in the charge/discharge part of the circuit. Paisley has suitable circuits on his site:
**broken link removed**

Finally, use the 2 Hz oscillator to modulate the 38 Khz oscillator as in the schematic I posted above. If you have access to an oscilloscope, it will help immensely in getting the timing right.

John
 
Last edited:
The TSOP4P38 is different from the digital TSOP receivers in that it utilizes suppression of sensitivity (i.e., AGC) of the detector to produce a signal that can be related to the strength of reflection and hence distance.


The schematic I posted is an example of how to use one 555 to modulate the 38 KHz produced by another. In that example, the 38 KHz is produced by IC1A. The modulation is by IC1B. The modulation frequency I used was about 800 Hz, and the duty cycle was about 50%. For the TSOP4P38, you need to use a frequency of about 2 Hz and a duty cycle of 24% (as shown in the example posted above). I suspect the 24% duty cycle is not critical, but it is important to use a low frequency, so the AGC will kick in and reduce gain.

I suggest that you design the transmitter first. You might want to use an MCU to do that, since your project seems to be MCU-based. If you prefer to use just 555's, get a circuit for 38 KHz, which you have. Then get a circuit for 2 Hz with a duty cycle that can be adjusted to less than 50%. There are various ways to do that. I prefer to use diodes to bypass resistors in the charge/discharge part of the circuit. Paisley has suitable circuits on his site:
**broken link removed**

Finally, use the 2 Hz oscillator to modulate the 38 Khz oscillator as in the schematic I posted above. If you have access to an oscilloscope, it will help immensely in getting the timing right.

John

so my circuit transmitter that i had can be used but a little modification right? with adding one more timer....plus with the 2hz oscillator component....so how to modifide the circuit using the component i just mentioned@you just mentioned...can u show me the real transmitter circuit that can compatible with the receiver....im weak in electronic....if i just keep google. im still get the wrong circuit for my transmitter
 
I slightly modified the circuit to use separate 555's and simulated it. The green trace is the output from the slow oscillator at about 2.27 Hz and a duty cycle of 26%. You only see the tops of the cycles. The blue trace is the 38 KHz oscillator. It appears solid on this time scale. It measured only 36 KHz. You will have to adjust R2 or C3 to get 38Khz.

John

View attachment 61239View attachment 61240
 
I slightly modified the circuit to use separate 555's and simulated it. The green trace is the output from the slow oscillator at about 2.27 Hz and a duty cycle of 26%. You only see the tops of the cycles. The blue trace is the 38 KHz oscillator. It appears solid on this time scale. It measured only 36 KHz. You will have to adjust R2 or C3 to get 38Khz.

John

View attachment 61239View attachment 61240

ok now then...i must adjust the r2 and c3 only right??? how about the other resistor and capacitor??? to get the 38khz output....how about the oscillator...u said that ur circuit got 2.27 hz oscillator and the duty cycle is 26 %...can this kind frequency of oscillator and duty cycle will compatible the receiver
 
Last edited:
I slightly modified the circuit to use separate 555's and simulated it. The green trace is the output from the slow oscillator at about 2.27 Hz and a duty cycle of 26%. You only see the tops of the cycles. The blue trace is the 38 KHz oscillator. It appears solid on this time scale. It measured only 36 KHz. You will have to adjust R2 or C3 to get 38Khz.

John

View attachment 61239View attachment 61240

ur very kind person man...u help me a lot a lot !!! a lot thx to u
 
Hi ripingz,

I just found we can upload asc (simulator files). So I have attached my file to this reply. I have modified the components on the higher frequency oscillator to give approximately 38 KHz with 50% duty cycle. Only one resistor is non-standard, and that can be made by a parallel combination of two, 5% resistors.

John

View attachment 61249
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top