Page 1 of 1

PIC16F17xx ADC Components [Solved]

Posted: Mon Jan 08, 2018 7:25 am
by QMESAR
Hi Team.

After fixing a few things on this device family we have the next issue ,
(1) you will see in the attachment the ADC is specified as 10 bit which it is not it is a 12 bit Converter.
(2) None of the ADC reads work ,I have tried them all on real HW (EB006 with various voltage at various AN pins)
Note I can see the captures in Ghost .

Please can you try to find a solution I need to capture AN0 -AN5 on a PIC16F1786 this is urgently now Please.I can get the ADC to work by manually setting it in a C call however as you know then I loose Ghost function as the ICD then loose track of the program ,I am not sure if this is an issue
or not however on a few projects I noticed that as long as you use FC componets the ICD will follow suite of the code once you add a C call then when running the ICD it rus but it ends up in the code somewhere which a person can not track

:D :D
Note below a capture of trying the Raw read however I tried All function calls none work on this chip.

Re: PIC16F17xx ADC Components

Posted: Wed Jan 10, 2018 6:58 am
by QMESAR
Hi Team

Besides the issue with the PIC17F1937 this issue is also still open with the ADC on the PIC16F17XX devices.
Here had a few issues
(1) Timer2 prescalers not allowing for 64 setting(fixed by Ben)
(2) UART Compile errors (fixed by Leigh)
(3) PWM error (fixed by Ben)
(4) ADC not working bit depth shown also incorrect it is a 12 bit converter.(Open)

ADC not working at all ,issue still open and I can not go forward with customer project ,just as a matter of interest the ICD/Ghost is working only about 5% it is unstable and not usable on this chip (Flowkit2 and EB006).The issue with the ICD is that you need to compile to chip several times before the ICD will connect after a reset and then when it is running and you pause and run again the famous popup message appear the Chip does not contain the latest build :D

Re: PIC16F17xx ADC Components

Posted: Wed Jan 10, 2018 10:36 am
by LeighM
Hi,

