PIC18F46K80 ADC Config Adcon1 in C-Code

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
PIC-Speed32
Posts: 33
Joined: Tue May 08, 2012 3:48 pm
Location: Germany
Has thanked: 7 times
Contact:

PIC18F46K80 ADC Config Adcon1 in C-Code

Post by PIC-Speed32 »

Hello all.

i have a problem with converting thinks from the datesheet in to C-Code for the PIC18F46K80 ADC Config Adcon1.
Pleas could someone help me out, i just need to know how to convert the 0-8 BIT to programm in Flowcode V5.

Best regards,

Uwe Kapuschinski

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: PIC18F46K80 ADC Config Adcon1 in C-Code

Post by Benj »

Hello,

I think I have found the ADC related bug that was causing the issue.

Please copy the files below into your Flowcode install folder before starting Flowcode and hopefully the ADC should work correctly for you now.

Extract and copy these files into "v5/FCD/"
18FxxK80.zip
(50.51 KiB) Downloaded 322 times
And copy this file into "v5/CAL/PIC/"
PIC_CAL_ADC.c
(88.76 KiB) Downloaded 318 times
Let me know how you get on.

PIC-Speed32
Posts: 33
Joined: Tue May 08, 2012 3:48 pm
Location: Germany
Has thanked: 7 times
Contact:

Re: PIC18F46K80 ADC Config Adcon1 in C-Code

Post by PIC-Speed32 »

The ADC query works.
New problem:
The ADC value overwrites a string variable S minvalue (29) has nothing to do with the ADC value S ADC0 (20). I have therefore created a new variable S Analog1 (20), the ADC is in the macro for the first time used. The second time it is used in the serial output.
Now another variable is maxvalue S (20) which has to do with anything overwritten.


Thanks in advance Uwe

PIC-Speed32
Posts: 33
Joined: Tue May 08, 2012 3:48 pm
Location: Germany
Has thanked: 7 times
Contact:

Re: PIC18F46K80 ADC Config Adcon1 in C-Code

Post by PIC-Speed32 »

Hi, I have a problem.

First The PIC18F46K80 has 12 bit analog inputs. In PIC_Cal_ADC_c for this PIC family only 10 and 8 is provided. (As far as I understand it)

Second The PIC has differential inputs as analog input.
That means it can directly measure the voltage between 2 analog inputs.
Here come out and negative voltage values​​.
Which may be determined by the configuration.
E.G. all I can say is AN0 + and An1 is -. Then I can put a 1.5 volt battery dierkt to both terminals and get a mere 1.5 volts + or when the battery is rotated 1.5 volts -.
In my project I do not need that.
I do not know whether the V5 already configured Sun

My problem:
I measure ADC2. ADC2 is connected to the PIC leg AN6. ADC2 has a reference VDD 500 x 10mV Fosc/64.
The connection is now connected to 0Volt. The measurement shows me at 4.99??
If the input is open, returns the value fluctuates and as is usual for an open entrance.

with kind regards
Uwe

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: PIC18F46K80 ADC Config Adcon1 in C-Code

Post by Benj »

Hello Uwe,

Please try this updated PIC CAL ADC file and see if this helps to solve the problem.
PIC_CAL_ADC.c
(88.84 KiB) Downloaded 291 times
Let me know how you get on.

PIC-Speed32
Posts: 33
Joined: Tue May 08, 2012 3:48 pm
Location: Germany
Has thanked: 7 times
Contact:

Re: PIC18F46K80 ADC Config Adcon1 in C-Code

Post by PIC-Speed32 »

Hi Benj,

my main problem is still present.
At 0 V input voltage to get 4.99 Displayed.
That was the reason to test it with Microbesic Pro.
Micro Basic shows here really to 0.

Therefore, I know that my hardware is ok.
There is still a bug.

Sincerely
Uwe

PIC-Speed32
Posts: 33
Joined: Tue May 08, 2012 3:48 pm
Location: Germany
Has thanked: 7 times
Contact:

Re: PIC18F46K80 ADC Config Adcon1 in C-Code

Post by PIC-Speed32 »

Hi Benj,

again.
I had changed the file already.
I had (TYPE 28) copies to (TYPE 32).
This was the same result.

Can make the compiler a mistake?

Sincerely
Uwe

PIC-Speed32
Posts: 33
Joined: Tue May 08, 2012 3:48 pm
Location: Germany
Has thanked: 7 times
Contact:

Re: PIC18F46K80 ADC Config Adcon1 in C-Code

Post by PIC-Speed32 »

Hello Benj.

Here a file can help.
The software reads only once the ADC port.
I hope this helps.

Sincerely
Uwe
Attachments
PIC18F46K80.mbppi_callertable.txt
(44 Bytes) Downloaded 284 times

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: PIC18F46K80 ADC Config Adcon1 in C-Code

Post by Benj »

Hello Uwe,

Please can you post your flowchart so I can try and see what's going wrong for you.

PIC-Speed32
Posts: 33
Joined: Tue May 08, 2012 3:48 pm
Location: Germany
Has thanked: 7 times
Contact:

Re: PIC18F46K80 ADC Config Adcon1 in C-Code

Post by PIC-Speed32 »

Hi Benj,
in Main
Macro is measured in the ADC call.
Prozent_Wert in the output.

Sincerely
Uwe
Attachments
HTK6fcf.fcf
(203.83 KiB) Downloaded 275 times

PIC-Speed32
Posts: 33
Joined: Tue May 08, 2012 3:48 pm
Location: Germany
Has thanked: 7 times
Contact:

Re: PIC18F46K80 ADC Config Adcon1 in C-Code

Post by PIC-Speed32 »

ADC PIC18f46K80

Sent: Thu Oct 25, 2012 8:09 am
From: PIC-Speed32
To: Benj
hi Benj.
sorry I'm writing again
is there a solution?
I have not heard anything.
Please see (viewtopic.php? f = 40 & t = 11366)
I have made new measurements.
The PIC is not set correctly

Sincerely
Uwe

Post Reply