Go Down

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

#### Jonraptor

#15
##### Oct 04, 2012, 12:08 pm

Code: [Select]
`if(ThermResist == Table[4][1])` ?

If the ThermResistance is = to the output shown on the table row 4, the 2nd column. Then, it will trigger the printout of the temperature on the same row on column 0

#### tuxduino

#16
##### Oct 04, 2012, 12:10 pm

Code: [Select]
`if(ThermResist == Table[4][1])` ?

If the ThermResistance is = to the output shown on the table row 4, the 2nd column. Then, it will trigger the printout of the temperature on the same row on column 0

I guess you ignored my previous comment then ?

#### Jonraptor

#17
##### Oct 04, 2012, 12:13 pm

Code: [Select]
`if(ThermResist == Table[4][1])` ?

If the ThermResistance is = to the output shown on the table row 4, the 2nd column. Then, it will trigger the printout of the temperature on the same row on column 0

I guess you ignored my previous comment then ?

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).

#### AWOL

#18
##### Oct 04, 2012, 12:16 pm
You're stepping through a lookup table, but only ever using constant subscripts.
That doesn't make sense.

Each loop has double increments on it.
That doesn't make sense.

You're looking for equality with floating point values.
That doesn't make sense.
"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.

#### Jonraptor

#19
##### Oct 04, 2012, 12:20 pmLast Edit: Oct 04, 2012, 12:31 pm by Jonraptor Reason: 1

You're stepping through a lookup table, but only ever using constant subscripts.
That doesn't make sense.

Each loop has double increments on it.
That doesn't make sense.

The For loop statement is suppose to provide a loop. One for the rows(0-9), and the other for the cols(0-1). Inside both loops, i am trying to state an if statement which applies to the Thermresist if it hits on a certain point based on table[4][1] 3800, then it will trigger a printout statement. Otherwise, it continues on with its sensorval, volt, and ohm printout process. This is what i am trying to do. But it doesn't seem to work out well for me. If this doesn't make any sense to you, can you please provide an explanation on what your suggestion going to be on this occassion?

#### AWOL

