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.

[MOVED] circuit related questions

Status
Not open for further replies.
Code:
while(1)
{
generate_square(); // in 38 khz
delay_ms(120);
output_low();        // IR led in Off state
delay_ms(380);      // 380+120 = 500ms period
}

- - - Updated - - -

use this procedure to generate square wave...


Now look at the recevier output oFF time that matters with distance.....


that can be found easily

- - - Updated - - -

Code:
while(1)
{
for( i = 0 ; recieve == 0; i++) // Count for number of ms the output is low
delay_ms(1);                        // i is the distance ouput  may be for 1m i = 75; 1.5m i = 25;

while(recieve == 1);
}

- - - Updated - - -

They are not meant to change the duty cycle, They are meant to set a constant square wave for some time.....
 

generate_square() <<< mean write the PR2=131 inside??

output_low() <<< mean if my IR LED connected to RC2, write a function to turn off RC2?


void output_low(void){

RC2=0;
}

then write output_low() in the main code is it?

can you combine those code? is that 2 while (1) or?
 

timing.JPG I think you will gt it....................
 

i think i get it already,haha,thanks,i will try and let you know the result.

by the way,what's wrong with the apr9600 ? when i connect to +5v it is nothing....zzz...i soldered it in copper strip board..
 

this is how i connect the sensor part, the voltage i measure through multimeter when ir led on is about the same with the input voltage, which is 4.98v, what happen...

and i connect the cathode of ir led to the collector of transistor(2N2222A), then anode connect to the power supply with 68ohm resistor, when i measure the voltage at anode,it gives about 5v, but if i connect the cathode directly to ground,i get 1.4-1.5v which is inside the operating voltage. and i measure the wave on pin RC2(if i using software pwm,i must feed the signal to anode through RC2 right?) i get the attached waveform which is quite weird...please help -.-

and according to the datasheet of tssp4p38, the operating current is 700uA , so i have to connect a resistor about 7k ohm to the input voltage side?this is why it couldn't work?

previously i connected 10k,and in the attached circuit i connect only 220ohm, since in the datasheet it mention connect 100 ohm(tried) and 0.1uf to increase the robustness.
the datasheet is for tssp6p38 which previously i'm using,now change to this, i see the different only on the type(tssp6p38=SMD, tssp4p38=through hole)

Code:
while(1)
{
generate_square(); // in 38 khz
delay_ms(120);
output_low();        // IR led in Off state
delay_ms(380);      // 380+120 = 500ms period
}

- - - Updated - - -

use this procedure to generate square wave...


Now look at the recevier output oFF time that matters with distance.....


that can be found easily

- - - Updated - - -

Code:
while(1)
{
for( i = 0 ; recieve == 0; i++) // Count for number of ms the output is low
delay_ms(1);                        // i is the distance ouput  may be for 1m i = 75; 1.5m i = 25;

while(recieve == 1);
}

- - - Updated - - -

They are not meant to change the duty cycle, They are meant to set a constant square wave for some time.....



for this, while(1)
{
for( i = 0 ; recieve == 0; i++) // Count for number of ms the output is low
delay_ms(1); // i is the distance ouput may be for 1m i = 75; 1.5m i = 25;

while(recieve == 1);
}

can you explain further?


and,
the code should be like this?

while(1)
{
generate_square(); // in 38 khz
delay_ms(120);
output_low(); // IR led in Off state
delay_ms(380); // 380+120 = 500ms period
for( i = 0 ; recieve == 0; i++) // Count for number of ms the output is low
delay_ms(1); // i is the distance ouput may be for 1m i = 75; 1.5m i = 25;

while(recieve == 1);
}

???
 

Attachments

  • IMG_1914.JPG
    IMG_1914.JPG
    2.7 MB · Views: 74
  • IMG_1916.JPG
    IMG_1916.JPG
    2.2 MB · Views: 79
  • IMG_1917.JPG
    IMG_1917.JPG
    2.3 MB · Views: 72
  • IMG_1918.JPG
    IMG_1918.JPG
    2.1 MB · Views: 73
  • IMG_1919.JPG
    IMG_1919.JPG
    2.3 MB · Views: 75
  • IR Sensor transmitter and receiver diode.pdf
    307.4 KB · Views: 86
