Changing ADC ref. point

Forum for problems or queries regarding Flowcode Comms Components. Eg LIN, I2C, SPI, RS232, CAN, IrDA etc

Moderators: Benj, Mods

Post Reply
Rob
Flowcode V4 User
Posts: 10
Joined: Mon Mar 09, 2009 5:24 pm
Contact:

Changing ADC ref. point

Post by Rob »

Hi, I am using flowcode v3.4.7.48
With regard to the ADC ,I would like to be able to switch the ref. point from VDD to alternate pin, reason being to measure low voltage ( 0.01) with greater accuracy
I have 16F877a & 12f676 but am willing to use any pic if you could help with the code.
If you can't help directly, could you point me to the help files for custom components

many thanks

Rob

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: Changing ADC ref. point

Post by Benj »

Hello Rob

Ok you need to browse to the "Flowcode V3/FCD" directory and open the FCD file for your target device in your favorite text editor eg. notepad.

Find the

Code: Select all

 section of the file and then find the line that starts "ADCCapture="

In the target datasheet goto the analogue to digital A/D section and find the register responsible for assigning Vref+. This will normally be adcon1.

For most targets the adcon1 register is given a value depending on the channel that is being sampled %a. Simply swap the adcon1 values (or appropriate register) for the corresponding value in the datasheet that switches the appropriate ADC channels on and also assigns the +Vref.

[b]Example - 16F877A sampling channel AN0 with Vref+ enabled.[/b]

#if (%a == 0)\n  #define MX_ADC_TRIS_MSK  0x01\n  #define MX_ADC_TRIS_REG  trisa\n  [b]adcon1 = 0x04;[/b]\n#endif\n

[b]Becomes[/b]

#if (%a == 0)\n  #define MX_ADC_TRIS_MSK  0x01\n  #define MX_ADC_TRIS_REG  trisa\n  [b]adcon1 = 0x05;[/b]\n#endif\n

Post Reply