I've had a look at the FCD and CAL code and I cannot yet see what the issues might be.
Despite the ADC component showing 10 bit, the correct 12 bit flag is generated. (I'll look into that separately)

Code: Select all

#define MX_ADC_BITS_12 
So the ADC functions should return 12 bits.

Could you post the C code that you use to get it working?

btw. Was that a typo about AN5? I don't see one on this 28 pin device.

Thanks!
Leigh

Re: PIC16F17xx ADC Components

Posted: Wed Jan 10, 2018 10:45 am
by QMESAR
Hi leigh

yes that was a type I use AN0, AN1 and AN2.
I will post the C code as I am out of my office today at a customer location will update tomorrow.$
Thanks for looking at this

Re: PIC16F17xx ADC Components

Posted: Wed Jan 10, 2018 4:16 pm
by QMESAR
Hi Leigh.

Here is the MPLABx Project in which you will see the ADC is working ,I tried both 12bit and 10 bit conversions.
In Flow code what concerns me is that the ANSELA andANSEL B shows 0 and from MPLAB Code configuration ANSELA has 0xBF (only AN0 is configured so it is correct in my opinion.
FC_1.jpg
FC_1.jpg (44.94 KiB) Viewed 7726 times
As you see here the ADC is working and the values of the configuration registers.Note that it is possible to set 10 or 12 bit conversion on this chip with 2 complements or signed values as return from the ADC (Right and left justified) also I think FC set the ADCON2 register incorrectly which selects the ANDREF ADC Negative Reference VSS or a AN Channel
MPLAB.jpg
MPLAB.jpg (73.02 KiB) Viewed 7726 times
MPLAB project attached you can use it or the hex file to test if my findings are valid
FC_2.jpg
FC_2.jpg (76.43 KiB) Viewed 7726 times

Re: PIC16F17xx ADC Components

Posted: Thu Jan 11, 2018 6:57 am
by QMESAR
Leigh.
Here is a FC project which I included the settings for the ADC in a C call and it runs prefect ,however no go with the FC ADC component there
is certainly something wrong with it

:D
pic1023.jpg
pic1023.jpg (76.98 KiB) Viewed 7709 times

Re: PIC16F17xx ADC Components

Posted: Thu Jan 11, 2018 11:21 am
by LeighM
Hi,

Comparing your register settings with ours, two differences:
You have ADFM set, so result is in 2's compliment, not sign-magnitude
You have ADRMD set, result is 10 bit, not 12 bit
So the result meaning will be different.
I'll need to have a chat with Ben to see what we think about supporting these options

I think you have something of note with the...

Code: Select all

ADCON2 = 0x0F;
looks like that is needed to set the Negative Ref to be selected by ADNREF

Could you try just adding that one code line to the Flowcode component test?

Thanks
Leigh

Re: PIC16F17xx ADC Components

Posted: Thu Jan 11, 2018 1:32 pm
by QMESAR
Leigh
As I have pointed out this is the settings in my post I also pointed out that 12 bit mode works when I configure it in C code
I tried both 12bit and 10 bit conversions.
just read my post on about Mplab and you will see this however the standard 12bit signed mode in FC does not work I can set the ADC in C code up anyway I want and it is working :D

Both options is not the problem just get one working and signed mode is left justified and right justified options and it is working in MPLAB
The point remains when using the FC component for ADC it does not WORK ,and that is all we need if it is working with 12 bit signed conversion fine
just make the FC component to work.
Question did you ran FC code on a chip and variified the component is working I do not think so if you did you will see I am not trying to waste your time ,the component does simply not work and my exrecise demonstrated that by configuring the ADC manually it is working 10bit 12bit signed and 2 compliment I just do not have the time to document that all and post in the forum .

Re: PIC16F17xx ADC Components

Posted: Tue Jan 16, 2018 11:28 am
by Benj
Hello,

I believe I might have made some progress on this problem.

I have now added a new ADC type in the CAL C code which now correctly assigns the negative reference as VSS.

I've also added the missing ADC channel 21 to the 40 pin devices and gone back through the ADC components and ensured the bit depth is now set correctly.

First extract the following files to your "Flowcode 7/components" folder.
components.zip
(59.14 KiB) Downloaded 264 times
Next extract the following files to your "Flowcode 7/FCD/PIC" folder.
PIC.zip
(36.74 KiB) Downloaded 254 times
Finally copy the file below to your "Flowcode 7/CAL/PIC" folder.
PIC_CAL_ADC.c
(124.36 KiB) Downloaded 265 times
Let us know how you get on.

Re: PIC16F17xx ADC Components

Posted: Tue Jan 16, 2018 12:59 pm
by QMESAR
Hi Ben.

Thank you very much .This is appreciated I confirm that the ADC component with 12 bit resolution is working fine for me now .
:D :D :D
114.jpg
114.jpg (66.49 KiB) Viewed 7627 times

Re: PIC16F17xx ADC Components [Solved]

Posted: Wed Jan 17, 2018 5:23 pm
by jgu1
Hi all!

I'm not hardcore. But do I understand this correct, is this new bugs?, Would you recommend all FC7 user to replace these files.

And again, I would be really happy If all corrected bug where placed in one lokation. :wink:

Thank` in advance.

Jorgen

Re: PIC16F17xx ADC Components [Solved]

Posted: Thu Jan 18, 2018 6:25 pm
by Benj
Hi Jorgen,

I would only advise the update if:

a) You are using the specific chip, CAL or component with a known bug that has been fixed
b) You are not working on a commercially sensitive project that is currently working with a looming deadline
c) You want to stay up to date with all the latest features and fixes.

I've now created a new updates since 7.3 topic here to simplify keeping up to date. Thanks for the prod to do the work :wink: it's one of those things that is very easy to put off until tomorrow and as we all know, tomorrow never comes.
viewtopic.php?f=63&t=19743

Re: PIC16F17xx ADC Components [Solved]

Posted: Thu Jan 18, 2018 8:07 pm
by jgu1
Hi Ben!

Perfect, perfect Ben, thank you.
You must tell me if I am too annoying. I just want, and try to have my FC7's 100 % up to date. :D :D :D
I am very grateful to you for the effort you and the MM team are doing.

Maybe at next update, add this, if possible Martin´s nice creation of MAX7219 component from here: viewtopic.php?f=66&t=19356&start=25 working perfect.


Thank´s

Jorgen