• 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.

PIC Microcontroller

Status
Not open for further replies.

gilardino

New Member
I am using PIC16F877A. My sensor output is 4.5V. I input this sensor to PIC. When i connect the output of my sensor to PIC, my output voltage is reduced to 1.3V. When i disconnect it to PIC, the output voltage goes back to 4.5V. Anyone know what happened? And how to keep the output voltage 4.5V to the PIC?

Thank you.
 

Pommie

Well-Known Member
Most Helpful Member
You have made the pin an output or the impedance of your sensor is too high and needs buffering.

Mike.
 

gilardino

New Member
I have 2 different sensor. 1st sensor works fine. Second sensor is just as what i mentioned in my 1st post.
I have set the port as input port. What do you meant by need buffering? How do i achieve that?

Thank you.
 

ericgibbs

Well-Known Member
Most Helpful Member
I have 2 different sensor. 1st sensor works fine. Second sensor is just as what i mentioned in my 1st post.
I have set the port as input port. What do you meant by need buffering? How do i achieve that?

Thank you.
hi,
Can you tell us what the sensors are, ie: logic or analog outputs.?
 

ericgibbs

Well-Known Member
Most Helpful Member

gilardino

New Member
Similar with the schematic. The only different is the microcontroller. In my testing i connect one of outputs of LM324 to PIC MCU and set it as input.
 

gilardino

New Member
If i directly connect portb.f7 to 5V. It works.

void main()
{
TRISB=0x11111111; //portB as input
TRISC=0x00000000;

while(1)
{
if(PORTB.f7==1)
{
PORTC.f7=1;
delay_ms(3000);
PORTC.f7=0;
delay_ms(3000);
}
}
}
 

ericgibbs

Well-Known Member
Most Helpful Member
Why the voltage drops to 1.3V. Not enough current? mismatch?
From what little we know of the project its difficult to say what exactly the problem is.

The input of a PIC draws very little current, so the output impedance of the IR unit would have to be very high.

The PIC pin is misset as a LOW output.

The IR unit is faulty.

Can you post a sketch of how you have that IR connected to the PIC pin.?


EDIT:
If the LM324 becomes unstable and oscillates when the PIC pin is connected this could also be the cause.
 
Last edited:

gilardino

New Member
1st, i have built the IR sensor in PCB board. So i tested the IR sensor only. Without detecting IR Light from emitter, output of LM324 is nearly 0V. When it detects, the output goes to 4.6V. So, basically it works fine. Then it is similar with the sketch. When i connect to PIC, without detecting IR light, output is 0V, when detect, it only shows 1.3V. When i take out the jumper wire from input PIC, without detect is 0V, after detect is 4.5V. Is it this skecth that u want?
 

Attachments

ericgibbs

Well-Known Member
Most Helpful Member
1st, i have built the IR sensor in PCB board. So i tested the IR sensor only. Without detecting IR Light from emitter, output of LM324 is nearly 0V. When it detects, the output goes to 4.6V. So, basically it works fine. Then it is similar with the sketch. When i connect to PIC, without detecting IR light, output is 0V, when detect, it only shows 1.3V. When i take out the jumper wire from input PIC, without detect is 0V, after detect is 4.5V. Is it this skecth that u want?
hi,
That sounds like its connected OK.
I'm beginning to suspect the LM324 is becoming unstable when connected to the PIC PORTB.7

One way to check for this would be to connect a 330R or 470R at pin 1 of the LM324 [as close as possible] and then connect the wire from the PIC to the free end of the resistor, so that the resistor is in series.

The other cause of instabilty could be, do you have any decoupling on the LM324 +5V rail.?????
 
Last edited:

gilardino

New Member
Thanks, What is the purpose of the series resistor 470R? What do you mean by decoupling on LM324+5V rail?Sorry, i do not understand.
 

ericgibbs

Well-Known Member
Most Helpful Member
Thanks, What is the purpose of the series resistor 470R? What do you mean by decoupling on LM324+5V rail?Sorry, i do not understand.
The resistor will help to isolate the LM324 output from stray capacitance in the outgoing wiring.

The LM324 should have a 10nF or 100nF cap from +5V to 0V, as close as possible to the LM324.

BTW: what are the other 'free' pins of the LM324 connected too.??

When the resistor is in place, rerun your meter tests with a high and low... measure at each end of the resistor
 
Last edited:

ericgibbs

Well-Known Member
Most Helpful Member
Other pins all connected since i use total of 4 IR sensors. 10nF or 100nF is from 5V supply connected to gnd?
Yes, the cap is from +5V to Common 0V [Gnd]

Lets know what you measure on both ends of the resistor.
 

gilardino

New Member
on both ends, are the same 1.3V.

Finally, i can make it work adding a transistor. So i connect output of sensor to transistor (base), collector to 5V and emitter to PIC. The voltage at the PIC is 2.5V which give logic 1.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top