Temperature reading 0.1 resolution

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
cobra1
Posts: 175
Joined: Thu Feb 04, 2010 7:44 am
Has thanked: 3 times
Been thanked: 3 times
Contact:

Temperature reading 0.1 resolution

Post by cobra1 »

Hi,

I would like to be able to display my temperatures like 32.1C, 32.4C as apposed to just 32C, 33C.

I am using ADC and realtime calculations, i end up with my real temperature value to the closest whole number.

Im doing this:

(TEMPERATURE = SAMPLE / 3), This gives me my single number value.

How do i do it so that i get a decimal point in there so i get 32.1 and so on??

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: Temperature reading 0.1 resolution

Post by medelec35 »

When I helped someone else who asked a similar question, I used string to manipulte the numbers.
take a look here:
http://www.matrixmultimedia.com/mmforum ... 888#p23817

I'm sure there are more examples I have done, it just finding them...Its an age thing....memory loss etc. :lol:


Martin
Martin

cobra1
Posts: 175
Joined: Thu Feb 04, 2010 7:44 am
Has thanked: 3 times
Been thanked: 3 times
Contact:

Re: Temperature reading 0.1 resolution

Post by cobra1 »

I looked at that link before, wasnt much use im afraid.

What im trying to do is convert my int value to a float, then to a string to display on screen to 1 decimal place.

so in the calculations i do,

FLOAT = SAMPLE

Then in string manipulation,

STRING = FloatToString$(FLOAT)

All i get on the screen is 0.00 its as if the float was never given a value.
Can you help on this??

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: Temperature reading 0.1 resolution

Post by medelec35 »

Ah I see.
The link I posted, you would not use the LUT, what you would do is use calculation to give you a integer x 10 e.g if 31.3deg, the calculation would give you a value of 313
then use the string method to derive 31.3

you need to be aware that floats take a vast amount of computing power and space for the pic chips. so if not much memory in the first place you soon run out of space when you compile.
In fact it's a good idea to keep compiling to hex every so often to check for amount of space left.

There is another post here:
http://www.matrixmultimedia.com/mmforum ... =29&t=8087
If you want to go down the float road and and no one else as posted, then I will see if I can help you out.

If you post your flowchart of what you have done so far, it can be altered for you.
Martin

cobra1
Posts: 175
Joined: Thu Feb 04, 2010 7:44 am
Has thanked: 3 times
Been thanked: 3 times
Contact:

Re: Temperature reading 0.1 resolution

Post by cobra1 »

OK, using the string method iv done it, i can only use 0.5c resolusion practically, but it will do nicely for me.

There is one more thing i need help with if you dont mind.

I need to use this formula for temperature compensation on my humidity sensor, but again this would involve floating numbers.

TrueRH= (SensorRH)/(1.0546-0.00216T), T in Celcius

Can this be calculated in any other way?

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: Temperature reading 0.1 resolution

Post by Benj »

Hello,

You can pre-calculate the values for each sensor reading and use a look up table approach meaning you do not have to float variables.

Here is a article on look up tables.
http://www.matrixmultimedia.com/article.php?a=50

If you have enough resolution on your ADC input then you can use two look up tables to do integer and decimal point.

TempI[] = {0,0,0,0,0,1,1,1,1,1,2...}
TempF[] = {0,2,4,6,8,0,2,4,6,8,0...}

ADC = Read ADC As Byte
Print Number TempI[ADC]
Print ASCII "."
Print Number TempF[ADC]

Post Reply