Regarding port A, why is it when I connect a low voltage into it from a photodiode, the voltage of the photodiode (and so the voltage at the pin) increases ? The open circuit voltage is 0.25V, and when I connect to AN0 it increases to 0.48V ?
The photodiode negative is connected to gnd and positive to the pin.
When I connect the variable voltage on my programmer board the voltage at pin also increases (tried for 0.6V, 1V, 2.5V). But when I connect voltage from a LM385-2.5 voltage reference it does not increase.
Is this a common occurrence with port A/PICs ? Anyone have any clue ? Im using PIC16F877A.
Thank you all.
edit: this happens with all the channels of port A. When nothing is connected, all pins of port A is at +5V.
Hi Nigel, thanks for the reply. Im programming in PICBasic Pro. Here is the code Im testing
define OSC 20
define ADC_BITS 10 'define number of bits in result
define ADC_CLOCK 3 'clock source3=RC
define ADC_SAMPLEUS 50 'set sampling time in microsec
m1pos var portd.7 'to motor 1 positive
m1neg var portd.6 'to motor 1 negative
led1 var portd.3
tolerance var byte
adc1 var word
adc2 var word
diff var word
lowlimit var word
trisa = %11111111
trisd = %00000000
adcon1 = %10000011
pause 500
duration = 1000
tolerance = 8
lowlimit = 82
pair1:
adcin 0, adc1
adcin 1, adc2
diff = abs(adc2-adc1)
if (adc2 > adc1) and (diff > tolerance) and (adc2 > lowlimit) then
high m1pos
low m1neg
high led1
pause duration
low m1pos
low m1neg
low led1
pause duration
pause 10
goto pair1
else
low m1pos
low m1neg
pause 10
goto pair1
endif
Its probably because you are using 2 channels on the ADC and the photo diode is a high impedance source (should be less than 2.5khm. What is happening is that the charge from your variable ADC input is being transfered to the photo diode ADC input by the PIC internal Chold capacitor because the ADC is scanning between these two inputs.
Solution: buffer the photo diode with an OpAmp.
Oh OK, did some reading and the LM339 only outputs in binary states (I always thought comparators were just a type of op amp and so were the same thing).
Are there certain op amp ICs that are more suitable as buffers than others, or can anyone be used ?
Since photodiodes usually convert light into current, you could build an I/V converter. J-FET op amps with low input bias current are suitable for this task. I would suggest reading some documentation about photodiode amplifiers, there are a lot of examples.
Since photodiodes usually convert light into current, you could build an I/V converter. J-FET op amps with low input bias current are suitable for this task. I would suggest reading some documentation about photodiode amplifiers, there are a lot of examples.
Actually, Im quite happy with the low voltage that the photodiode outputs right now, without having to add any amplifiers/build anything extra. I just want to be able to get that voltage into the PIC analog pin.
I chose quad because Im using 4 photodiodes and four analog pins. Heh, I did not know they were the lowest spec, I just Googled for op amps because Im unfamiliar with ICs.
Any others other than the TL0x1 in case I cant get them ?
Thanks for the replies.
edit: I found the TL034 (for quad).. What is the advantage of this IC over the LM324 ? Higher precision ?
I'm not sure about a TL034?, but the TL074 and TL084 are excellent devices, compared with an LM324 they are much higher gain, much higher bandwidth, much lower noise, and much higher impedance inputs.
If you were talking cars, the TL series are like a modern hatchback, Voltswagon Golf GTI, something like that? - the LM324 is like a model T ford with three flat tyres! (and this is probably an UNDER exaggeration!).
OK, so I bought the TL084 and connected it as a voltage follower. However I cannot get equal voltage at the output if I input the photodiode voltage (around 0.30V). The voltage can follow if I connect 2.5V. I tried simulating it and it seems the output can only follow the input when Vin >= 1.8V, even though the datasheet states Vin 'must never exceed magnitude of supply voltage or 15V, whichever is less' ?
Is the voltage too low ? I have Vcc+ connected to 5V and Vcc- to ground.
The output from a photodiode is absolutely tiny, you need to amplify it, and is current rather than voltage, the link I posted gives the circuit for converting the current to voltage.
The output from a photodiode is absolutely tiny, you need to amplify it, and is current rather than voltage, the link I posted gives the circuit for converting the current to voltage.
OK, i read up a bit on the photodiode amplifiers and those I-V converters.. But with my deadline coming, I decided to just swap the photodiodes with LDRs instead to uncomplicate things. Thanks for all the help anyways, Nigel and all those replied.