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?
Help needed using vref with adc
-
- Posts: 6
- Joined: Tue Feb 19, 2008 12:01 pm
- Contact:
- 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
Hello,
here are some posts with the relevant info:
http://www.matrixmultimedia.com/mmforum ... hilit=vref
http://www.matrixmultimedia.com/mmforum ... vref#p7981
here are some posts with the relevant info:
http://www.matrixmultimedia.com/mmforum ... hilit=vref
http://www.matrixmultimedia.com/mmforum ... vref#p7981
-
- Posts: 6
- Joined: Tue Feb 19, 2008 12:01 pm
- Contact:
Re: Help needed using vref with adc
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?
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
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.
- 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
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.
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
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
Dave
- Attachments
-
- 16F819_extref.fcd
- (5.61 KiB) Downloaded 354 times
- 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
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.
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
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel