looking for PIC18F46K42 and dsPIC33EP128GM710 ADC -Vref pin configuration

Moderator: Benj

Post Reply
mit2003
Posts: 18
Joined: Wed Oct 14, 2020 11:37 am
Been thanked: 2 times
Contact:

looking for PIC18F46K42 and dsPIC33EP128GM710 ADC -Vref pin configuration

Post by mit2003 »

Dear friends,

I can't able to enable configuration (or) not familiar to configuration of -Vref in PIC18F46K42 as well as dsPIC33EP128GM710 to increase measurement resolution by means of setting negative reference voltage from default system reference (0V) to 2.3V. Eventhough i insert the command "ADREF=0X10" i am not lucky. :roll:
Hope there is a way or trick to implement which i am not aware. Kindly help me to assign -Vref pin for negative reference. :o

Thanks in advance

Senthil
Thank you so much :!:
B.Senthil

chipfryer27
Valued Contributor
Valued Contributor
Posts: 664
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 203 times
Contact:

Re: looking for PIC18F46K42 and dsPIC33EP128GM710 ADC -Vref pin configuration

Post by chipfryer27 »

Hi

Being honest I've never used the -Vref option before, but from p296 of the PIC18F46K42 datasheet it looks like you need to set the ADCON1 register to 0x05 (0b00000101). Bits 3-2 set +Vref with bits 1-0 setting -Vref

In a C-Code block include ADCON1=0x05;

Let me know how you get on.

Regards

mit2003
Posts: 18
Joined: Wed Oct 14, 2020 11:37 am
Been thanked: 2 times
Contact:

Re: looking for PIC18F46K42 and dsPIC33EP128GM710 ADC -Vref pin configuration

Post by mit2003 »

Hi Friend,
Thanks for your reply.
1. In the page 296 i found Peripheral Module Disable register only.
PAGE_296.jpg
PAGE_296.jpg (45.28 KiB) Viewed 11486 times
2. ADCON1 having only pre-configuration for ADC Precharge controls
ADCON1.jpg
ADCON1.jpg (99.81 KiB) Viewed 11486 times
3. ADREF register at page 622 of datasheet having that configuration. But don't know how to insert this piece of code effectively.
ADREF.jpg
ADREF.jpg (58.77 KiB) Viewed 11486 times
I think still i am unlucky. But hope that there is a way to achieve this.

Let me try till i get the result and update the way to implement if i did.

Any way my heartly thanks for you to spent some time for me.
Thank you so much :!:
B.Senthil

chipfryer27
Valued Contributor
Valued Contributor
Posts: 664
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 203 times
Contact:

Re: looking for PIC18F46K42 and dsPIC33EP128GM710 ADC -Vref pin configuration

Post by chipfryer27 »

Hi

Clearly I've opened up the wrong document. I have a folder containing PIC datasheets and I must have inadvertently opened up the wrong one :oops:

From the correct one, I'd agree with you in that ADREF should be set at 0x10 by adding a C-Code block containing ADREF=0x10;

Capture.JPG
Capture.JPG (11.31 KiB) Viewed 11478 times

However I'm unsure if when FC accesses the ADC it overwrites. I don't think I have one of those chips, but if not I'll try with one I have. As mentioned I haven't had need to use it before so it will be interesting to see what happens.

Regards

mit2003
Posts: 18
Joined: Wed Oct 14, 2020 11:37 am
Been thanked: 2 times
Contact:

Re: looking for PIC18F46K42 and dsPIC33EP128GM710 ADC -Vref pin configuration

Post by mit2003 »

Hi,
I have checked with my test routine but no impact in the result.
ADREF_CONFIG.jpg
ADREF_CONFIG.jpg (22.1 KiB) Viewed 11475 times
Thank you so much :!:
B.Senthil

chipfryer27
Valued Contributor
Valued Contributor
Posts: 664
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 203 times
Contact:

Re: looking for PIC18F46K42 and dsPIC33EP128GM710 ADC -Vref pin configuration

Post by chipfryer27 »

Hi

I'm guessing then that FC is overwriting the setting, perhaps when the component initialises. What component are you using for the ADC?

Regards

mit2003
Posts: 18
Joined: Wed Oct 14, 2020 11:37 am
Been thanked: 2 times
Contact:

Re: looking for PIC18F46K42 and dsPIC33EP128GM710 ADC -Vref pin configuration

Post by mit2003 »

HI,
Potentiometer (Slider) used for development.
POT.jpg
POT.jpg (102.17 KiB) Viewed 11468 times
Thank you so much :!:
B.Senthil

mit2003
Posts: 18
Joined: Wed Oct 14, 2020 11:37 am
Been thanked: 2 times
Contact:

Re: looking for PIC18F46K42 and dsPIC33EP128GM710 ADC -Vref pin configuration

Post by mit2003 »

Hi friends,
If any other part macro provide -Vref assignments for ADC, Kindly let me know :!:
Thank you so much :!:
B.Senthil

