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

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

Postby PIC-Speed32 » Tue Oct 09, 2012 11:46 am

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: 14313
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4405 times
Been thanked: 4128 times
Contact:

Re: PIC18F46K80 ADC Config Adcon1 in C-Code

Postby Benj » Wed Oct 10, 2012 10:20 am

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.52 KiB) Downloaded 138 times


And copy this file into "v5/CAL/PIC/"
PIC_CAL_ADC.c
(92.79 KiB) Downloaded 128 times


Let me know how you get on.
These users thanked the author Benj for the post:
PIC-Speed32 (Wed Oct 10, 2012 11:53 am)
Rating: 5.26%
 

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

Postby PIC-Speed32 » Wed Oct 10, 2012 11:07 am

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

Postby PIC-Speed32 » Sat Oct 13, 2012 8:39 am

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: 14313
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4405 times
Been thanked: 4128 times
Contact:

Re: PIC18F46K80 ADC Config Adcon1 in C-Code

Postby Benj » Tue Oct 16, 2012 11:47 am

Hello Uwe,

Please try this updated PIC CAL ADC file and see if this helps to solve the problem.

PIC_CAL_ADC.c
(92.86 KiB) Downloaded 106 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

Postby PIC-Speed32 » Tue Oct 16, 2012 5:30 pm

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

Postby PIC-Speed32 » Tue Oct 16, 2012 5:40 pm

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

Postby PIC-Speed32 » Wed Oct 17, 2012 10:31 am

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
(48 Bytes) Downloaded 97 times

User avatar
Benj
Matrix Staff
Posts: 14313
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4405 times
Been thanked: 4128 times
Contact:

Re: PIC18F46K80 ADC Config Adcon1 in C-Code

Postby Benj » Wed Oct 17, 2012 1:55 pm

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

Postby PIC-Speed32 » Wed Oct 17, 2012 4:03 pm

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 106 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

Postby PIC-Speed32 » Thu Oct 25, 2012 9:11 am

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