Page 1 of 1

ADC's returning a zero value

Posted: Fri Feb 07, 2020 9:38 pm
by ianjoh
This works perfect in simulation as always!
when compiled to chip it fails to read the ADC voltage as it always returns a zero on A0, A1 & A2 inputs.
I put a test calculation (500) on variable RAW_MAP, if I put it before reading the ADC I get zeros on the LCD, put it after and I get numbers, not the correct percentages because of other variables being at zero but it proves the adc is at fault. There may be something in the configuration that is not right as this is my first play with this pic.
Thanks
Ian

Re: ADC's returning a zero value

Posted: Fri Feb 07, 2020 11:43 pm
by ianjoh
Just updated from 8.1 to 8.2 and I now get errors when compiling as below so something is not right, over to a genius I think!



Target folder: C:\Users\ianjo\Dropbox\T4PROJ~1
Source name: C:\Users\ianjo\Dropbox\T4 project\SENSOR_READER_INTEGER_ADC1_v2.fcfx
Title:
Description:
Device: PIC.18F.18F25Q10
Generated by: Flowcode v8.2.0.12
Date: Friday, February 07, 2020 22:26:05
Users: 1
Registered to: ianjoh
License key: DTHTBY
NOT FOR COMMERCIAL USE
https://www.matrixtsl.com
Launching the compiler...
C:\Program Files (x86)\Flowcode\Common\Compilers\pic\batch\pic_xc8_comp.bat 18F25Q10 "C:\Users\ianjo\Dropbox\T4PROJ~1\" "SENSOR_READER_INTEGER_ADC1_v2"

C:\Users\ianjo\Dropbox\T4PROJ~1>C:\PROGRA~2\Flowcode\Common\COMPIL~1\pic\batch\..\bin\xc8.exe --chip=18F25Q10 "SENSOR_READER_INTEGER_ADC1_v2.c" --MSGDISABLE=359,1273,1388 --FLOAT=32 --DOUBLE=32
Microchip MPLAB XC8 C Compiler (Free Mode) V1.45
Build date: Nov 15 2017
Part Support Version: 1.45
Copyright (C) 2017 Microchip Technology Inc.
License type: Node Configuration

C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC\PIC_CAL_ADC.c: FC_CAL_ADC_Enable()
1805: ADCON1bits.VCFG0 = 1;
^ (255) not a member of the struct/union ""
^ (182) illegal conversion between types
int -> volatile union S578
(908) exit status = 1
(908) exit status = 1

Error returned from [xc8.exe]

C:\Program Files (x86)\Flowcode\Common\Compilers\pic\batch\pic_xc8_comp.bat reported error code 1

Autoclose turned off


FINISHED

Re: ADC's returning a zero value

Posted: Sat Feb 08, 2020 11:53 am
by medelec35
Hi ianjoh,
Flowchart posted compiles for me OK and I'm using 8.2.1.12 built Aug 6 2019.
What about doing a full update?
Select Help, Check for updates.
Change from Files in-use to full database.
Update, then select reload (third icon from the left).

Re: ADC's returning a zero value

Posted: Sat Feb 08, 2020 2:23 pm
by ianjoh
Thanks Martin, that has cured the compile problem but still not getting any value from the ADC. I have set up another input to convert to a byte value and print as a number to the lcd as I am more familiar with this method but I still get zero on the lcd. I have played with the watchdog and anything else in the setup just to get a change. I am a bit stumped at the moment!

Re: ADC's returning a zero value

Posted: Sat Feb 08, 2020 5:55 pm
by medelec35
You're welcome.
If you have use ReadAsByte then sent byte value to LCD & you are using the correct pin with say the pin pulled to VDD.
If the display is showing 0 then I will be unable to help as could be to do with ADC code.
Maybe best waiting for Matrix staff to help resolve your issue.

Re: ADC's returning a zero value

Posted: Sat Feb 08, 2020 10:22 pm
by ianjoh
Thanks Martin, I think my options have been exhausted as I tried a few new pins just in case I had fried the ones I was testing. Shame as I was quite excited to fire up my salvaged 40x4 display, this is an Optrex display and unusually required bits 4 to 7 for data in 4 bit mode and looks good with just the fixed strings printed on it.
Ian

Re: ADC's returning a zero value

Posted: Mon Feb 10, 2020 11:28 am
by Benj
Hello,

I've been through the ADC conversion routines for the Q10 devices and found and fixed some issues. fingers crossed this will solve the problem for you. The new file is now available via the update system.

Re: ADC's returning a zero value

Posted: Mon Feb 10, 2020 12:39 pm
by ianjoh
Hi Ben
There is no difference with the update.
I have attached the latest file as have made a few changes and I may have inadvertently changed some of the configuration settings.
thanks
Ian

Re: ADC's returning a zero value

Posted: Mon Feb 10, 2020 1:11 pm
by Benj
Hi Ian,

Ok thanks I've had another go for you, fingers crossed again. It's a totally new ADC onboard this device so it's a bit of digging around in the dark to get t working.

In the device config settins you might also want to disable LVP as this can potentially cause problems when enabled. Also I can't find which pin this is connected to to see if there is a collision with your program.

Re: ADC's returning a zero value

Posted: Mon Feb 10, 2020 1:57 pm
by ianjoh
Hi Ben
Still no joy!
I need to place on order today for some other unrelated components, is there a similar spec pic (32kb) that you know would be plug and play for this code that I can add to the order, just to get me going.

Happy to post this non worker to you to if that helps.
Thanks
Ian