Page 1 of 1

Help needed using vref with adc

Posted: Thu May 22, 2008 1:16 pm
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?

Re: Help needed using vref with adc

Posted: Thu May 22, 2008 3:17 pm
by Steve

Re: Help needed using vref with adc

Posted: Fri May 23, 2008 4:47 am
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?

Re: Help needed using vref with adc

Posted: Fri May 23, 2008 8:28 am
by Steve
Yes - this is an area we will improve for Flowcode v4.

Re: Help needed using vref with adc

Posted: Mon Nov 03, 2008 9:51 pm
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.

Re: Help needed using vref with adc

Posted: Tue Nov 04, 2008 8:53 am
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.

Re: Help needed using vref with adc

Posted: Mon Nov 10, 2008 10:16 pm
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

Re: Help needed using vref with adc

Posted: Thu Nov 13, 2008 10:27 am
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.