Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PWM for IR Proximity Sensor

Status
Not open for further replies.

varuntejavarma

Newbie level 5
Newbie level 5
Joined
May 31, 2014
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
96
Hello,
I have to build an Ir proximity sensor to detect any obstacle passing by. I have used TSOP 4856 sensor to detect the reflected ir signals. I have to generate Ir signals with carrier frequency at 56khz and also the 56 khz signals shouldn't be continous. ON OFF pulses of 56 khz signals should be generated. I have used two 555 timers for this purpose. one for generating 56 khz signal and other for the on off signals. THe ON pulse should be smaller than the OFF pulse(i.e., about 20- 30 % duty cycle) nad the ON pulse should contain min of 11 cycles of 56 khz signals. I have attached the picture of signal i got with the timers. But with timers, i could not achieve a desired range and have lot of problems with connections. So, i thouight of using a pic mcu for generating the pulses.

I have tried the PWM module of PIC18f4550 to generate 56 khz pulses and acheived a range of only 5 cms. Mybe its because i wasn't sending ON OFF pulses. But i do not know how to Make the 56 khz signal ON OFF at a particular freq. I am using XC8 compiler and ICD3 programmer. MY simple program for pwm is:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <xc.h>
#include <stdio.h>
#include <stdlib.h>
#pragma config FOSC = INTOSCIO_EC
#pragma config FCMEN = OFF
#pragma config BORV = 3
#pragma config WDT = OFF
#pragma config CPB = OFF
#pragma config CPD = OFF
void SetupClock()
{
OSCCONbits.IRCF0 = 1;
OSCCONbits.IRCF1 = 1;
OSCCONbits.IRCF2 = 1;
}
void main(void)
{
SetupClock();
TRISCbits.RC2=0;
PORTCbits.RC2=0;
PR2= 0b00100011;
T2CON = 0b00000100;
CCPR1L = 0b00010001;
CCP1CON = 0b00111100;
while(1);
}



I have just started working with microcontrollers and this is my first project with mcu. I am trying the method of learning by doing. So, It would be very helpfull if someone could tell me how to do the pulsing with microcontroller with some explanation (or a sample program) for a beginner (me).
 

Attachments

  • DSC_0987.jpg
    DSC_0987.jpg
    1.3 MB · Views: 57
Last edited:

Hey Var.

Your scope voltage indicates >20V pulses. Is that 2V? It should be 3 - 5V supply.

You can do this with a simple CMOS logic to generate clock and burst pulses with any duty cycle to conserve emitter power. Proximity threshold is dependant on many factors outside and inside your control.


IR surface reflection coefficient ...wide range 10 to 90% typ.
IR power: beam angle and current... Wide range from 6 to 60 deg and 20 to 150mA peak. So choose narrow and high peak, low duty cycle but fast rep rate , like 50 cycles On, 500 cycles off or whatever they suggest with 150mA current limiting R or use two in series ~1.5x2 on 3V with FET as series R.

The receiver has wide gain AGC so it should adjust gain from 1m to 30m range with good supply filter (good battery and low ESR cap) on both emitter and detector. If using coin cell, much lower duty cycle needs to be considered since it is >3k ESR. (NG)

Most important is your optical design. When no object, ther should be no signal. This requires narrow emitter beam and aperture hole on both emitter detector sides like a camera with stepped concentric circle cuts or long black tube (1cm) with recessed parts. Then aim at angle for desired scattering of light from object to detector. (Diffusion, not mirror like) this is most critical part of proximity distance control. For long distance, almost parallel, for short distance, use angles to decide. If you want to have wide viewing angle yet narrow detection, then you need multiple emitter detectors with narrow beam. Otherwise signals bounce off everthing. For even better performance alternate or use Johnson counter to drive up to 10 radial emitters one at a time and drive all receivers to look for coherence. iE. received burst after lag for AGC, occurs in same time slot , then object in that direction.

Since you have no control over distance threshold directly with slow rise times, you must use direction of beam reflection to detect direction of object.

Careful consideration of path loss in each step will get you up to 30 meter range, otherwise only 2m +/-1 for example.

image.jpg

I successfully used only photodiode and emitter diode for 1cm for example detecting black line on rotating electric meter disk to index power consumption in bright sunlight to detect black level. But you are looking for "grey level of unknown objects while if small might reflect less than large white background, so narrow beam is critical with many emitters.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top