ADC Component change ref voltage

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

medelec35
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

Post by medelec35 »

Hi Steve,
If you compare side by side the register you did (Branch 1) with and existing register I did (Branch 2) with the C code there is a difference in format:
Register differences.png
(23.68 KiB) Downloaded 6779 times
Martin
Martin

Steve001
Valued Contributor
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

Post by Steve001 »

right a better result tonight :lol:

register ADPCH

Scope volts on AN32 - E0 225.1 mv

pass 1 251
pass 2 128
pass 3 255
pass 4 235
pass 5 162
pass 6 214

no binary values displayed

Steve
Success always occurs in private and failure in full view.

medelec35
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

Post by medelec35 »

Hi steve I'm away for the weekend. So only got mobile.
Since ADPCH enables the required ADC channel then from memory with value left as zero then only An0 is active.
I did suspect that hence the reason for connecting the pot to An0 pin.
I thought if a voltage is applied to An0 pin the correct ADC value word be shown.
Maybe this is one for Matrix staff to sort out, but I will see if I can find out why correct values are not being transferred to ADPCH on sunday evening when back home if not too late.

Martin
Martin

Steve001
Valued Contributor
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

Post by Steve001 »

Hi Martin


No problem. Have a good weekend. Thanks for all your help.

Steve
Success always occurs in private and failure in full view.

medelec35
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

Post by medelec35 »

Hi Steve.
I have had a look at PIC_CAL_ADC.c and it looks like the ADC channels only go up to 24 whereas your device has got 34
ADC channels.
As you was selecting ADC channel 32 then PIC_CAL_ADC.c would not be picking it up.
Can you select a ADC channel higher than 0 but lower than 24.
Connect pot to it, then recompile.
If you can't connected a pot to an ADC channel lower than 24, then I can add ADC channel 32 to PIC_CAL_ADC.c and send it to you.

Don't know if any other issues until the above is tried.

Martin
Martin

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: ADC Component change ref voltage

Post by LeighM »


Steve001
Valued Contributor
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

Post by Steve001 »

Evening All,

Struggling again :?

using the "read ADC voltage as string example " in the tutorials - this works ok correct readings but my input voltage is 220mv

Adding a c code icon with "FVRCON = 0x81;"

and changing the VREFOP to FVR and Vrefvol to 102

didn't give the expected results the voltage displayed is 1.018890V and doesn't seam to change

reading the data sheet bit ambiguous and confusing

When you start using FVR module is this only available on ADC1 ? as the data sheet seams to indicate this see page 266 onwards (cannot find the exact spot where I read this now sorry)

data sheet here

http://www.farnell.com/datasheets/22452 ... 1501615565

haven't tried martins program to read the registers yet will have another go tomorrow with that

should RA3 (pin 5) be outputting 1.024 Volts ? as it was all over place on my scope

Steve
Success always occurs in private and failure in full view.

medelec35
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

Post by medelec35 »

Hi Steve,
Steve001 wrote:Adding a c code icon with "FVRCON = 0x81;"

and changing the VREFOP to FVR and Vrefvol to 102

didn't give the expected results the voltage displayed is 1.018890V and doesn't seam to change
No it won't as FVRCON is set within ADC component.
So any FVRCON or other registers set, the ADC component will override them.

I have posted about that here.
It was not for your target device, but principle will still be the same.

Martin
Martin

Steve001
Valued Contributor
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

Post by Steve001 »

Hi Martin

struggling again and getting confused :?

