Help needed using vref with adc

Any general or miscellaneous queries that do not fit into the other forum catagories

Moderators: Benj, Mods

Post Reply
veedubmachine
Posts: 6
Joined: Tue Feb 19, 2008 12:01 pm
Contact:

Help needed using vref with adc

Post by veedubmachine »

Im using a pic16f877A to read 3 analog inputs from an accelerometer however the signal is 0-3.3V
so i need have a vref of 3.3v.
Somewhere i read that a config file needs to be edited to do this,
what needs to be done so that I can use the vref inputs?

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

Re: Help needed using vref with adc

Post by Steve »


veedubmachine
Posts: 6
Joined: Tue Feb 19, 2008 12:01 pm
Contact:

Re: Help needed using vref with adc

Post by veedubmachine »

Ah thanks, followed the instructions and all is good.
thank you
oh maybe it would be worth having an adc config screen in the adc properties for setting things like this?

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

Re: Help needed using vref with adc

Post by Steve »

Yes - this is an area we will improve for Flowcode v4.

djmills
Posts: 7
Joined: Mon Nov 03, 2008 3:53 pm
Contact:

Re: Help needed using vref with adc

Post by djmills »

Read this with great interest, thought it would solve a similar problem I'm having with a PIC16F819. I was suprised to find that the portion of the fcd file that I have for the PIC16F877 is significantly different from the example given, worse still the fcd file for the PIC16F819 is different again. Being a real novice the significance of the hashed entries in the ADCCapture entry in the code section eludes me. I noticed allso that adcon1 is initialised to 0x07 earlier in the list, looks like duplication, whats that all about?, help please.

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

Re: Help needed using vref with adc

Post by Steve »

The ADC routines are one of the more complicated pieces of code in the FCD files because there is a great variation in the routines required in the PICmicros. Also, the code for the chips has grown as Flowcode has grown - there have been a number of iterations in the techniques we have used for the ADC code and not all FCD files will be using our most recent "technique". Having said that, we test each file and they all work - it's just that the algorithm used may not be the most efficient.

As for the #ifdef statements, I agree that they look confusing - especially to a novice C programmer. But they are the best way to create compact code for the ADC conversions (although the C code itself is relatively long, the generated HEX code will be short).

As I explained, we intend to overhaul the ADC conversion routines in Flowcode v4 to offer more comprehensive features such as user-defined acquisition time and Vref options.

djmills
Posts: 7
Joined: Mon Nov 03, 2008 3:53 pm
Contact:

Re: Help needed using vref with adc

Post by djmills »

Thanks, but when do you expect flowcode 4 to see the light of day?. In the mean time I have added the following lines to my 16f819 fcd filenow 16f819_extref. in Device, ChipName=16F819 and in Code I've added to ADCCapture \nadcon1=0x01; as has been suggested elsewhere, allas it does not work, what have I missed? ive attached a copy of my revised fcd file for your consideration.

Dave
Attachments
16F819_extref.fcd
(5.61 KiB) Downloaded 354 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Help needed using vref with adc

Post by Benj »

Hello Dave

The attached file should work correctly. The problem was that each channel was assigning its own value to the adcon1 register which was overwriting your value. I have edited the channel values and the +Vref should be working correctly now.
Attachments
16F819_extref.fcd
(5.6 KiB) Downloaded 336 times

Post Reply