Go Down

Topic: Having trouble on solving the following tasks (Read 5 times) previous topic - next topic

Jonraptor


OK, I'll try one more time.
What sort of value are you seeing for "ThermResist" ? (OK, I know I spelled it wrong last time)

I see the ThermResist as a float value to calculate the resistance of the Thermistor based on the voltage Output

tuxduino

#26
Oct 04, 2012, 02:19 pm Last Edit: Oct 04, 2012, 02:22 pm by tuxduino Reason: 1
Quote
Lose the excess subscript increments. How so? The task mentions that i need to make a simple lookout table based on 2D array (without using the steinhart-hart equation).


Ok, I'll repeat: you get an analog value and you search it with equality among a (small) set of predefined values. An analog value in Arduino is an integer number between 0 and 1023. If you compare it to, say, 10 values you roughly have 1% probability to "catch" it each time.

Back to your code, it's clear that you're trying to identify the type of battery based on its weight. Each battery type has a minimum and maximum weight. You want to determine in which weight range your analog value falls. For this you need to test it against the minimum and maximum value of each range. And for this you need >= and <=, not ==.

I don't understand why using a lookup table implies using (only) ==.

If you insist on using ==, you could probably make a 1024-elements lookup table and use the analogRead result as an index into it. Total waste of RAM, IMHO, but using just 1 byte per element it could be doable (you'd be using half RAM just for that...).


(edit: sorry I assumed you would search using an integer value. If you use floats, then == is _definitely out of question_)

AWOL

#27
Oct 04, 2012, 02:22 pm Last Edit: Oct 04, 2012, 02:24 pm by AWOL Reason: 1
Quote
I see the ThermResist as a float value to calculate the resistance of the Thermistor based on the voltage Output

Sigh.

"Seeing" with your actual eyes, not your mind's eye.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

tuxduino



OK, I'll try one more time.
What sort of value are you seeing for "ThermResist" ? (OK, I know I spelled it wrong last time)

I see the ThermResist as a float value to calculate the resistance of the Thermistor based on the voltage Output


Please copy-n-paste here what you get on the serial monitor after running your program.

Tell us why what you see is wrong, and what it should be instead.

I hope it's clear now.

Jonraptor




OK, I'll try one more time.
What sort of value are you seeing for "ThermResist" ? (OK, I know I spelled it wrong last time)

I see the ThermResist as a float value to calculate the resistance of the Thermistor based on the voltage Output


Please copy-n-paste here what you get on the serial monitor after running your program.

Tell us why what you see is wrong, and what it should be instead.

I hope it's clear now.


Yup, in a min.

Here is an output of my code: -

Code: [Select]



Value = 754.00 Voltage = 3.69 V Resistance = 3562.91 Ohm
Value = 753.00 Voltage = 3.68 V Resistance = 3580.90 Ohm
Value = 751.00 Voltage = 3.67 V Resistance = 3617.02 Ohm
Value = 754.00 Voltage = 3.69 V Resistance = 3562.91 Ohm
Value = 754.00 Voltage = 3.69 V Resistance = 3562.91 Ohm
Value = 754.00 Voltage = 3.69 V Resistance = 3562.91 Ohm
Value = 754.00 Voltage = 3.69 V Resistance = 3562.91 Ohm
Value = 754.00 Voltage = 3.69 V Resistance = 3562.91 Ohm
Value = 755.00 Voltage = 3.69 V Resistance = 3544.97 Ohm
Value = 754.00 Voltage = 3.69 V Resistance = 3562.91 Ohm
Value = 754.00 Voltage = 3.69 V Resistance = 3562.91 Ohm
Value = 752.00 Voltage = 3.68 V Resistance = 3598.94 Ohm
Value = 755.00 Voltage = 3.69 V Resistance = 3544.97 Ohm
Value = 755.00 Voltage = 3.69 V Resistance = 3544.97 Ohm
Value = 755.00 Voltage = 3.69 V Resistance = 3544.97 Ohm
Value = 754.00 Voltage = 3.69 V Resistance = 3562.91 Ohm
Value = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm
29 C
Value = 754.00 Voltage = 3.69 V Resistance = 3562.91 Ohm
Value = 755.00 Voltage = 3.69 V Resistance = 3544.97 Ohm
Value = 755.00 Voltage = 3.69 V Resistance = 3544.97 Ohm
Value = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm
29 C
Value = 754.00 Voltage = 3.69 V Resistance = 3562.91 Ohm
Value = 753.00 Voltage = 3.68 V Resistance = 3580.90 Ohm
Value = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm
29 C
Value = 754.00 Voltage = 3.69 V Resistance = 3562.91 Ohm
Value = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm
29 C
Value = 754.00 Voltage = 3.69 V Resistance = 3562.91 Ohm
Value = 755.00 Voltage = 3.69 V Resistance = 3544.97 Ohm
Value = 755.00 Voltage = 3.69 V Resistance = 3544.97 Ohm
Value = 755.00 Voltage = 3.69 V Resistance = 3544.97 Ohm
Value = 755.00 Voltage = 3.69 V Resistance = 3544.97 Ohm
Value = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm
29 C
Value = 753.00 Voltage = 3.68 V Resistance = 3580.90 Ohm
Value = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm
29 C
Value = 754.00 Voltage = 3.69 V Resistance = 3562.91 Ohm
Value = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm
29 C
Value = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm
29 C
Value = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm
29 C
Value = 758.00 Voltage = 3.71 V Resistance = 3491.44 Ohm
29 C
Value = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm
29 C
Value = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm
29 C
Value = 754.00 Voltage = 3.69 V Resistance = 3562.91 Ohm
Value = 754.00 Voltage = 3.69 V Resistance = 3562.91 Ohm
Value = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm
29 C
Value = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm
29 C
Value = 758.00 Voltage = 3.71 V Resistance = 3491.44 Ohm
29 C
Value = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm
29 C
Value = 758.00 Voltage = 3.71 V Resistance = 3491.44 Ohm
29 C
Value = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm
29 C
Value = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm
29 C
Value = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm
29 C
Value = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm
29 C
Value = 758.00 Voltage = 3.71 V Resistance = 3491.44 Ohm
29 C
Value = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm
29 C
Value = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm
29 C
Value = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm
29 C
Value = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm
29 C
Value = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm
29 C
Value = 758.00 Voltage = 3.71 V Resistance = 3491.44 Ohm
29 C
Value = 755.00 Voltage = 3.69 V Resistance = 3544.97 Ohm
Value = 759.00 Voltage = 3.71 V Resistance = 3473.68 Ohm
29 C
Value = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm
29 C
Value = 758.00 Voltage = 3.71 V Resistance = 3491.44 Ohm
29 C



Go Up