Go Down

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

Jonraptor

I've been trying to make a 2D array table based on the temperature, and Resistance. But it doesn't seem to work well. Here is the code and the task requirement so forth: -

Complete and test a program that uses a simple lookup table to print the
temperature from a thermistor to the serial console. Test it by holding the
thermistor between two fingers and watch the resistance drop, voltage increase
and temperature increase.

Code: -
Code: [Select]

const int AnalogInPin = A0;

void setup()
{
  Serial.begin(9600); 
}

void loop()
{
int SensorValue = 0;
const int cols = 2;
const int rows = 10;
int DArray [rows] [cols] = {
                            {25, 4470},
                            {26, 4000},
                            {27, 3900},
                            {28, 3800},
                            {29, 3530},
                            {30, 3270},
                            {31, 3170},
                            {32, 3110},
                            {33, 3090},
                            {34, 3070},
                           }; 
int i;                           
float R2 = 10000.0;
float R1;
float Vin = 5.0;
float Vout;
float ThermResist;
   SensorValue = analogRead(AnalogInPin);   
for( i = 0; i <rows; i++)
{
if(ThermResist == DArray[i][2])
   Serial.println(DArray[1][0]);
}

//  Serial.println(DArray[rows] [cols]);

  Serial.print("Voltage: ");
  Vout = (((SensorValue+1)*5)/1024.0);
  Serial.print(Vout);
  Serial.print(" V");

  Serial.print("\t Resistance: ");
  ThermResist = ((R2 * Vin)/Vout) - R2; 
  Serial.print(ThermResist, DArray[i][2]);
  Serial.println(" Ohm ");
}



Thank you :)

Jonraptor

In addition to that, i am having trouble converting the Temperature from the 2D array to Kelvins, Celsius, and Fahrenheit.

If someone would be able to explain how am i suppose to solve this task without adding the SteinHart-Hart equation (just a simple way to convert the default temperature from the 2D array to K, C & F)

Improve the structure of your program by creating, implementing and using
the following functions:
int getTemperatureUsingLookup(int pin); //gets the temperature from a
thermistor attached to an analog pin
int getTemperatureInKelvin(int pin); //returns the temperature in K.
int getTemperatureInCelcius(int pin); //returns the temperature in C.
int getTemperatureInFarenheit(int pin); //returns the temperature in F

dxw00d


Nick Gammon


In addition to that, i am having trouble converting the Temperature from the 2D array to Kelvins, Celsius, and Fahrenheit.


Converting the figure in the table, in Celsius, to Celsius would be quite taxing. It's a complex problem, for sure.

Jonraptor

#4
Sep 30, 2012, 09:54 am Last Edit: Sep 30, 2012, 11:03 am by Jonraptor Reason: 1

When is our homework assignment due in?


I dunno, haven't checked tbh

Go Up