Float Calculation Always shows incorrect in HW [Solved]
Moderator: Benj
- QMESAR
- 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]
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 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
attached is the Flowchart
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 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
attached is the Flowchart
- Attachments
-
- 3.jpg (21.93 KiB) Viewed 8801 times
-
- 2.jpg (43.69 KiB) Viewed 8801 times
-
- 1.jpg (41.38 KiB) Viewed 8801 times
-
- FC Test Proj.rar
- (72.5 KiB) Downloaded 225 times
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- QMESAR
- 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
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
Noticced the famous 0.00000059 value
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
Noticced the famous 0.00000059 value
- Attachments
-
- 1.jpg (37.89 KiB) Viewed 8793 times
-
- 2.jpg (97.75 KiB) Viewed 8795 times
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- QMESAR
- 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
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 ?
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 (79.86 KiB) Viewed 8790 times
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- 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
Thanks for your investigations, looks like we have some work to do!
- QMESAR
- 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
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 ,
regarding your comment I take it there will be no fix soon so I have to live without it ?
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Matrix Staff
- Posts: 9521
- 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
I did post this
If its the same bug, then maybe the way reported bugs are dealt with should be reviewed?
If its the same bug, then maybe the way reported bugs are dealt with should be reviewed?
Martin
- QMESAR
- 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
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
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
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- 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
I've checked the USB comms and it looks like the data is being collected OK,I take it there will be no fix soon so I have to live without it ?
The issue is now with the exe team, I will update when we have news
Leigh
- QMESAR
- 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
Leigh.
Thank you very much I appreciate this
Thank you very much I appreciate this
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Matrix Staff
- Posts: 9521
- 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
Nearest I have got is 16F1789.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
I will try with that tonight.
Martin
Martin
- QMESAR
- 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
Martin Thank you very much I will apprecaite that.medelec35 wrote:Nearest I have got is 16F1789.
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
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- 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
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Matrix Staff
- Posts: 9521
- 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
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
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 201 times
Martin
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- QMESAR
- 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
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
I only try to get the best out of my Flowcode
Why I have a feeling you guys are mad at me
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- 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
Hi Peter,
Not at all
Always good to find and fix problems especially if they are causing issues.
Thanks again for finding and reporting it's very much appreciated
Not at all
Always good to find and fix problems especially if they are causing issues.
Thanks again for finding and reporting it's very much appreciated
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- QMESAR
- 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
Team.
Now I feel better again Thank you
Now I feel better again Thank you
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- QMESAR
- 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
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 (30.19 KiB) Viewed 8718 times
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- QMESAR
- 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
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
A big Thank you guys I really appreciate this.
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
A big Thank you guys I really appreciate this.
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR