PDA

View Full Version : Using WPU and ADC



Szczepaniec
- 24th April 2013, 03:47
I have a piece of code I am having issues with and suspect it may have to do with the ADC and WPUs I am using. I am using a phototransistor to ground and attempting to read a relative value with an ADC input by using the WPU. Aside from one comment in the datasheet for the 12F615 about having a bunch of things cleared including the WPUs when a pin is setup for analog input I cannot find where it says it cannot be done. I configured the pin as an analog input and then right before I am doing the ADC measurement I put the wpu.4 = 1 in place which seems to bring the pin up but I am thinking it is skewing my ADC results. I don't have a display to display the output on the board it is so it is hard to tell. I will probably end up bringing the circuit to a breadboard to test but I am wondering if I have done a "no-no" and need to scrap the boards and order ones with external pull ups before doing anything else. Also, I have included OPTION_REG.7 = 0. Thanks in advance.

peterdeco1
- 24th April 2013, 14:56
What phototransistor are you using? Generally, the collector needs a far lower resistance than the WPU's in the PIC. Maybe disable WPU's (if they enable in analog mode) and tie a suitable external resistor to B+. Or try a photoresistor instead. Good luck.

Szczepaniec
- 24th April 2013, 22:07
I am using an OSRAM, SFH 300 FA-3/4 which works fine. It is apparently a problem with my code because it doesn't work on my breadboard but a more basic program utilizing the WPU, ADC, and an LCD works fine. FWIW, I am using a 12F615 and you do have to activate the WPU after configuring the pin as an analog input.