#20
##### Oct 04, 2012, 12:30 pm
My suggestion is to lose the the second i++ and j++ in the loops (I think I've already said this).

My suggestion is to test not for equality, but for a range of values. (I think others have said this).

I still don't know why you're looping through a table but using constant subscripts, or even why you're looping across the columns. Maybe you can answer this.
"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.

#### Jonraptor

#21
##### Oct 04, 2012, 12:37 pm

My suggestion is to lose the the second i++ and j++ in the loops (I think I've already said this).

My suggestion is to test not for equality, but for a range of values. (I think others have said this).

I still don't know why you're looping through a table but using constant subscripts, or even why you're looping across the columns. Maybe you can answer this.

Ok, i think i got it somehow working. Except it isn't as accurate as i've expected. I've followed your lead, and this is what i've done so far: -

Code: [Select]
`void loop(){float Vin = 5.0;float ThermResist = 0.0;float R2 = 10000.0;float SensorValue = 0.0;float Vout = 0.0;                           SensorValue = analogRead(ThermPin);  Serial.print("Value = ");  Serial.print(SensorValue);    Vout = (((SensorValue+1)*Vin)/1024.0);  Serial.print("\t Voltage = ");  Serial.print(Vout);  Serial.print(" V");    ThermResist =((R2*Vin)/Vout)-R2;  Serial.print("\t Resistance = ");  Serial.print(ThermResist);  Serial.println(" Ohm");        if(ThermResist <= Table[4][1] && ThermResist >= Table[5][1])      {        Serial.print(Table[4][0]);         Serial.println(" C");      }}`

I've tried to go between those 2 values, but no luck. Except, if i've gone below Table[5][1], the printout statement have been triggered.

#### AWOL

#22
##### Oct 04, 2012, 12:41 pm
Quote
Except it isn't as accurate as i've expected

Can you tell us what your expectations are, and how your observations differ?

What sort of value are you seeing for "TermResist"
"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.

#### Jonraptor

#23
##### Oct 04, 2012, 12:47 pm

Quote
Except it isn't as accurate as i've expected

Can you tell us what your expectations are, and how your observations differ?

What sort of value are you seeing for "TermResist"

My expectations is, if the ThermResist values hits below 3800. At the same time, stays above 3530. A printout statement of the Temp of 29 C have been initiated. Otherwise, it will keep on repeating the sensval, volt, & ohm outputs the usual.

ThermResist records the resistance of the Thermister, by adding the static resistance with it.

#### AWOL

#24
##### Oct 04, 2012, 12:57 pm
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)
"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.

#### Jonraptor

#25
##### Oct 04, 2012, 02:07 pm

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 pmLast 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 pmLast 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.

"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

#28
##### Oct 04, 2012, 02:24 pm

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

#29
##### Oct 04, 2012, 02:27 pm

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 OhmValue = 753.00 Voltage = 3.68 V Resistance = 3580.90 OhmValue = 751.00 Voltage = 3.67 V Resistance = 3617.02 OhmValue = 754.00 Voltage = 3.69 V Resistance = 3562.91 OhmValue = 754.00 Voltage = 3.69 V Resistance = 3562.91 OhmValue = 754.00 Voltage = 3.69 V Resistance = 3562.91 OhmValue = 754.00 Voltage = 3.69 V Resistance = 3562.91 OhmValue = 754.00 Voltage = 3.69 V Resistance = 3562.91 OhmValue = 755.00 Voltage = 3.69 V Resistance = 3544.97 OhmValue = 754.00 Voltage = 3.69 V Resistance = 3562.91 OhmValue = 754.00 Voltage = 3.69 V Resistance = 3562.91 OhmValue = 752.00 Voltage = 3.68 V Resistance = 3598.94 OhmValue = 755.00 Voltage = 3.69 V Resistance = 3544.97 OhmValue = 755.00 Voltage = 3.69 V Resistance = 3544.97 OhmValue = 755.00 Voltage = 3.69 V Resistance = 3544.97 OhmValue = 754.00 Voltage = 3.69 V Resistance = 3562.91 OhmValue = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm29 CValue = 754.00 Voltage = 3.69 V Resistance = 3562.91 OhmValue = 755.00 Voltage = 3.69 V Resistance = 3544.97 OhmValue = 755.00 Voltage = 3.69 V Resistance = 3544.97 OhmValue = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm29 CValue = 754.00 Voltage = 3.69 V Resistance = 3562.91 OhmValue = 753.00 Voltage = 3.68 V Resistance = 3580.90 OhmValue = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm29 CValue = 754.00 Voltage = 3.69 V Resistance = 3562.91 OhmValue = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm29 CValue = 754.00 Voltage = 3.69 V Resistance = 3562.91 OhmValue = 755.00 Voltage = 3.69 V Resistance = 3544.97 OhmValue = 755.00 Voltage = 3.69 V Resistance = 3544.97 OhmValue = 755.00 Voltage = 3.69 V Resistance = 3544.97 OhmValue = 755.00 Voltage = 3.69 V Resistance = 3544.97 OhmValue = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm29 CValue = 753.00 Voltage = 3.68 V Resistance = 3580.90 OhmValue = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm29 CValue = 754.00 Voltage = 3.69 V Resistance = 3562.91 OhmValue = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm29 CValue = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm29 CValue = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm29 CValue = 758.00 Voltage = 3.71 V Resistance = 3491.44 Ohm29 CValue = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm29 CValue = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm29 CValue = 754.00 Voltage = 3.69 V Resistance = 3562.91 OhmValue = 754.00 Voltage = 3.69 V Resistance = 3562.91 OhmValue = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm29 CValue = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm29 CValue = 758.00 Voltage = 3.71 V Resistance = 3491.44 Ohm29 CValue = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm29 CValue = 758.00 Voltage = 3.71 V Resistance = 3491.44 Ohm29 CValue = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm29 CValue = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm29 CValue = 756.00 Voltage = 3.70 V Resistance = 3527.08 Ohm29 CValue = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm29 CValue = 758.00 Voltage = 3.71 V Resistance = 3491.44 Ohm29 CValue = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm29 CValue = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm29 CValue = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm29 CValue = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm29 CValue = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm29 CValue = 758.00 Voltage = 3.71 V Resistance = 3491.44 Ohm29 CValue = 755.00 Voltage = 3.69 V Resistance = 3544.97 OhmValue = 759.00 Voltage = 3.71 V Resistance = 3473.68 Ohm29 CValue = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm29 CValue = 758.00 Voltage = 3.71 V Resistance = 3491.44 Ohm29 C`

Go Up

Please enter a valid email to subscribe