NO floating point

hmjswt

New Member
Hallo,

This week I received my PICAXE-08M2 Starter Pack (USB).
After populating the board with the electronic parts I started to program my first 'blink' program from manual 1.
No problem works perfectly.
 
Last edited:

srnet

Senior Member
Welcome to the Forums.

Whilst Floating point would be nice, its not difficult to manage without.

An MCU with no floating point is for most serious applications useless ....... I am sorry to say, but this is a dead-end street
Could not disagree more with those two statements ....................

Maybe you might say what its is exactly that you are trying to achieve ?
 

Buzby

Senior Member
Wecome to the Forum !.

Yes, PICAXE does not have floating point.

It's not really a secret, a quick read of the freely available manuals would have shown you that.

The target market for PICAXE does not need FP, but just look at what you can do without it !.

One of our members has a satellite circling the Earth as we speak, and that's running on a PICAXE.

Buzby
 

inglewoodpete

Senior Member
Welcome to the PICAXE forum.

You will find that there is a lot of documentation available on the PICAXE. As you have also found, there are many positive and constructive discussions in the PICAXE forum pages. When buying anything, it is important to do some research into the capabilities of your options first.

There is at least one PICAXE currently orbiting the earth at the moment. I have personally interfaced a network of PICAXEs to a living neural network. So, there is rocket science and neuroscience in two different applications. There are tens of thousands of less exotic uses for the PICAXE too. My current PICAXE project, based on a PICAXE 08M2, is to light the side of a multi-storey building in the city where I live with RGB lighting.

Please don't criticize your tools when you buy the wrong ones for the job you have.
 

KeithRB

Senior Member
The Arduino mcu has no floating point either. It is done in software and is relatively slow.

But thanks for sharing. I hope you feel better now.
 

erco

Senior Member
Welcome to the PICAXE forum. Please don't criticize your tools when you buy the wrong ones for the job you have.
+1. Take a cruise through the forums to find out what amazing things have been done with the Picaxe, integer math and all.
 

westaust55

Moderator
I was planning to use the PICAXE for my model rockets.
So I translated the temperature program I already use in Arduino and Launchpad RockComp's in my rockets into PICAXE BASIC.
Then I did have a nasty surprise. No floating point math.
From PICAXE Manual 1 "Getting Started" page53
General Purpose Variables.
There are 14 or more general purpose byte variables. These byte variables are
labelled b0, b1 etc. Byte variables can store integer numbers between 0 and 255.
Byte variables cannot use negative numbers or fractions, and will ‘overflow’
without warning if you exceed the 0 or 255 boundary values (e.g. 254 + 3 = 1)
(2 - 3 = 255)
However for larger numbers two byte variables can be combined to create a word
variable, which is capable of storing integer numbers between 0 and 65535.
Not really hidden information IF the manuals are read.
 

jon_nic

New Member
Hallo,

Then I did have a nasty surprise. No floating point math
http://swtrocketry.com
Hi what maths do you want to attempt to do, I am currently "fighting" the picaxe code to get around no floating point maths, but lots of people on here can give you a hand if you describe the maths you want to do within the picaxe.

regards jon.
 

hmjswt

New Member
Hallo,

OK, I get the message.
There are a lot of people doing a lot of nice things with the PICAXE.
Perhaps I am to harsh in my conclusion.
You know what? Now I have the PICAXE I am going to give it a real try and build a timer and a temperature measuring RockComp.
By the way... are there any floating point libraries for use with PICAXE?
So now I am going to read the manuals again.
I am still trying to understand the difference between B.1 and C.1 on the 08M2.
When to use C.1 and when to use B.1.
I understand there are a lot of people that are willing to help me. Thats nice.
I think I need a lot of help.
PICAXE is very different from MCU's I have used before.

Henk Siewert
 

srnet

Senior Member
I am going to give it a real try and build a timer and a temperature measuring RockComp.
If you tell us a bit more about what it is you want to do, people will be in a better position to give advice.

What for instance are you using to measure temperature, what temperatures are you measuring, how often etc.
 

geoff07

Senior Member
To read temperatures from a DS18B20 sensor:
- limitations: tenths of a degree resolution, positive values only
- negative values need additional logic based on whether bit 15 is set when the raw value is read

- get the value from the sensor:
Code:
readtemp12 input_pin, W_variable
- convert raw data to tenths of a degree: (the sensor reports in units of 0.0625 degrees)
Code:
W_variable = W_variable * 25/40
- W_variable now contains tenths of a degree i.e. for 25.4 degrees it contains 254

