ADC Component change ref voltage
Moderator: Benj
-
- Valued Contributor
- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
ADC Component change ref voltage
Afternoon all
using a PIC16F18875 and I want to change the internal ref voltage to 1.024 volts
http://www.matrixtsl.com/wikiv7/index.p ... a0dd265bce
I am not 100% sure on how to change this, don't fully under stand the wiki
If someone could advise
Steve
using a PIC16F18875 and I want to change the internal ref voltage to 1.024 volts
http://www.matrixtsl.com/wikiv7/index.p ... a0dd265bce
I am not 100% sure on how to change this, don't fully under stand the wiki
If someone could advise
Steve
Success always occurs in private and failure in full view.
- 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: ADC Component change ref voltage
Hi Steve,
Change the VRefOption to FVR.
Change the VRefVoltage to 102.
Then use the following C code to configure the FVR peripheral.
Hopefully that should be all that is required.
Change the VRefOption to FVR.
Change the VRefVoltage to 102.
Then use the following C code to configure the FVR peripheral.
Code: Select all
FVRCON = 0x81;
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
-
- Valued Contributor
- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
Re: ADC Component change ref voltage
Afternoon
trying to get analogue input working, reading not making any sense at all
Connected LM35CAZto port E0
http://uk.farnell.com/texas-instruments ... st=9494529
test program reading not stable what so ever 0.000031 - 1.015899 voltage on scope 256mv which is probably correct for temperature in room
not 100 % sure if I have analogue port settings correct
if someone can advise
Steve
:edit
the plot thickens
1) tried the example file from the wiki - "Reading a sample as a Voltage" changed target device to PIC16F18875 and 4 x 16 display - example didn't work read rubbish
2) exact same example and setup - target device ECIO40P - working correctly
changed back to test 1
measured voltage with scope on chip input pin - correct
changed analogue inputs to different pin - not working (AN32 - RE0)
so is the problem with my device setup or is there something else a miss ?
trying to get analogue input working, reading not making any sense at all
Connected LM35CAZto port E0
http://uk.farnell.com/texas-instruments ... st=9494529
test program reading not stable what so ever 0.000031 - 1.015899 voltage on scope 256mv which is probably correct for temperature in room
not 100 % sure if I have analogue port settings correct
if someone can advise
Steve
:edit
the plot thickens

1) tried the example file from the wiki - "Reading a sample as a Voltage" changed target device to PIC16F18875 and 4 x 16 display - example didn't work read rubbish
2) exact same example and setup - target device ECIO40P - working correctly
changed back to test 1
measured voltage with scope on chip input pin - correct
changed analogue inputs to different pin - not working (AN32 - RE0)
so is the problem with my device setup or is there something else a miss ?
Success always occurs in private and failure in full view.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: ADC Component change ref voltage
Hi Steve,
What chip pin number have you connected the analogue signal to?
then adding C code code block with would not work?
Steve,
Have you read this thread?
In your case you will need to search for instead of
Martin
To me that sounds like the port is floating so wrong pin is being read or there is a bug with ADC.Steve001 wrote: test program reading not stable what so ever 0.000031 - 1.015899 voltage on scope 256mv which is probably correct for temperature in room
not 100 % sure if I have analogue port settings correct
What chip pin number have you connected the analogue signal to?
I would have thought since this is set withinBenj wrote: Then use the following C code to configure the FVR peripheral.Code: Select all
FVRCON = 0x81;
Code: Select all
PIC_CAL_ADC.c
Code: Select all
FVRCON = 0x81;
Steve,
Have you read this thread?
In your case you will need to search for
Code: Select all
TYPE_34
Code: Select all
TYPE_26
Martin
-
- Valued Contributor
- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
Re: ADC Component change ref voltage
Hi Martin
I am using port E0 (pin8) - i have checked the pin voltage is correct with my scope
I was looking at that post this afternoon, wasn't too confident in looking into that or fiddling with the code.
I will sit down tomorrow and have a go through it when i have a clear head
Steve
:edit
I also checked by using the example file in the wiki AN0, AN1, AN32 using standard analogue port settings - readings meaning less
I am using port E0 (pin8) - i have checked the pin voltage is correct with my scope
I was looking at that post this afternoon, wasn't too confident in looking into that or fiddling with the code.
I will sit down tomorrow and have a go through it when i have a clear head

