Sha256: 039855738d751daf03662f4053bcf6904d3b5c78f98c28d42469d9b3f1f91b77

Contents?: true

Size: 792 Bytes

Versions: 54

Compression:

Stored size: 792 Bytes

Contents

#include "Types.h"
#include "TemperatureCalculator.h"
#include <math.h>

#ifndef logl
#define logl log
#endif

float TemperatureCalculator_Calculate(uint16 millivolts)
{
  const double supply_voltage = 3.0;
  const double series_resistance = 5000;
  const double coefficient_A = 316589.698;
  const double coefficient_B = -0.1382009;
  double sensor_voltage = ((double)millivolts / 1000);
  double resistance;
  
  if (millivolts == 0)
  {
    return -INFINITY;
  }

  // Series resistor is 5k Ohms; Reference voltage is 3.0V
  // R(t) = A * e^(B*t); R is resistance of thermisor; t is temperature in C
  resistance = ((supply_voltage * series_resistance) / sensor_voltage) - series_resistance;
  return (float)(logl(resistance / coefficient_A) / coefficient_B);
}

Version data entries

54 entries across 39 versions & 1 rubygems

Version Path
ceedling-0.29.1 examples/temp_sensor/src/TemperatureCalculator.c
ceedling-0.29.1 vendor/cmock/examples/temp_sensor/src/TemperatureCalculator.c
ceedling-0.29.0 examples/temp_sensor/src/TemperatureCalculator.c
ceedling-0.29.0 vendor/cmock/examples/temp_sensor/src/TemperatureCalculator.c
ceedling-0.19.0 examples/temp_sensor/src/TemperatureCalculator.c
ceedling-0.18.0 examples/temp_sensor/src/TemperatureCalculator.c
ceedling-0.18.0 vendor/cmock/examples/src/TemperatureCalculator.c
ceedling-0.17.0 vendor/cmock/examples/src/TemperatureCalculator.c
ceedling-0.17.0 examples/temp_sensor/src/TemperatureCalculator.c
ceedling-0.16.0 examples/temp_sensor/src/TemperatureCalculator.c
ceedling-0.16.0 vendor/cmock/examples/src/TemperatureCalculator.c
ceedling-0.15.6 vendor/cmock/examples/src/TemperatureCalculator.c
ceedling-0.15.6 examples/temp_sensor/src/TemperatureCalculator.c
ceedling-0.15.5 vendor/cmock/examples/src/TemperatureCalculator.c
ceedling-0.15.5 examples/temp_sensor/src/TemperatureCalculator.c
ceedling-0.15.4 examples/temp_sensor/src/TemperatureCalculator.c
ceedling-0.15.4 vendor/cmock/examples/src/TemperatureCalculator.c
ceedling-0.15.3 examples/temp_sensor/src/TemperatureCalculator.c
ceedling-0.15.3 vendor/cmock/examples/src/TemperatureCalculator.c
ceedling-0.15.2 vendor/cmock/examples/src/TemperatureCalculator.c