Last edited:

nothing to worried about.....

first of all you have to learn a bit of pic programing...

try to make a led blink(in 1hz), after that reduce the delay and run in 38khz and now check with the oscilloscope..

- - - Updated - - -

No need to attach bread boards, instead attach schematic of what you actually doing..

- - - Updated - - -

the final programing part is very easy... and don worry about it..

- - - Updated - - -

first try and complete the square wave.. after that convert it with ISR...
 

I set the ccp to pwm and then set ccpr1l to 65 and 0 to provide 0 and 50% duty cycle,is this wrong?the schematic I had attached in the 1st thread..and is that the 38 kHz didn't generated so the receiver can't detect anything and keep it at 5v?and if I connect the cathode to the ground directly,by phone camera I able to see the infrared light,but if I connect to collector of transistor,I can't see the light and the voltage is 5v which beyond the operating voltage(1.6v),but it should connect to the collector of transistor right?
 

right....

first of all remove the transistor base from Mu and check the output of MC in oscilloscope..

- - - Updated - - -

according to your previous wave form there is no pulse in the ouput its just remains low....
 

You mean the 1 I attached today?ok,I will try to modify my program,I think the delay got mistake,total is 500ms for on and off pulse,I set about 600 on and off,maybe this make problem,will try tomorrow and let u know,thanks for the teaching=)
 

change the program and try to get 38khz in output exactly.............. Then transistor will automatically turn ON the LED..
 

Ok,let say if my program is working after modification,then connect transistor,as the problem I mentioned,if I connect the cathode to collector,I can't see the light and the voltage is 5 v.........
 

The base resistor I out is 3.3k,and I measure the current I get is 0.53mA to 0.58mA I forgotten...since te transistor having 40 hfe...
 

you have look at the pin configuration of transitor because the base current is (5-0.7)/3.3k its about 1.3mA so no problem in design.. For atleast 20hfe the led current will be 26mA sufficient for led.. If you want to check transistor configuration connfct the base via resistor to vcc and led shd be glwing..
 

So the schematic correct?the mcu rc2 I connect to the base with resistor and cathode of ir led to collector of transistor, anode of ir led to +5 v with 68 ohm...

The ir led need at least 50mA right?the transistor having 40 hfe...
 

Schematic is correct and and also the emitter is connected to the ground and other end of 68 ohm is connected to Vcc verify that..
 

my ir led is connected like this and i get 5v when i measure the ir led,if i didnt connect the cathode to collector of transistor and directly connect to ground,i get 1.5v(around), why...?
 

you got confused with voltage right.. It is simple take this configurationled.PNG The voltage "across" the LED is matters not the voltage respect to the cathode and ground. you have to measure between Anode and cathode... Try and tell the result..
 

ok,will try,previously i tried is measure voltage between anode and ground...

#include <pic.h>
#define _XTAL_FREQ 20000000
#define _FOSC_HS & _WDTE_OFF & _PWRTE_OFF & _BOREN_ON & _LVP_OFF & _CPD_OFF & _WRT_OFF & _CP_OFF

void init(void)
{
TRISB = 0X00;
TRISD= 0X00;
TRISC= 0X00; //configure Rc2 as output for Emitter(pwm)
CCP1CON = 0X0C; //select PWM mode.
PR2 = 131; //Set period register for approx. 38khz.
T2CON = 0X04; //Set timer2 pre/post scalers to 0 & start Timer2.
}


void main()
{

init( );
while(1){
CCPR1L = 0; //Set duty cycle for approx 0%
__delay_ms(380);
CCPR1L = 65; //Set duty cycle for approx 50%
__delay_ms(120);
}
}

#define _FOSC_HS & _WDTE_OFF & _PWRTE_OFF & _BOREN_ON & _LVP_OFF & _CPD_OFF & _WRT_OFF & _CP_OFF
this i have to define right? for hi-tech universal toolsuite is that configure as this?i read the manual it said it should configure as __config(data) but if i do that way,it can't...
 

leave that line I wont use it, instead in Mplab window, configure(menu) -->Configuration bits -->uncheck in code configurration and edit as you want..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top