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.

PIC input problem. Help required...

Status
Not open for further replies.

2camjohn

Member
I recently changed the micro I use in one of my projects to the PIC18F1320.

But I have a problem with some of the inputs.

I have a phototransistor connected between RA0 and GND, with a 27k resistor pullup resistor connected to RA6 (defined as output and set high).


The output from the phototransistor (without the chip connected) goes between 0.1V (high light) and 3.5V (low light). But when the PIC is connected this pin is high (according to the software and on my multimeter) regardless of the light conditions.


I have disabled the ADC and set all the ADC chanels as digital IO. This is port A so it doesnt have any WPUs.

This setup works great on other Pics such as the 16f819.



This problem occurs when the phototransistor is connected to RA0 or RA1. The pin reads high (low light) all the time.

Shorting the phototransistor works great, that pulls the pin low and it is recognised by the software. But the Phototransistor is unable to pull the pin low by itself (I even tried two phototransistors in paralell).


When this is connected to RB1 it works great, as it does on the other chips that I have used for this circuit.


I have tried several different chips so im certain Its not a damaged chip.



I feel I have tried everything I can think of to solve this problem, so any advice at all would be greatly appreciated.

John
 
Never played with one, or even seen one, but I suspect there's something you're not configuring correctly? - read the datasheet completely and you might spot it? - it sounds like the pin is either restriced in some way, or allocated to some hardware (assuming you don't have a constructional error?).
 
Nigel,

Thanks as always for your help.
I have gone through the entire datasheet looking for something that could be causing this problem.
The pins in question are shared with the ADC and the LDVIN.

I have disabled the ADC and set all the pins as digital IO.
I have disabled the LDV circuitry but im not very farmiliar with it...



The frustrating thing is, the rest of my code ported very easily in a couple of hours, and this one input problem has taken me almost a week and im still no closer than I was a week ago.
 
Ok, just something to try, using a 330R resistor, measure the current from the PIC leg to 0V, if it's above a few uA (into the MA's) then this leg if defniatelly configured as an active high.

Can you please post your config/Init code for us to have a look at? It's often and "obvious" fault that you can "see" that is the problem. Have you checked that you are loading the registers through the correct banks, Microchip have a crafty habit of shuffling them around, so your "ported" code compiles OK, but won't work.

Oh and try not to throw your project too far, even tho it TOTALLY deserves it, I am sure we can make it better for you!

Trust me, we have ALL been there, and anyone who say's they havn't, hasn't programmed PIC's! :)

I hope this helps!
 
Check the following:

1. That RA0 is truely set for input - check the software and confirm by hardware test (led + resistor is enough).
2. That the collector of the photo transistor is truely connected to RA0.
3. That the emitter of the photo transistor is truely grounded.
4. That the collector and emitter of the photo transistor are not shorted to anything else.
5. That the base of the photo transistor (if there is one) is biased correctly (usually floating) and not shorted to anything else.

If still doesn't work:

Check the operation of the phototransistor independently - remove PIC and connect the 27K to 5V and check that collector goes low when there is light and goes high in low light. If this does not work either the transitor is faulty or RA0 pin is shorted to something else. If this works, RA0 is being programmed for output high somewhere in the code - which the transistor cannot drive.

Hope this gives you some ideas.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top