Steve
:edit
I also checked by using the example file in the wiki AN0, AN1, AN32 using standard analogue port settings - readings meaning less
Success always occurs in private and failure in full view.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: ADC Component change ref voltage
Hi Steve,
This is a long shot.
Can you connect the voltage to be measured to Pin 2 (AN0) and see what the Display reads?
Martin
This is a long shot.
Can you connect the voltage to be measured to Pin 2 (AN0) and see what the Display reads?
Martin
Martin
-
- Valued Contributor
- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
Re: ADC Component change ref voltage
Hi Martin,
I checked by using the example file in the wiki AN0, AN1, AN32 using standard analogue port settings - readings meaning less
Steve
I checked by using the example file in the wiki AN0, AN1, AN32 using standard analogue port settings - readings meaning less
Steve
Success always occurs in private and failure in full view.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: ADC Component change ref voltage
Hi Steve, I was suspecting registers not being assigned with correct values?
There is a way to find out.
You could read the registers then send value to LCD.
Would you know how to do that?
Martin
There is a way to find out.
You could read the registers then send value to LCD.
Would you know how to do that?
Martin
Martin
-
- Valued Contributor
- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
Re: ADC Component change ref voltage
Hi Martin
To be honest I don't have a clue
If you can help me out with that one please
Steve
To be honest I don't have a clue

If you can help me out with that one please
Steve
Success always occurs in private and failure in full view.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: ADC Component change ref voltage
Sure,
I will put something together tomorrow for you.
Martin
I will put something together tomorrow for you.
Martin
Martin
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: ADC Component change ref voltage
Hi Steve,
Don't know if the attached file will help?
It will display the register name and below will display the register value in binary which makes it easier to compare with the data sheet.
Martin
Don't know if the attached file will help?
It will display the register name and below will display the register value in binary which makes it easier to compare with the data sheet.
Martin
- Attachments
-
- analougue test 2.fcfx
- (22.05 KiB) Downloaded 359 times
Martin
-
- Valued Contributor
- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
Re: ADC Component change ref voltage
Hi Martin
Connected my LM35 to E0 - measured 233.1mv on scope
cannot make end or tail of this
I let it run for 4 passes and got different results
Looking at the FVRCON Register 11000001
Fixed Voltage Reference is enabled
Fixed Voltage Reference output is ready for use
Temperature Indicator is disabled
VOUT = VDD - 2VT (Low Range)
Comparator FVR Buffer is off
ADC FVR Buffer Gain is 1x, (1.024V)
or have I read this the wrong way round ? and why is ADC different values
looking at page 267 on data sheet
http://www.farnell.com/datasheets/22452 ... 1501615565
Steve
Connected my LM35 to E0 - measured 233.1mv on scope
cannot make end or tail of this

I let it run for 4 passes and got different results
Looking at the FVRCON Register 11000001
Fixed Voltage Reference is enabled
Fixed Voltage Reference output is ready for use
Temperature Indicator is disabled
VOUT = VDD - 2VT (Low Range)
Comparator FVR Buffer is off
ADC FVR Buffer Gain is 1x, (1.024V)
or have I read this the wrong way round ? and why is ADC different values