after looking at the component as you suggested (didn't mean much i must admit)

Code: Select all

		switch (Vref)
		{
			case 1:		// Vref selected
				ADCON1 |= 2;
				break;
			case 2:		// FVR selected
				ADCON1 |= 3;
				FVRCON |= 0x81;		// ADC FVR output is enabled, 1x (1.024V)
				break;
			default:	// VDD selected
				break;
dose this mean that the component supports a setting of the FVR ?

i have tried several things now , and made a test circuit on a EB17 pcb - Attached
but cannot get it to work when trying to set fvr to 1.0124 volts

the correct voltage is displayed when set at 5 vcc can read 1.024 & 2.5 volts

do you have any ideas ? as i am at a total loss now

steve

:edit - drawing for reference only
Success always occurs in private and failure in full view.

medelec35
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

Post by medelec35 »

Hi Steve,
Select properties of POT and make sure you have FVR selected within Vref option.
I have had a go at changing C code within PIC_CAL_ADC.c
Looking at the Code what Ben suggested should have worked and what I said should not apply.
If properties was not on FVR, after changing just recompile.

Just in case does not work?
Can you make a back up copy of PIC_CAL_ADC.c
As C is not my strong point, I'm not sure if altered it correctly or not?
Can place the attached PIC_CAL_ADC.c in \Flowcode 7\CAL\PIC directory.
Then if Flowcode is loaded, just hit the Reload icon
Recompile flowchart.

Hopefully will work?

Martin
Attachments
PIC_CAL_ADC.c
(118.8 KiB) Downloaded 274 times
Martin

Steve001
Valued Contributor
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

Post by Steve001 »

hi martin

Thanks for that will have a play next week and get back to you

Steve
Success always occurs in private and failure in full view.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: ADC Component change ref voltage

Post by LeighM »

Hi,
Thanks for your work Martin.
Both please use the attached, as I've removed the previous "switch" fix for FVR support,
as Ben has updated all the fcds and ADC component to fix this differently.
So attached should now work in all cases, just select FVR in the ADC component,
Let me know if you have any problems.
Leigh
Attachments
PIC_CAL_ADC.c
(118.62 KiB) Downloaded 280 times

Steve001
Valued Contributor
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

Post by Steve001 »

evening

am I been really stupid here and missing the point ? :( :?

cannot get a meaningful result from either test file

a 223.8 mv input shows 1024 or 1.0285.. volts ?

Steve
Success always occurs in private and failure in full view.

medelec35
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

Post by medelec35 »

Hi Steve,
You have got Vref+ selected within ADC properties not FVR.
After selecting FVR and recompiling, can you see what happens?

If it still does not work you could use the flowchart I developed for displaying registers.

I must admit im not sure about

Code: Select all

 if (Vref != 0)							//assign VREF functionality
			ADREF = ADREF | Vref;
Where Vref is being picked up from?
Could be what Leigh mentioned that's changed within FCD & ADC component?

Martin
Martin

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: ADC Component change ref voltage

Post by LeighM »

Hi,

Vref value gets passed into the CAL ADC Enable function...

Code: Select all

void FC_CAL_ADC_Enable (MX_UINT8 Channel, MX_UINT8 Conv_Speed, MX_UINT8 Vref, MX_UINT8 T_Charge)
The value of Vref is explicitly set by the selection of the Flowcode ADC component setting of the "VRef Option" property.
The "VRef Option" is a list of name / value pairs that are read from the target FCD <vref> section.

So the bits to be set in ADREF (in this case) come directly from the FCD.

Hope that helps,
Leigh

Steve001
Valued Contributor
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

Post by Steve001 »

thanks will have another go tonight and get back to you


steve
Success always occurs in private and failure in full view.

Steve001
Valued Contributor
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

Post by Steve001 »

working now ! :D

helps if you apply updates :oops:

http://www.flowcode.co.uk/mmforums/viewt ... 760#p80726

then swap the PIC cal ADC file above

Thank you for everyone's help

223.1 mv input

read as string file in above post 0.2228

read as int file in above post 219

Steve
Success always occurs in private and failure in full view.

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times

Re: ADC Component change ref voltage

Post by jadiflow »

Not sure how relevant this is, but I had the exact same issue in the past, which was resolved when support send me a new version of the PIC_cal_ADC file. Might be useful that you are using the revised version.

Jan Didden

Post Reply