mit2003
Posts: 18
Joined: Wed Oct 14, 2020 11:37 am
Been thanked: 2 times
Contact:

Re: looking for PIC18F46K42 and dsPIC33EP128GM710 ADC -Vref pin configuration

Post by mit2003 »

Hi Friends,
I found the key factor and modified as well as tested. Now i got proper result with -Vref. :D

In the "PIC_CAL_ADC.c" file @ C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC
ADREF = Vref;
If modified this as ADREF = 0X10;
SOLUTION.jpg
SOLUTION.jpg (79.33 KiB) Viewed 11460 times
Now PIC18F46K42 working with negative reference voltage.

Note:
I am sure about the impact of this modification will reflect in all similar ADC based controllers behavior.

Kindly back-up that file before modifying that, after testing replace with original one to ensure default system behavior. :mrgreen:
Thank you so much :!:
B.Senthil

mit2003
Posts: 18
Joined: Wed Oct 14, 2020 11:37 am
Been thanked: 2 times
Contact:

Re: looking for PIC18F46K42 and dsPIC33EP128GM710 ADC -Vref pin configuration

Post by mit2003 »

Hi Friends,
I have not received dsPIC33EP128GM710 which i ordered.

I can able to test while i receive, assemble, configure and then only I will try & update above modification impact.

If any one of you already having this hardware setup, kindly try to test and update the result which can be either give me confident in advance or helps to plan accordingly.
Thank you so much :!:
B.Senthil

chipfryer27
Valued Contributor
Valued Contributor
Posts: 664
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 203 times
Contact:

Re: looking for PIC18F46K42 and dsPIC33EP128GM710 ADC -Vref pin configuration

Post by chipfryer27 »

Hi

Great you have it working and thanks for letting us know.

Unfortunately I don't have the dsPIC to try but I'm sure your "fix" will work again.

Regards

mit2003
Posts: 18
Joined: Wed Oct 14, 2020 11:37 am
Been thanked: 2 times
Contact:

Re: looking for PIC18F46K42 and dsPIC33EP128GM710 ADC -Vref pin configuration

Post by mit2003 »

Dear Chipfryer,

Thanks for your support.

Even though i have configured -Vref and got the response as intended, I failed to fulfil my objective of getting higher resolution of measured parameter for better accuracy.
In my case always processed (Voltage divider network R1&R2) signal voltages varies from 2.6V only. There are multiple signals tapped from the source voltage of 2.6V to 220V. Now i can able to measure @ resolution of 0.0537v.

My intension is achieve better measurement resolution of 0.001V > Vmeasure >0.0001v. (Final goal)

At this step, i planned to improve the resolution from 0.0537v to 0.0268v by means of setting -Vref = 2.5V.

Theoretically everything fine, but real time implementation is not seems to be that much easier. While testing about the ADC result with -Vref = 2.5v, that is okay and good.

While i tried to integrate the measured portion (50%) with escalated portion (2.5V ie 50% certain value for each tapings for ex: 25V for 50V measurement, that node voltage never goes below 25V ) and experienced upto 0.2V deviation from the actuals which is a worst scenario for my objective.

I realized that this deviation due to any one of the following reasons.
1. -Vref is varying slightly (AMS117 2.5V with 1000 uf)
2. System reference (GND) may be slightly differ during these functionality (decoupling 4.7uf ceramic and 2 X 1000 uf)
3. Impact of sampling current (less on low voltage and significantly high on High voltage measurements)

Now decided that -Vref implementation is best for Single parameter measurement or multiple parameters with similar amplitude.

For widely varying parameter (0V to 220V) common ground reference for both ADC and Microcontroller may be the best option.

Now i have only one option to achieve my objective. Increasing ADC bit resolution to 24bits (For one stop solution for a while).

Planning to go with MCP3561 ADC and got hope after go through below links

viewtopic.php?f=76&t=22546&p=104853&hil ... 01#p104853

and FC_Comp_Source_ExternalADC_MCP356X.fcfx for FC8

https://www.flowcode.co.uk/wiki/index.p ... log_Input)

Chipfryer, i hope you can help me to add this component to FC8 (Step by step) and utilize for test the output.
Thank you so much :!:
B.Senthil

chipfryer27
Valued Contributor
Valued Contributor
Posts: 664
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 203 times
Contact:

Re: looking for PIC18F46K42 and dsPIC33EP128GM710 ADC -Vref pin configuration

Post by chipfryer27 »

Hi

The MCP356x family is suported in Flowcode v10 and is a component found under Inputs.

In FCv10 all componentsare free and you only need to purchase chip packs if your chip is not included in the free offerings. You can download v10 and components for free and can evaluate using say a PIC16F877A.

Regards

mit2003
Posts: 18
Joined: Wed Oct 14, 2020 11:37 am
Been thanked: 2 times
Contact:

Re: looking for PIC18F46K42 and dsPIC33EP128GM710 ADC -Vref pin configuration

Post by mit2003 »

Hi CF,
Thanks for your valuable information. :D
Thank you so much :!:
B.Senthil

Post Reply