looking at page 267 on data sheet
http://www.farnell.com/datasheets/22452 ... 1501615565
Steve
Success always occurs in private and failure in full view.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: ADC Component change ref voltage
Hi Steve,
From your results it looks like ADCON0 is either not being assigned correctly or it's being cleared within PIC_CAL_ADC.c
On further investigation its the latter.
In order to view ADCON0 SFR:
Can you make a back up copy of PIC_CAL_ADC.c in if 64 bit windows
or if 32 bit windows.
Then replace original with attached version, which will be for diagnostics only.
Martin
From your results it looks like ADCON0 is either not being assigned correctly or it's being cleared within PIC_CAL_ADC.c
On further investigation its the latter.
In order to view ADCON0 SFR:
Can you make a back up copy of PIC_CAL_ADC.c in
Code: Select all
C:\Program Files (x86)\Flowcode 7\CAL\PIC\PIC_CAL_ADC.c
or
Code: Select all
C:\Program Files\Flowcode 7\CAL\PIC\PIC_CAL_ADC.c
Then replace original with attached version, which will be for diagnostics only.
Martin
- Attachments
-
- PIC_CAL_ADC.c
- (117.19 KiB) Downloaded 286 times
Martin
-
- Valued Contributor
- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
Re: ADC Component change ref voltage
cheers martin will have a go tonight
do I reprogram device with new file and re run ?
Steve
do I reprogram device with new file and re run ?
Steve
Success always occurs in private and failure in full view.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: ADC Component change ref voltage
Hi Steve,
I'm interested in what the new ADCON0 results are.
Martin
Yes or else there will be no difference in your results.Steve001 wrote:do I reprogram device with new file and re run ?
I'm interested in what the new ADCON0 results are.
Martin
Martin
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: ADC Component change ref voltage
Hi Steve,
I have noticed some confusion with the datasheet;
It shows on page 344: Which shows to use ADCON0 for analogue channel selection.
Yet further down the datasheet it shows: Can you change one of the registers in the flowchart to and recompile.
Don't forget to refresh flowchart before compiling.
From the results, we could get further.
Martin
I have noticed some confusion with the datasheet;
It shows on page 344: Which shows to use ADCON0 for analogue channel selection.
Yet further down the datasheet it shows: Can you change one of the registers in the flowchart to
Code: Select all
ADPCH
Don't forget to refresh flowchart before compiling.
From the results, we could get further.
Martin
Martin
-
- Valued Contributor
- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
Re: ADC Component change ref voltage
Hi Martin
do you want me to use the original cal file or your modified one ?
I was reading that data sheet too last night but not as far down as that page, I did notice something that FVR is on port AN1 ???? I was getting confused at this point also too
I will have another go tonight
Steve
do you want me to use the original cal file or your modified one ?
I was reading that data sheet too last night but not as far down as that page, I did notice something that FVR is on port AN1 ???? I was getting confused at this point also too
I will have another go tonight
Steve
Success always occurs in private and failure in full view.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: ADC Component change ref voltage
Hi Steve,
1) Go in to a switch branch of flowchart.
Change a name of both C code and calculation box to desired register.
E.g change & to
&
Or
2) Add an additional Switch from the flowchart symbols and double click on it.
Change the default to
In change to
Copy any of the two icons e.g &
Paste in the branch of the new switch icon.
Just change the the register names of both icons so you have: & for branch 11.
Finally cut the from branch 10 and paste in the new branch 11.
Recompile flowchart.
Martin
Nothing requires changing on cal file:Steve001 wrote:do you want me to use the original cal file or your modified one ?
There are two different ways.medelec35 wrote:Can you change one of the registers in the flowchart to
CODE: SELECT ALL
ADPCH
and recompile.
1) Go in to a switch branch of flowchart.
Change a name of both C code and calculation box to desired register.
E.g change
Code: Select all
FCV_REGISTER_VALUE=ADCON1;
Code: Select all
RegisterName = "ADCON1"
Code: Select all
FCV_REGISTER_VALUE=ADPCH;
Code: Select all
RegisterName = "ADPCH"
2) Add an additional Switch from the flowchart symbols and double click on it.
Change the default
Code: Select all
0
Code: Select all
Count
Code: Select all
Cases:
Code: Select all
1
Code: Select all
11
Code: Select all
FCV_REGISTER_VALUE=ADCON1;
Code: Select all
RegisterName = "ADCON1"
Code: Select all
11
Just change the the register names of both icons so you have:
Code: Select all
FCV_REGISTER_VALUE=ADPCH;
Code: Select all
RegisterName = "ADPCH"
Finally cut the
Code: Select all
Count = 0
Recompile flowchart.
Martin
Martin
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: ADC Component change ref voltage
No problem.
One thing.
Can you make sure the ADC channel being used within flowchart and hardware is not An0.
Cheers
One thing.
Can you make sure the ADC channel being used within flowchart and hardware is not An0.
Cheers
Martin
-
- Valued Contributor
- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
Re: ADC Component change ref voltage
Hi Martin
i get the following error when I compile now
Launching the compiler...
C:\Program Files (x86)\Flowcode 7\compilers\pic\bin\xc8.exe --chip=16F18875 "analougue test 2.01.c" --MSGDISABLE=359,1273,1388
Microchip MPLAB XC8 C Compiler (Free Mode) V1.41
Build date: Jan 24 2017
Part Support Version: 1.41
Copyright (C) 2017 Microchip Technology Inc.
License type: Node Configuration
analougue test 2.01.c: main()
1245: FCV_REGISTER_ADPCH;
^ (192) undefined identifier "FCV_REGISTER_ADPCH"
(908) exit status = 1
(908) exit status = 1
C:\Program Files (x86)\Flowcode 7\compilers\pic\bin\xc8.exe reported error code 1
FINISHED
have I done something stupid
cannot see anything
input connected to E0 - pin 8 still (AN32)
Steve
i get the following error when I compile now
Launching the compiler...
C:\Program Files (x86)\Flowcode 7\compilers\pic\bin\xc8.exe --chip=16F18875 "analougue test 2.01.c" --MSGDISABLE=359,1273,1388
Microchip MPLAB XC8 C Compiler (Free Mode) V1.41
Build date: Jan 24 2017
Part Support Version: 1.41
Copyright (C) 2017 Microchip Technology Inc.
License type: Node Configuration
analougue test 2.01.c: main()
1245: FCV_REGISTER_ADPCH;
^ (192) undefined identifier "FCV_REGISTER_ADPCH"
(908) exit status = 1
(908) exit status = 1
C:\Program Files (x86)\Flowcode 7\compilers\pic\bin\xc8.exe reported error code 1
FINISHED
have I done something stupid

input connected to E0 - pin 8 still (AN32)
Steve
Success always occurs in private and failure in full view.