Try a lower value POT - 2.5k or so (see circled data below).
Try a lower value POT - 2.5k or so (see circled data below).
Why pay for overpriced toys when you can have
professional grade tools for FREE!!!
rmteo:
I changed the pot to ten turn 2k ohm, also tried a ten turn 20k ohm. No change, it reads exactly the same as before. The ADC is not reading correct, between 0.000 and 0.063 Vdc in on AN0 the ADC count is 0, and at 2.500 Vdc the ADC count is 505. At 5.000 Vdc the ADC count is correct, it reads 1023. It is strange that the closer I get to Vdd the more correct the ADC gets. This thing should read 1 count for every 4.8 mV, and its not. I have tried using other chips, such as its big brother the 16F876, and its cousin the 16F819.
At first I suspected my Keithley 175, however I have tried other meters and a scope and they all read the exact same as my Keithley.
Thought about ripple, there is about 1mV. If it were reading the ripple I would at least get a count from the ADC. What is bothering me is that I do not get a count from the ADC until I get over 0.063 Vdc at AN0.
Anyone else have any ideas?
Thanks,
Ron
Hey RDavid,
At this point, if I were you, I would drop back to some trouble shooting techniques.
How about using debug to send the adval to a serial port or if you are using the PICkit programmer it has that feature available.
Below is a sample program for the 16F690 so you will have to adapt it for your PIC, but you can see how to set up debug.
Code:' 16F690 '**************************************************************** '* Name : UNTITLED.BAS * '* Author : [select VIEW...EDITOR OPTIONS] * '* Notice : Copyright (c) 2007 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 12/4/2007 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** ' 10-bit A/D conversion ' Connect analog input to channel-2 (RA2) ' -----[ I/O Definitions ]------------------------------------------------- DEFINE DEBUG_REGG PORTA 'set debug port to porta DEFINE DEBUG_BIT 0 'use pin a0 of porta for debug DEFINE DEBUG_BAUD 2400 'set baud rate to 2400 DEFINE DEBUG_MODE 0 'communicate in true mode ' Define ADCIN parameters ' Set number of bits in result DEFINE ADC_BITS 10 ' Set clock source (3=rc) DEFINE ADC_CLOCK 3 ' Set sampling time in microseconds DEFINE ADC_SAMPLEUS 50 adcVar VAR WORD ' Create variable to store result ' Set PORTA to all input 'TRISA = %11111111 ' Set up AD ANSEL = %00000100 'enable AN2, ALL THE REST DIGITAL ANSELH = %00000000 'AN8-11 DIGITAL ADCON0 = %10001000 ' RIGHT JUSTIFIED ADCON1 = %00010000 'fOSC/8 Pause 500 ' Wait .5 second main: ADCIN 2, adcVar ' Read channel 0 ' do something with adVar here debug DEC adcvar," ",BIN adcVar,$0D,$0A Pause 100 ' Wait.01 second GoTo main ' Do it forever
Dwight
These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.
Dwight:
Thanks, I was already using Debug to send the ADCin value to one of my PicKit2 using the UART tool. It's pretty cool, if you have two PicKits you can use two at a time, one as a programmer running under MicroCode studio and the another as a debugger spitting out data from your code.
Any way thanks to everone for their help. I got it to correctly read the ADC.
The issue was that if I leave any pin on PortB high it would throw off my ADC readings on the low end. I found that if I make all the bits on PortB low before reading the ADC the reading are accurate. Go figure!
Thanks again for all the help.
Ron
That is strange. I checked section 11 of PIC 16F87x and there is no reference to Port B. It does mention Port E, but the 16F873 doesn't have that port.
How about the config fuses? Smells of PGM in LVP mode to me, OR there<s some psu noise, or floating MCLR pins.. go figure
As usual, 10uF tantalum + 0.1uF as close as possible of VDD, make sure you have both VSS pins connected, 10K or so on MCLR.
Last edited by mister_e; - 16th May 2011 at 08:30.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Steve:
Here are the conifgs:
@ device pic16F873A, HS_OSC ' High Speed Crystal/Resonator, 4 MHz and above
@ device pic16F873A, WDT_ON ' Watchdog timer enabled
@ device pic16F873A, PWRT_ON ' Power on timer enabled
@ device pic16F873A, BOD_ON ' Brown out detect enabled
There is a 0.1uf between Vss and Vdd
The Vdd has less than 1mV of ripple.
Both Vss pins are tied to ground.
I added the following to my configs, still no change.
@ device pic16F873A, LVP_OFF ' Low-Volt ICSP programming disabled
With any of PortB pins high the ADC will not respond until AN0 is above 0.063Vdc. If I ensure that all PortB pins are low the ADC responds correctlty.
I even added a 100 mS pause before and after issuing the ADCIN statement, that helped some, but didn't solve the issue.
In this aplication it's not a problem. I ensure that all pins on PortB are low before reading the ADC. The ADC now correctly reads 1 count for every 0.0488 volts.
Thanks,
Ron
Bookmarks