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.

Odd PIC Copy Problem

Status
Not open for further replies.
...The original factory circuit used 1.2k current limiting resistor on the IRLED and 47K on the photo transistor.
...

... In each case the PIC was programmed identically. But each PIC appears to have had a different input pin impedance so the reported voltage range differed drastically.

A photosensor with 47k pullup is very typical, and will not be affected in any significant way by the PIC pin input impedance between PIC batches. Even different PIC types will work very similarly when their ADC input is facing a 47k analogue source.

I'm sure you are missing something in config or code, like one PIC has port pullups on, the other not. Or one has pins set to analog the other not. Or one trying to run RC osc the other from xtal (which affects ADC acq time). And all those things can cause ADC issues and are the type of things that can be set/cleared in config.

Did you try programming that bad HEX file back into the good PIC as I suggested?
 
I considered the possibility that my configuration codes were different. In both the bad and good PIC configurations were set using the CONFIG directive. So------

I took two factory fresh PIC 12f683's.

I programmed one after another in my PicKit2, during a single session, with config bits set by CONFIG directive. Each PIC was placed in a single hardware board, one after another.

The two PIC's displayed different voltages into the AN3 pin. One was 0.68 volts. The other was 1.87 volts.

My best explanation is the photo transistor was operating in a steep slope area of its linear range making for dissimilar reading of the input voltage.

I increased the IR LED drive by changing its load resistor from 820 ohms to 470 ohms. The PIC's now reported 0.48 and 0.53 volts in the "unblocked light" condition.
 
The photo transistor is acting more like a resistor becasue the IR led was not switching it on fully. I've seen this happen a lot. I reuse parts from printers and such. There are a lot of nice photo-interrupters in them.

And some will not work if the IR LED is powered with less then 50 mA but most worked fine at 25ma to 20

You get funny reading I incresed the curent and it would work fine
 
Last edited:
...
I programmed one after another in my PicKit2, during a single session, with config bits set by CONFIG directive. Each PIC was placed in a single hardware board, one after another.

The two PIC's displayed different voltages into the AN3 pin. One was 0.68 volts. The other was 1.87 volts.

My best explanation is the photo transistor was operating in a steep slope area of its linear range making for dissimilar reading of the input voltage.

I increased the IR LED drive by changing its load resistor from 820 ohms to 470 ohms. The PIC's now reported 0.48 and 0.53 volts in the "unblocked light" condition.

Thank you for providing the new information. :) What value is your pullup resistor from the PIC pin to Vdd? If the pullup resistor is too high it can cause issues.

Also with a high impedance ADC source in general you need to allow plenty of settling time, and maybe a cap on the PIC input pin. the PIC datasheet ADC chapter should cover the issues with high impedance ADC sources.
 
I agree, good coding would be if possible to use the right resistor values and a schmidt trigger digital input. :)

I'm still trying to work out why the differences between different PICs would cause such a change on the input pin. If code and config has been ruled out it's looking like a problem caused by really bad biasing whcih is why I asked about the value of pullup resistor the OP was using.
 
The pullup resistor was 47K. See post #8

My original application used the schmidt trigger with the 820 ohm/47K resistor combination. When I programmed a second PIC and it didn't swing between digital limits I added the ADC function because the comparator was already being used for other functions.

The following bulletin discusses the use of opto interruptors for linear sensing. (Linear was not my intent.)

https://www.electro-tech-online.com/custompdfs/2012/03/App20Bulletin20213-Opto20Components.pdf
 
It not really the Pic that is the problem the IR diode is not turned on fully and is not switching the photo transistor on. I had some of these need a full 50mA to work right most don't need but 20mA. and then there is also a chance the over head lighting can keep them partly turned on Fluorescent lights are bad to do so.
 
I'm still not getting what the problem is. 47k is pretty typical for a pullup on a photodiode and should not cause any problem into a PIC input which should be megohms.

Changing from PIC to PIC with the same resistor and photodiode should not cause any issues (assuming everything but the PIC remains the same). So it's looking like a code or config issue again?
 
Last edited:
I'm still not getting what the problem is. 47k is pretty typical for a pullup on a photodiode and should not cause any problem into a PIC input which should be megohms.

The problem isn't the 47K, it's too little current in the LED, so the photo-transistor isn't switching.

Changing from PIC to PIC with the same resistor and photodiode should not cause any issues (assuming everything but the PIC remains the same). So it's looking like a code or config issue again?

It's a bad design choice, followed by a poorly conceived attempt at repairing the problem.
 
The problem isn't the 47K, it's too little current in the LED, so the photo-transistor isn't switching.
...

But that won't change from PIC to PIC, provided the same phototransistor etc is used. Because of the 47k pullup the source impedance of the analogue voltage is <47k, which should give the same analogue voltage into the PIC input which has a load impedance of megohms.

He said the analogue voltage was varying from 0.8v to 1.8v, indicating transistor pull down of maybe 20k? So the total source impedance might be 10k to 15k, this voltage is not going to be affected by changing between different PICs!

I'm just saying the reason for the big change in that analogue voltage is almost certainly not caused by changing the PIC, it's either code or config or some other external variable that has not yet been eliminated.
 
Rb the whole deal here is the OP has to high value resistor on the IR diode and he is letting light hit the photo transistor. That's the whole story.

He posted a data sheet stating resistor values Like I said.

I've changed light bulbs and changed the readings of these photo detectors
 
But that won't change from PIC to PIC, provided the same phototransistor etc is used. Because of the 47k pullup the source impedance of the analogue voltage is <47k, which should give the same analogue voltage into the PIC input which has a load impedance of megohms.

He said the analogue voltage was varying from 0.8v to 1.8v, indicating transistor pull down of maybe 20k? So the total source impedance might be 10k to 15k, this voltage is not going to be affected by changing between different PICs!

I'm just saying the reason for the big change in that analogue voltage is almost certainly not caused by changing the PIC, it's either code or config or some other external variable that has not yet been eliminated.

But there's no point in even looking - he shouldn't be using the ADC - and the far too small current leaves the output from the photo-transistor in an undetermined state which will probably vary over a wide range depending on many factors.
 
Thanks Burt and Nigel for the clarification. :) If it's the ambient light affecting the voltage and/or a combination of bad resistor choice (bad biasing) then that all makes sense.

My argument was against the OP insisting that it was totally caused by changing from one PIC to another PIC, which did not make sense.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top