- to display 25.4 i.e. with a decimal point (or comma in your case)
Code:
B_units    = W_variable // 10
B_tens     = W_variable /  10  // 10
B_hundreds = W_variable /  100 // 10
serout diplay_pin, baud_rate, (#B_hundreds, #B_tens, ",", #B_units)
The B_ and W_ prefixes are my way of making clear that variables are bytes or words.

No libraries to include, nothing complicated, as long as you can keep your values scaled within byte or word integer values.

dat is niet zo moeilijk!
 

hmjswt

New Member
Hallo,

I was planning to use the Texas Instruments LM35.
I have used it successfully before with the Arduino and LaunchPad.
But I understand PICAXE supports the DS18B20.
I will get a DS18B20 and try your code.
Thanks for sharing the code with me.

Where did you get the 'dat is niet zo moeilijk! '? That's Dutch!

By the way, any Dutch people on this forum?

Henk Siewert
 

Goeytex

Senior Member
The LM35 will work just fine as indicated by Dippy. It will output 10mv per degree C. With readADC 10 using the FVR 2.048V internal reference, each unit is 2mV. To get degrees multiply the ADC value times 2. Then use "bintoascii" to format the data for display with the decimal point.

If FVR is set to 1.024V, then the ADC will give a temperature display range of 0 to 100C with a resolution of 1/10 degree.
 

Pongo

Senior Member
The obvious downside of the LM35 is that it needs a negative supply voltage to read temps below freezing, and that leads to the further complication that you can't directly measure a negative voltage with a picaxe A/D.

The DS18B20 is a much better choice IMHO.
 

hmjswt

New Member
One more Dutchie here :)
Hallo Hendriks,

Leuk om nog een Nederlander tegen te komen op dit forum.
Wat maak je zoal met de PICAXE?

(Google translation:
Nice to have a Dutchman to come across on this forum.
What do you been up to the PICAXE?) :eek:

Groetjes,
Henk Siewert
 

hmjswt

New Member
Hallo,

Yes, I have ordered a DS18B20.
But I will also experiment with a LM35.
I don't have to measure negative temps.
Just temp changes in a model rocket body tube.

Thank you all for your input.

Henk Siewert
 

manuka

Senior Member
-just temp changes in a model rocket body tube.
Gasp-this sounds hot stuff! No wonder you don't have to measure negative temps ... FWIW Maxim's esteemed DS18B20 (DS = Dallas Semiconductor) has an operating temperature range of -55°C to +125°C and is accurate to ±0.5°C over the range of -10°C to +85°C.
 

srnet

Senior Member
Yes, I have ordered a DS18B20.
The DS18B20 is not particularly fast at returning a result, up to 750mS, but that is more down to the device than the PICAXE.

Using it in PICAXE basic is very simple indeed, far simpler than some of the less 'serious' competing Micros.
 

geoff07

Senior Member
The 750mS spec is interesting because it isn't clear under what circumstances that applies. I have quite a few going in the house for various purposes, and though I haven't done any measurements, it seems to be more like half that time in practice.
 

Technical

Technical Support
Staff member
The M2 and X2 parts 'poll' the DS18B20 to ask it when the conversion is finished. Therefore the time taken is simply the time the DS18B20 needs, and this will vary depending on the actual temperature. The DS18B20 datasheet states 'up to 750ms', so that is worst case scenario.
 

hmjswt

New Member
Hallo,

The 750ms can be a problem.
I wanted to sample the temperature every 0.1 of a second or so.
750ms = 3/4 of a second.
In 750ms a rocket can travel hundreds of meters.

Well, I am going to use both the DS18B20+ I am getting and the LM35.
I will let them run free and pump their data in an 24LC512 EEPROM
Then I can compare the two.

It's getting more and more interesting...

Henk Siewert
 

srnet

Senior Member
The 750ms can be a problem.
I wanted to sample the temperature every 0.1 of a second or so.
750ms = 3/4 of a second.
In 750ms a rocket can travel hundreds of meters.
Yes, but what sort of temperature variation are you expecting ?

The thermal mass of the DS18B20 (or LM35) will mean that the recorded temperature will lag considerably behind the surface temperature, so reading it every 100mS wont tell you much, apart from what the temperature was a while ago.
 

westaust55

Moderator
Using a DS18B20 temperature sensor in 9-bit mode, the temperature conversion takes approx 96 ms (as opposed to approx 750 ms in 12 bit mode).
If using a PICAXE X1 or X2 part then you can use the 1-Wire commands and receive updates close to the mentioned 0.1 sec interval. It will be slightly greater intervals after considering the time for the PICAXE chip to execute the BASIC commands.
 

hmjswt

