Page 1 of 1

Float Calculation Always shows incorrect in HW [Solved]

Posted: Tue Jan 09, 2018 9:21 am
by QMESAR
Hi guys
PIc16F1937
As you will see when I read an Analog Pin (getAvgInt())and do a float calculation in Simulator it works fine however when using HW and Ghost (EB006V9)
the float result always show 0.0000000000059 :D although the getAvgInt() function returns a good value, The same thing happens when you do a GetVoltage() ADC read the returned Voltage always show 0.00000000059, I also tried doing a explicit type cast to float ! The reason I tried to calculate the voltage myself is that the getVoltage() adc call returns the same o.0000059 value .Please can you help out here I feel like spamming the Forum with all my reports :oops:
attached is the Flowchart
:D

Re: Float Calculation Always shows incorrect in HW

Posted: Tue Jan 09, 2018 10:07 am
by QMESAR
Hi Guys
Hete I have made a screen print of the getVoltage ADC call you will see the flaot returned is 0.0 in the debug window and I also add a multi meter print of the voltage at AN0 pin ,if I do a getAvgInt read on the pin it shows the equivalent value of the multi meter value in bits that is fine , my problem with FC and the Ghost is float calculations and the ADC call getvoltage() in my humble opinion they do not work I need your help to show me what I do incorrect or fix the problem :D
Noticced the famous 0.00000059 value

Re: Float Calculation Always shows incorrect in HW

Posted: Tue Jan 09, 2018 10:38 am
by QMESAR
Hi Guys

Update I can confirm it is again the famous Ghost /ICD that is causing the issue
(1)I read the ADC with getAvgInt and GetVoltage and then write the value out on the UART perfect correct that means that the float calculations and the get Voltage function is working but you can not see it in the ICD

