Arduino issues
OK, even though Arduino is supposed to make us older farts equal to the young dudes in programming, I will readily admit that I am useless at it which is even more embarrassing as I was an electronics technologist 30 years ago. ARRRGGGG.
So all I am trying to do is take the Mega, and sensor shield, add a 10k thermister (2 wire, not the digital stuff that I never see in the heating industry) and see the temp change on the screen. I followed a thread on yourduino to do this and got errors that I cannot explain and it seems, I cannot even find definitions to some of the phrases given at the bottom of the page when trying to verify the program. Here is an example: "was not declared in this scope" What does that mean? I cannot find a glossary of terms used anywhere. HHHheeeellllpppp (please) |
I am no pro, but is this regarding a variable that was not declared initially? Do you want to post up your sketch?
|
The sketch is not important so here only because it it taken directly from the the adafruit book about how to use a thermister. I cut and paste the exact sketch from the site and voila......errors.
The phrasing doesn't have enough explanation. Here is what i tried to do: Code:
Then I erase this program and copy one that changes the thermister value to deg C (below) and it doesn't recognize the thermister. Code:
The problem is that the explanations are inadequate. |
Quote:
It is easiest to see your sketch, if you put it inside CODE tags. So you would use a square brace "[" and then you would put the letters "CODE" next, and then you would put another square brace "]"... then you put your sketch, your whole sketch next... ...then you would use a square brace "[" and then you would put a slash "/" and then the letters "CODE" next, and then you would put another square brace "]". It makes your sketch stand out so that it's easier to see what went wrong. -AC |
The two versions of the code are presented in their entirety above. I thought it was evident enough, perhaps not, so I will try again. I edited it again to show the square brackets. As there is 2 separate codes in the post I said "end post". This is not going in the arduino so i assume it is just for the readers benefit.
The main thing is that there is no plain english glossary that really defines the terms as presented in the debugger. I have my talents but this isn't one of them LOL. |
i'm no longer a programming expert, but this line looks fishy to me:
steinhart -= 273.15; // convert to C it seems you should have something like: variable = variable + constant rather than variable = constant |
The original sketch looks at the value but does not convert to C nor does it account for the non linearity of the thermister. The Steinhart equation is supposed to do this, to some extent.
Jeff, would you get rid of the steinhart parts? It does need some math to convert. |
If it were me, I would use what works and build upon it.
Since the original routine reads the thermistor value as it should, I would use it. It returns the floating point variable READING. I would take the first code and add a single line that converts the reading to temperature. Something like this: float logcubed = log(reading); logcubed = logcubed * logcubed * logcubed; float kelvin = 1.0 / (-7.5e-4 + 6.23e-4 * log(reading) - 1.73e-6 * (logcubed)); float celsius = kelvin - 273.15; the A, B, and C values were stolen from Alan Wendtt from his arduino.cc posting. Your values may or may not vary, IDK. I learned long ago that the compilers/assemblers/translaters (whatever you call themtoday) tend to work better with these ugly one-line equations without hiccups or weird errors than using many lines to do the same thing. Once you have the code in that first program spitting out temperatures, use it as a function to do your averaging. As long as you keep the operations separate it will be easy to tell where your program is going wrong. |
I found an article that is aimed at doing the averaging/smoothing, written in older-school syntax.
Arduino - Smoothing From this example, it seems to me that you haven't defined your SAMPLES array in the second program correctly. I could be wrong, but constants and variables used to have to be assigned a data type before you could assign them actual values. If you are looking for a rolling average, a defined array isn't even necessary. You could simply make a low-pass filter, PID style. Here's a snip in arduino flavor. float adcResult = 0; void setup() { Serial.begin(9600); } void loop() { adcResult = adcResult * 0.95 + analogRead(0) * 0.05; Serial.println(adcResult); delay(50); } in this example, alpha is 20, which approximates a 20-point running average. |
Quote:
Code:
steinhart -= 273.15; Code:
steinhart = steinhart - 273.15; As for the Quote:
If possible please give the full error message, so that we know which variable was not declared, etc. |
All times are GMT -5. The time now is 08:34 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Ad Management by RedTyger