Hi,
I am developing a flowcode program to obtain a temperature reading using a thermistor. The basic principle is to interface the thermistor to an ADC input using a potential divider. The program reads the ADC value converts the ADC value to voltage across the thermistor and calculates the resistance of the thermistor. The temperature of the thermistor can then be calculate based on the resistance value. The equation relating resistance and temperature requires the log function.
The program runs fine in simulation mode.
However, when I try to Compile to Chip (for ECIO40), the following error messages are shown:
"unknown identifier log", and "arguments of FCI_SHEAD" don't match parameters of call.
Does anybody have experience of this type of problem, or any suggestions for means of resolving it?
Thank you,
patl02.
Problem with Log Function with ECIO40
Moderator: Benj
-
- 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: Problem with Log Function with ECIO40
Hi patl02.
ECIO does not support maths functions like LOG, SIN, TAN ATAN ect.
This is a limitation of BoostC compiler that is used within Flowcode when compiling 8bit microcontrollers .
There was talk about changing from BoostC to a different compiler just so additional maths functions can be supported.
only AVR, ARM and dsPIC support the maths functions you require.
For the ECIO you can use the look-up table method.
There are a few tutorial on using look-up tables in the Tips and Tricks section.
Although there is a dedicated look-up table component macro within Flowcode 6.
If you interested in using that I can help you with it.
If you want to use LUT method then Benj posted an excel sheet which makes life easier.
I adapted the spreadsheet for 5V rather than for MIACs
I will see If I still have the spreadsheet I used when I made a temperature sensor using a thermistor.
Another alternative is to use a different type of temperature sensor e.g LM34 see here
Martin
ECIO does not support maths functions like LOG, SIN, TAN ATAN ect.
This is a limitation of BoostC compiler that is used within Flowcode when compiling 8bit microcontrollers .
There was talk about changing from BoostC to a different compiler just so additional maths functions can be supported.
only AVR, ARM and dsPIC support the maths functions you require.
For the ECIO you can use the look-up table method.
There are a few tutorial on using look-up tables in the Tips and Tricks section.
Although there is a dedicated look-up table component macro within Flowcode 6.
If you interested in using that I can help you with it.
If you want to use LUT method then Benj posted an excel sheet which makes life easier.
I adapted the spreadsheet for 5V rather than for MIACs
I will see If I still have the spreadsheet I used when I made a temperature sensor using a thermistor.
Another alternative is to use a different type of temperature sensor e.g LM34 see here
Martin
Martin
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Problem with Log Function with ECIO40
In addition to Martin’s comments, there is also a bug in the string conversion for target code generation.
It occurs when numeric conversion is mixed with string concatenation (the FCI_SHEAD error)
We have a fix in the pipeline for the next release, but in the meantime you can work around this by separating any numeric to string conversion into a separate statement.
That is, only concatenate strings.
Regards,
Leigh
It occurs when numeric conversion is mixed with string concatenation (the FCI_SHEAD error)
We have a fix in the pipeline for the next release, but in the meantime you can work around this by separating any numeric to string conversion into a separate statement.
That is, only concatenate strings.
Regards,
Leigh
Code: Select all
result_string = "some text"
number_x = 1234
number_string = STRING number_x
result_string = result_string + number_string
- SteveM
- Posts: 55
- Joined: Tue Mar 25, 2014 2:09 pm
- Has thanked: 28 times
- Been thanked: 65 times
- Contact:
Re: Problem with Log Function with ECIO40
Hi patl02,
You might be able to make use of the file I posted in this post.. There's a macro to calculate the natural logarithm, ln(x), (i.e. a logarithm with base 'e'). You can convert the natural logarithm to a base 10 logarithm by simply dividing the answer by 2.302585 (that's the natural logarithm of 10 - in general, convert to another number base by dividing by the natural logarithm of the new number base). It uses only normal "8-bit" functions to zero in on an approximation, and has been tested before for compiling to an ECIO. Accuracy should be good to around five significant digits, which should be at least as good as interpolating a lookup-table, and should use less of the chip's memory (though it may be a little slower than an LUT).
Best regards,
Steve.
You might be able to make use of the file I posted in this post.. There's a macro to calculate the natural logarithm, ln(x), (i.e. a logarithm with base 'e'). You can convert the natural logarithm to a base 10 logarithm by simply dividing the answer by 2.302585 (that's the natural logarithm of 10 - in general, convert to another number base by dividing by the natural logarithm of the new number base). It uses only normal "8-bit" functions to zero in on an approximation, and has been tested before for compiling to an ECIO. Accuracy should be good to around five significant digits, which should be at least as good as interpolating a lookup-table, and should use less of the chip's memory (though it may be a little slower than an LUT).
Best regards,
Steve.
Re: Problem with Log Function with ECIO40
Hi Martin, Leigh and Steve,
Thank you all for your prompt replies. All of the information was very useful, and I have used the macro for the Taylor Series approximation for the Ln function successfully.
Best Regards.
patl02
Thank you all for your prompt replies. All of the information was very useful, and I have used the macro for the Taylor Series approximation for the Ln function successfully.
Best Regards.
patl02
- SteveM
- Posts: 55
- Joined: Tue Mar 25, 2014 2:09 pm
- Has thanked: 28 times
- Been thanked: 65 times
- Contact:
Re: Problem with Log Function with ECIO40
Hi,
Glad to hear you got everything working.
For those users using Flowcode6, you may also be interested to see another solution to the problem of using certain float functions on the smaller 8-bit PICS...
POST: Macro Library - Float Maths 8-bit
Best Regards,
Steve.
Glad to hear you got everything working.
For those users using Flowcode6, you may also be interested to see another solution to the problem of using certain float functions on the smaller 8-bit PICS...
POST: Macro Library - Float Maths 8-bit
Best Regards,
Steve.
-
- Posts: 243
- Joined: Tue Nov 27, 2012 12:53 pm
- Location: Cambridge, UK
- Has thanked: 140 times
- Been thanked: 118 times
- Contact:
Re: Problem with Log Function with ECIO40
Thanks Leigh.LeighM wrote:In addition to Martin’s comments, there is also a bug in the string conversion for target code generation.
It occurs when numeric conversion is mixed with string concatenation (the FCI_SHEAD error)
We have a fix in the pipeline for the next release, but in the meantime you can work around this by separating any numeric to string conversion into a separate statement.
That is, only concatenate strings.
Regards,
Leigh
Code: Select all
result_string = "some text" number_x = 1234 number_string = STRING number_x result_string = result_string + number_string
This build-time error was driving me nuts for a while until I found this thread (I was concatenating 'StringPhrase + ToString$(NumberVariable') within the LCD component print string box. As you suggest, I can confirm that pre-conversion of NumberVariable to NumberString, followed by simple concatenation of the two string variables StringPhrase + NumberString, fixed it
All the best,
Brendan
LinkedIn Profile...
http://www.linkedin.com/in/brendantownsend
http://www.linkedin.com/in/brendantownsend