Float Calculation Always shows incorrect in HW [Solved]

An area to discuss 8-bit PIC specific problems and examples

Moderator: Benj

Post Reply
User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Float Calculation Always shows incorrect in HW [Solved]

Post 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
Attachments
3.jpg
3.jpg (21.93 KiB) Viewed 8325 times
2.jpg
2.jpg (43.69 KiB) Viewed 8325 times
1.jpg
1.jpg (41.38 KiB) Viewed 8325 times
FC Test Proj.rar
(72.5 KiB) Downloaded 212 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Float Calculation Always shows incorrect in HW

Post 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
Attachments
1.jpg
1.jpg (37.89 KiB) Viewed 8317 times
2.jpg
2.jpg (97.75 KiB) Viewed 8319 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Float Calculation Always shows incorrect in HW

Post 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 ?
Attachments
1.jpg
1.jpg (79.86 KiB) Viewed 8314 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Float Calculation Always shows incorrect in HW

Post by LeighM »

Thanks for your investigations, looks like we have some work to do! :roll:

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Float Calculation Always shows incorrect in HW

Post 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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Float Calculation Always shows incorrect in HW

Post by medelec35 »

I did post this
If its the same bug, then maybe the way reported bugs are dealt with should be reviewed?
Martin

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Float Calculation Always shows incorrect in HW

Post 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

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Float Calculation Always shows incorrect in HW

Post 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

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Float Calculation Always shows incorrect in HW

Post by QMESAR »

Leigh.
Thank you very much I appreciate this :D

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Float Calculation Always shows incorrect in HW

Post 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
Martin

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Float Calculation Always shows incorrect in HW

Post 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

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: Float Calculation Always shows incorrect in HW

Post 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.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Float Calculation Always shows incorrect in HW

Post 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
Attachments
Basic counter EB083.fcfx
(12.05 KiB) Downloaded 188 times
Martin

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: Float Calculation Always shows incorrect in HW

Post 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.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Float Calculation Always shows incorrect in HW

Post 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:

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: Float Calculation Always shows incorrect in HW

Post 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:

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Float Calculation Always shows incorrect in HW

Post by QMESAR »

Team.
Now I feel better again :) Thank you

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Float Calculation Always shows incorrect in HW

Post by QMESAR »

Guys now I see a new message which makes me happy and I will test the project when back at my Lab
Attachments
FC PID.jpg
FC PID.jpg (30.19 KiB) Viewed 8242 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Float Calculation Always shows incorrect in HW

Post 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 8216 times

Post Reply