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.

Vreference +/-

Status
Not open for further replies.

Eng.Abbasi

New Member
hello all
i was implementing ADC on pic16f877a, it work probably when i made the refernces voltage is the same Vdd,Vss for the pic , but when i tried to put other reference voltage at pin 4,5 it only display 0 or 255 , and when i change the frequency of the signal it change but only on these two num 0 ,255.
i'll be grateful if any one help me
 
i appreciate your help, but i read it and i dont get the answer.
my problem is not with the pic code becuase i test the code and the circiut on ISIS professional program and it give me the as i want.
 
If you're only getting 0 or 255 from your input then it's set as a digital input, and not as an analogue one. My tutorial explains all the settings, in an easier way than the datasheet.
 
hello Dr.
i told you before that i simulate my code on ISIS program to make sure, and for more explaination i put 1111 on PCFG3:pCFG0 which mean the final choice

thanks a lot
 
I don't know ISIS but simulators often have problems with peripherals. I suspect that Nigel's answer is the right one given the results you described. There are a number of things you have to set up to make the 877 adc work properly, including timing. I'm pretty sure it is your code.
 
What is your refrence voltage? There are usually minimum requirements.
 
Try it on a different simulator. MPLAB has a free one included. Just noticed it simulates the 16F877 not the 16F877A *there's a difference, you'll need to shut off the comparators to use it.

Also post your code segment if you want help.
 
Last edited:
THANKS FOR ALL OF YOU

Sceadwian said:
What is your refrence voltage? There are usually minimum requirements.

-5 TO +5 V. AND I TRIED ON LESS THAN THAT.

-when i use ADC with out reference(same as the pic Vdd,Vss) it work without any problem

this is my code
 

Attachments

  • code.txt
    2.3 KB · Views: 121
For starters with the 16F877A you must turn off the comparators at the beginnig of your program, they're on by default.

As for -5V ? that's not gonna work on a PIC analog input. It'll clamp to 0.

usually
Code:
movlw  0x07
movwf  CMCON
Your simulator doesn't have 877A support?
 
Eng.Abbasi said:
do you mean that pic analog input dont support any signal in minus

You have to offset it to a positive voltage. It's easy to build a voltage divider for 0-10V just use a pair of 4.7K resistors. The PICs A/D like to see around 10K on them.

If analog inputs are of interest you should start looking at a ICD or ICE. Simulators are good and fast but they can only simulate so much. Some don't fully emulate their targets. That 16F877A has a debug mode in hardware, get yourself a ICD and things will be much eaiser.
 
William At MyBlueRoom said:
The PICs A/D like to see around 10K on them.

Check your source. All of the Microchip's PIC datasheets I have seen recommend a maximum of 2.5K.
 
eblc1388 said:
Check your source. All of the Microchip's PIC datasheets I have seen recommend a maximum of 2.5K.

If you check the 16F88 datasheet you will see in section 12.1, Max impedance of 2.5K is stated in the text, however, in note 3 it states 10K.

Someone, which may have been you, gave me an explanation a year or so ago but, I can't remember it. Whichever way you look at it, it is a confusing situation when the datasheet states it so clearly.

Mike.
 
I just realised, I had the B revision of the 16F88 datasheet. Did a quick check and there is a newer version. The newer version states 10K in both places!!

Mike.
 
Oh I remembered.

The 10K is the absolute maximum resistance on which the accuracy of the A/D would not suffer due to pin leakage current.

The 2.5K requirement is such that more rapid channel hopping can be done as the source impedance directly affects the hold capacitor charging time.

So if extra care be taken when using source resistance between 2.5K and 10K to meet the hold capacitor charge time requirement, then such value can be used on 16F88.

But I have no idea if this also applied to "older generation" of PICs like 877 and 877A.

Edited: I'm of opinion that the different Rmax refers to different requirement limit of A/D accuracy or speed. Noted that newer PIC seems to have lower value of C_hold from 120PF down to 25PF for 18F4520 & 18F4550 and as low as 10PF for 16F917. Anyway, the lower the source resistance the better the A/D performance.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top