I am asking myself what is the value of the ICD in FC it just does not work on each and every chip
Note below I write out the voltage value on the UART (it is not degree C as I just use this position to TX the float value of the ADC

the big question now is what should I do keep on struggling to see the variable with a non working ICD or is there a fix from your side ?

Re: Float Calculation Always shows incorrect in HW

Posted: Tue Jan 09, 2018 11:00 am
by LeighM
Thanks for your investigations, looks like we have some work to do! :roll:

Re: Float Calculation Always shows incorrect in HW

Posted: Tue Jan 09, 2018 12:18 pm
by QMESAR
:D
I believe you Leigh however I heard these words a few times since FC6 and an official promise the ICD will be fixed in FC7 , :shock:
regarding your comment I take it there will be no fix soon so I have to live without it ? :D

Re: Float Calculation Always shows incorrect in HW

Posted: Tue Jan 09, 2018 12:39 pm
by medelec35
I did post this
If its the same bug, then maybe the way reported bugs are dealt with should be reviewed?

Re: Float Calculation Always shows incorrect in HW

Posted: Tue Jan 09, 2018 2:31 pm
by QMESAR
Hi Martin.

If possible and you have a device PIC16F1783/4/6 can you try to use the ICD ,It is working but with great difficulty on my side
It takes some time 3 to compile and programming with ICD ON then it would connect ,if connected the variables does not show what I would expect
then if you run and pause and run again it will loose the connection and I have to program the device again.

I would appreciate if someone can confirm that it is working properly with them or they also see these problems,I am using PICkit3 and EB006V9 as the Ghost/ICD/ICT device as the Flowkit2 will not work at all
I will appreciate any efforts to confirm or refute my claim :D

Re: Float Calculation Always shows incorrect in HW

Posted: Tue Jan 09, 2018 3:25 pm
by LeighM
I take it there will be no fix soon so I have to live without it ?
I've checked the USB comms and it looks like the data is being collected OK,
The issue is now with the exe team, I will update when we have news
Leigh

Re: Float Calculation Always shows incorrect in HW

Posted: Tue Jan 09, 2018 4:30 pm
by QMESAR
Leigh.
Thank you very much I appreciate this :D

Re: Float Calculation Always shows incorrect in HW

Posted: Wed Jan 10, 2018 7:11 am
by medelec35
QMESAR wrote:Hi Martin.

If possible and you have a device PIC16F1783/4/6 can you try to use the ICD ,It is working but with great difficulty on my side
Nearest I have got is 16F1789.
I will try with that tonight.

Martin

Re: Float Calculation Always shows incorrect in HW

Posted: Wed Jan 10, 2018 7:41 am
by QMESAR
medelec35 wrote:Nearest I have got is 16F1789.
Martin Thank you very much I will apprecaite that.
I am programming with PICKIT3 and the device is in EB006V9 then after programming I switch the ICSP Bridge to USB and then reset and run the Ghost ,
This works fine one some other 8 biters but the 16F1786 I have it is very unstable .Although I also tried my Flowkit 2 and the symptoms are the same so I am in doubt if it is the setup causing the issue I also made sure it has an Chrystal clock on board as we have seen in the past that the INTOSC is an issue for FC ICD,

Thanks a million appreciated :D

Re: Float Calculation Always shows incorrect in HW

Posted: Wed Jan 10, 2018 12:59 pm
by Benj
We have begun to dig into this and have found that the XC8 compiler treats floats as a 24-bit value rather than the more standardised 32-bit value. There is a simple flag to force the compiler to use the 32-bit type so we are just testing this now to see if it solves the problem.

Re: Float Calculation Always shows incorrect in HW

Posted: Wed Jan 10, 2018 1:08 pm
by medelec35
Hi I have tested with 16F1789, EB006 V9 & EB083
ICD runs just fine with the attached Flwochart.
Its just a very basic Quad 7SEG counter.

Martin

Re: Float Calculation Always shows incorrect in HW

Posted: Wed Jan 10, 2018 1:13 pm
by Benj
Right confirmed this does solve the problem, sorry it took so long Martin :?

Simply add the following to the end of the compiler parameters.

--FLOAT=32 --DOUBLE=32

Current parameters
--chip=$(chip) "$(target).c" --MSGDISABLE=359,1273,1388

New parameters
--chip=$(chip) "$(target).c" --MSGDISABLE=359,1273,1388 --FLOAT=32 --DOUBLE=32

Currently we think it's just 8-bit PICs that are effected, just checking the other variants now.

Edit. XC16 and XC32 use 32-bit IEEE-754 by default so these should be ok as is.

Re: Float Calculation Always shows incorrect in HW

Posted: Wed Jan 10, 2018 1:24 pm
by QMESAR
Hi Ben I just hope you guys are not angry with me
I only try to get the best out of my Flowcode
Why I have a feeling you guys are mad at me :shock:

Re: Float Calculation Always shows incorrect in HW

Posted: Wed Jan 10, 2018 1:26 pm
by Benj
Hi Peter,

Not at all :D

Always good to find and fix problems especially if they are causing issues.

Thanks again for finding and reporting it's very much appreciated :mrgreen:

Re: Float Calculation Always shows incorrect in HW

Posted: Wed Jan 10, 2018 1:27 pm
by QMESAR
Team.
Now I feel better again :) Thank you

Re: Float Calculation Always shows incorrect in HW

Posted: Wed Jan 10, 2018 1:32 pm
by QMESAR
Guys now I see a new message which makes me happy and I will test the project when back at my Lab

Re: Float Calculation Always shows incorrect in HW

Posted: Fri Jan 12, 2018 5:10 am
by QMESAR
Hi Team.
I can confirm that the setting of the compiler flag for float treatment is working fine with us too !!and I can debug now properly with Ghost and ICD.
My gratitude and appreciation to Leigh and Ben for fixing this up and also putting up with me :D
A big Thank you guys I really appreciate this.
:D :D :D
111.jpg
111.jpg (63.26 KiB) Viewed 8349 times