New Member
Yes, but what sort of temperature variation are you expecting ?

The thermal mass of the DS18B20 (or LM35) will mean that the recorded temperature will lag considerably behind the surface temperature, so reading it every 100mS wont tell you much, apart from what the temperature was a while ago.
Ah, good question.
I will be surprised if something spectacular comes up.
This is more an exercise getting, storing, and later, recovering and graphing data in a model rocket using PICAXE.
And, last but not least, getting to know the PICAXE system and programming.

And yes, getting data is always legging behind.
Has something to do with time, I believe.

Henk Siewert
 

Goeytex

Senior Member
The LM35 Datasheet explains how to mitigate the effects of thermal mass as well lead/pin temperature. I'm sure the DS18B20 datasheet does the same.

As far as sampling rate goes, 10 samples per second is quite common in many temperature sensing/control applications. While there will be a bit of lag, it is better to log the data from a short time ago (LM35/ Thermistor/thermocouple) than from a long time ago (DS18B20 / ReadTemp).

For the rocket application, I would try the LM35 and be tempted to sample & log the data as fast as the Picaxe will allow without exceeding the memory used for logging data. This will partly be determined by flight time.
 

srnet

Senior Member
The LM35 Datasheet explains how to mitigate the effects of thermal mass as well lead/pin temperature.
It suggests how you can minimise the effect, yes, but only that. I am guessing the suggestions are to do with long term (relativly stable) measuments, not to do with fast moving changes and keeping them within a few hundread milli seconds of the surface temperaure.

For a standard DS18B20 the temperature of the internal sensor is always going to lag the surface temperature.

If you put a DS18B20 on a surface that is, say 2C higher than ambient, how long before the sensor reports a 1C rise, several seconds maybe ?
 

Armp

Senior Member
Small bead thermistors have a very small thermal mass and response time.
Coupled with a single resistor, and simple math, they can be used over a range of 100F with 1F accuracy
 

srnet

Senior Member
Small bead thermistors have a very small thermal mass and response time
Yes.

The implication is that this project is measuring the temperature inside a rocket module tube, although that is just a guess, there are no details provided.

So, assuming my guess is correct, the temperature is only going to change very slowly, so recording it every 100mS does not seem to serve any purpose.
 

Armp

Senior Member
So, assuming my guess is correct, the temperature is only going to change very slowly, so recording it every 100mS does not seem to serve any purpose.
I seem to recall temperature changes at about 4F/1000ft altitude? And these rockets move quite quickly.
 

hmjswt

New Member
So, assuming my guess is correct, the temperature is only going to change very slowly, so recording it every 100mS does not seem to serve any purpose.
AH, but not all things in live must have a purpose.
Sometimes you can do things for fun.
Or as an intellectual exercise
Or you want to learn something new.
Or just because it can be done.
Or just for the hell of it...

As I said earlier: 'This is more an exercise getting, storing, and later, recovering and graphing data in a model rocket using PICAXE.
And, last but not least, getting to know the PICAXE system and programming.'

But now we already have 4 pages.
So you seem to like this tread.
Go on, have fun.
And I am learning a lot.

Henk Siewert
 

Goeytex

Senior Member
If you put a DS18B20 on a surface that is, say 2C higher than ambient, how long before the sensor reports a 1C rise, several seconds maybe ?
You tell me, I am not one for guessing too much on this lind of stuff. That is just a guess, isn't it?. I would much rather do some math from the datasheet specs then test & measure and get a somewhat accurate idea.

As far as "lag" goes, there is always the thermal lag (thermal time constant) , but in the in the case of the DS18B20 there is also processing delay. This is why I would prefer the LM35 over the DS18B20 given only these two choices. At least it will supply moving data points without the added processing time restriction. However, the thermal time constant of both of these is > 30s in still air, with some estimating the DS18B20 at over 2 minutes, so neither these will be particularly good in a short duration flight. It will depend upon the engine burn time and when measurement is started & stopped. The temperature readings will keep rising after the engine has stopped and the actual max temperature may never be read. IN other words measurement will not be at anything close to "real time" with a 3 second burn. But that may be ok depending upon what the OP is after

Note: (The metal can version of the LM35 can have thin fins added to improve response time in still air).

So, after considering this a but more carefully, I think the best all around choice is for performance/economy is a small glass bead thermistor which will have a thermal time constant of ~1 sec or less.

The OP as not indicated what exactly is being measured only the " temp changes in a model rocket body tube". Is this the ambient (air cavity) or will the sensor be mounted to a hard part? How far away from the engine will it be ? ... These things will matter quite a bit.
 
Top