Reference voltage for A/D inputs - Revisited 16886

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Reference voltage for A/D inputs - Revisited 16886

Post by Mark »

Reference voltage for A/D inputs - Revisited for 16886

Hi Guys,

The above topic is covered in a previous post but that post is now out of date (for 16F876) and my question is for the 16F886.

A summary of the previous post might be:

If you want Vref then go in to the FCD file, make a copy, call it Device_Vref.fcd and adapt it to change ADCON1 register to use the Vref you require. Also add to the Device field a reminder of the source device. Then use the new fcd file as the device definition file in Flowcode.

I have tried the above with the 16F876 and it works fine (original file name retained), though the fcd code has changed so some adaptation was required.

For the 16F886 two problems arose:

1) Using a new file name (.fcd) and the "ChipName = 16F886" in the device field still stopped the compiler recognising the processor.
Changing the original fcd file and keeping the name the same worked.
How can I find the correct Device Name Phrase (for this and other processors)?

2) Changing the original file and using ADCON1 = 8 (VRef on RA3) did not work in as much as the Vref was not recognised (even though Vref was there and could be read on, say RA1 as a correct value. All the Analaog inputs still stayed referenced to 5v (HP-488 board used, jumpers changed for Analog Inputs). Presumably the Tris register code also needs changing, or something else?
Please suggest what needs changing.

Since the Original post seems the most popular (hits wise) on the whole forum, it would seem that Vref is a good candidate for incorporation into the Flowcode ADC Component itself.

Thanks again,

Mark
Go with the Flow.

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: Reference voltage for A/D inputs - Revisited 16886

Post by Steve »

I agree that this is a hot topic and that some way of making it easier in Flowcode is required. I'll look into it.

On the specific points:

1) I don't know why the "ChipName" is not working. It might be case-sensitive (e.g. 16f886 instead of 16F886)? If you are still having an issue, post your modified FCD file up and we'll look at it.

2) The '886 uses a different method of VRef selection. Instead of ADCON1=0x08; you should use ADCON1=0x30; See the ADC entry in the device datasheet for more info.

Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Re: Reference voltage for A/D inputs - Revisited 16886

Post by Mark »

Steve,

Many thanks for the prompt reply. The correct Code is ADCON1=0x10; for VRef+ and ADCON1=0x30; for Vref+ and Vref-. I attach the amended and tested 16F886.fcd file (Vref+) for the convenience of others. The file name is unchanged, but people may wish to change it for ease of reference.

As a secondary task I would like to access the the ADC 14 and ADC 15 channels of CVRef and 0.6v as this (0.6v) will save using an external Vref source and will presumably be useful, for example, to monitor battery voltage without any external components.

I will send my attempt at the .fcd change by e-mail.

thanks again,

Mark
Attachments
16F886.fcd
(8.25 KiB) Downloaded 320 times
Go with the Flow.

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times
Contact:

Re: Reference voltage for A/D inputs - Revisited 16886

Post by echase »

As the originator of that previous post I am chuffed that it was so well read.

I have recently had to do this Vref mod for a 18F2550 and I would stress that, in the absence of the good people who moderate this forum providing you the exact changes to make, it is important to read the datasheet of the chip as there are many variations in the exact register and values that need to be changed.

Roll on the ability of Flowcode to do this as standard though.

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times
Contact:

Re: Reference voltage for A/D inputs - Revisited 16886

Post by echase »

I’d stress the importance of using an accurate reference.

Usually people use the 5V supply as the reference, i.e. Flowcode default. But that leads to situations such as I found in a respected magazine where they had designed a temperature meter that used this reference. They were claiming high temperature accuracy, as the sensor was this accurate, but ignored the fact that the reference inaccuracy completely degraded the overall accuracy. 5V rails are typically up to +- 5%. And even if you initially calibrate your product to account for this, you will get long term and temperature drift on the 5V rail that reduces the calibrated accuracy.

Post Reply