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.

PWM for IR Proximity sensor

Status
Not open for further replies.

varuntejavarma

New Member
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:

#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 this with some explanation for a beginner (me). :)
 

Attachments

  • DSC_0987.jpg
    DSC_0987.jpg
    1.3 MB · Views: 176
Since the on pulse must be shorter than the off pulse, we would be generating a square wave with a less than 50% duty cycle. What is the time duration of the on pulse and the off pulse?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top