Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Arduino pro mini analog inputs

Status
Not open for further replies.
With the delay it works fine.
I'dve used screened cable, however the sensor is right next to the chip.
 
Having the sensor so close to the chip could be part of the problem, but if the delay fixes the problem then thats good. My project had the sensor completely seperate from the board (sticking out the end of an old pen barrel and held in place with epoxy!)
 
A lot of posts, I did not read them :D.

I used "LM335"?

The problem for me was in the programming. You need to use floating point numbers to make the accuracy "1 degree" or/and connect more than 1 LM335 like its written in the datasheet.
 
The problem for me was in the programming. You need to use floating point numbers to make the accuracy "1 degree" or/and connect more than 1 LM335 like its written in the datasheet.

You don't "need" floating point. An ADC running at 5V will have each count representing 5mV. This means you can read with a resolution of approx 0.5C. No amount of manipulation with floating point will change this. If you wan't to keep the 0.5C part and still use signed integers then subtract 273*2 before using itoa and placing the decimal in the correct position.

Mike.
 
You don't "need" floating point. An ADC running at 5V will have each count representing 5mV. This means you can read with a resolution of approx 0.5C. No amount of manipulation with floating point will change this. If you wan't to keep the 0.5C part and still use signed integers then subtract 273*2 before using itoa and placing the decimal in the correct position.

Mike.

Or use a micro with 12-bit resolution and an external reference of 4.096 volts. Now 0.1 degree accuracy my simply subtracting 2732 - then illuminate the correct decimal on the display.
 
You don't "need" floating point. An ADC running at 5V will have each count representing 5mV. This means you can read with a resolution of approx 0.5C. No amount of manipulation with floating point will change this. If you wan't to keep the 0.5C part and still use signed integers then subtract 273*2 before using itoa and placing the decimal in the correct position.

Mike.
Even at "10mv/degree" I had a bad accuracy until I increased the formula numbers to x.xxxxxx.
 
Even at "10mv/degree" I had a bad accuracy until I increased the formula numbers to x.xxxxxx.

In which case you weren't doing it right - it's a LOT faster, more accurate, and uses much less memory, to use integer maths rather than floating point.

You just need to be aware of exactly what you're doing, and simply add the decimal point in the string at the end - if you were getting inaccuracies (and they would be substantial ones) you were getting results outside the range of your integer variables somewhere during the maths.
 
In which case you weren't doing it right - it's a LOT faster, more accurate, and uses much less memory, to use integer maths rather than floating point.

You just need to be aware of exactly what you're doing, and simply add the decimal point in the string at the end - if you were getting inaccuracies (and they would be substantial ones) you were getting results outside the range of your integer variables somewhere during the maths.
I know, but it doesn't work. And on todays MCUs it does not matters too. I am thinkig we wont get along.
 
I know, but it doesn't work. And on todays MCUs it does not matters too.
But, it does work. You get an integer value from the ADC which you can manipulate to get the ascii string you want to print. And, why doesn't it matter? I guess You just get a bigger faster processor rather than a much cheaper solution if you adjust your attitude.

Mike.
 
Example of simple integer maths for temperature conversion, based on a 10 bit ADC and 5V reference, for an LM335:
(Not tested).

Get ADC reading.
subtract 559 (equivalent of 2.73V)
ensure not less than zero; if it is, set it to zero.
Multiply by 49

That gives a number equivalent to 1/100th of a degree, to half a degree accuracy.
eg. 100'C results in 10049
Just insert a decimal point.

With a 12 bit ADC you can get it rather better still.

In practice I use several stages of filtering, again with integer maths, before displaying a value such as that, to prevent the display flickering about with noise and single bit changes.
 
Thats what I did pomm's, each count is 0,5 degree, and I just used a byte.
I learned to program before floating point was a luxury on microcontrollers.
 
I mean on the 4MHz PIC16F690 that I have tried, it makes no difference in the performance, I know it should work without the floating points, but it doesn't.
 
If you're using a 4MHz 16F690 then all the more reason to not use floating point.

An example of how to calculate it using integers is here. Note the use of int32 to prevent overflow.

Mike.
Edit, if you want to play with the code hit the "fork this" button at the top.
 
I mean on the 4MHz PIC16F690 that I have tried, it makes no difference in the performance, I know it should work without the floating points, but it doesn't.

As I said before, if it doesn't work you're doing it wrong, and as Pommie mentioned the 16F690 is a VERY good reason to avoid floating point at all costs as you don't have much memory to play with.

I think a lot of this comes from the Arduino, where it's common practice to use floating point when it's not needed - long time micro-controller users think otherwise :D
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top