ThermistorPack.

Dependents:   Pachube_TestProgram ThermistorPack_TestProgram _DearMrJeffMourich StarBoardOrangeExpansion2 ... more

Files at this revision

API Documentation at this revision

Comitter:
shintamainjp
Date:
Fri Sep 17 23:42:46 2010 +0000
Child:
1:4f84f03b1703
Commit message:

Changed in this revision

Thermistor.cpp Show annotated file Show diff for this revision Revisions of this file
Thermistor.h Show annotated file Show diff for this revision Revisions of this file
ThermistorDummy.cpp Show annotated file Show diff for this revision Revisions of this file
ThermistorDummy.h Show annotated file Show diff for this revision Revisions of this file
ThermistorLM35.cpp Show annotated file Show diff for this revision Revisions of this file
ThermistorLM35.h Show annotated file Show diff for this revision Revisions of this file
ThermistorLM60.cpp Show annotated file Show diff for this revision Revisions of this file
ThermistorLM60.h Show annotated file Show diff for this revision Revisions of this file
ThermistorMCP9701.cpp Show annotated file Show diff for this revision Revisions of this file
ThermistorMCP9701.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Thermistor.cpp	Fri Sep 17 23:42:46 2010 +0000
@@ -0,0 +1,14 @@
+/**
+ * Thermistor interface driver. (Version 0.0.1)
+ *
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ */
+
+#include "Thermistor.h"
+
+Thermistor::Thermistor() {
+}
+
+Thermistor::~Thermistor() {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Thermistor.h	Fri Sep 17 23:42:46 2010 +0000
@@ -0,0 +1,18 @@
+/**
+ * Sensor interface driver. (Version 0.0.1)
+ *
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ */
+
+#ifndef _THERMISTOR_H_
+#define _THERMISTOR_H_
+
+class Thermistor {
+public:
+    Thermistor();
+    virtual ~Thermistor();
+    virtual double read() = 0;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ThermistorDummy.cpp	Fri Sep 17 23:42:46 2010 +0000
@@ -0,0 +1,31 @@
+/**
+ * Sensor interface driver. (Version 0.0.1)
+ *
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ */
+
+#include "ThermistorDummy.h"
+
+ThermistorDummy::ThermistorDummy()
+        : memory(getNextValue(MIN + ((MAX - MIN)/2))) {
+}
+
+ThermistorDummy::~ThermistorDummy() {
+}
+
+double ThermistorDummy::read() {
+    memory = getNextValue(memory);
+    return memory;
+}
+
+double ThermistorDummy::getNextValue(double prev) {
+    static const int THR = 5;
+    int SCOPE = (MAX - MIN) + 1;
+    int tmp = 0;
+    do {
+        tmp = (rand() % SCOPE) + MIN;
+    } while (THR < abs(tmp - prev));
+    int udt = rand() % 10;
+    return (double)tmp + (double)(udt * 0.1);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ThermistorDummy.h	Fri Sep 17 23:42:46 2010 +0000
@@ -0,0 +1,28 @@
+/**
+ * Sensor interface driver. (Version 0.0.1)
+ *
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ */
+
+#ifndef _THERMISTOR_DUMMY_H_
+#define _THERMISTOR_DUMMY_H_
+
+#include <mbed.h>
+
+#include "Thermistor.h"
+
+class ThermistorDummy : public Thermistor {
+public:
+    ThermistorDummy();
+    virtual ~ThermistorDummy();
+    virtual double read();
+private:
+    static const int MIN = -10;
+    static const int MAX = 50;
+    double memory;
+
+    static double getNextValue(double prev);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ThermistorLM35.cpp	Fri Sep 17 23:42:46 2010 +0000
@@ -0,0 +1,22 @@
+/**
+ * Sensor interface driver. (Version 0.0.1)
+ *
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ */
+
+#include "ThermistorLM35.h"
+
+ThermistorLM35::ThermistorLM35(PinName pin)
+        : analogInput(pin) {
+}
+
+ThermistorLM35::~ThermistorLM35() {
+}
+
+double ThermistorLM35::read() {
+    /*
+     * The value range of analogInput.read() is 0.0 to 1.0.
+     */
+    return ((analogInput.read() * 3.3) * 100.0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ThermistorLM35.h	Fri Sep 17 23:42:46 2010 +0000
@@ -0,0 +1,24 @@
+/**
+ * Sensor interface driver. (Version 0.0.1)
+ *
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ */
+
+#ifndef _THERMISTOR_LM35_H_
+#define _THERMISTOR_LM35_H_
+
+#include <mbed.h>
+
+#include "Thermistor.h"
+
+class ThermistorLM35 : public Thermistor {
+public:
+    explicit ThermistorLM35(PinName pin);
+    virtual ~ThermistorLM35();
+    virtual double read();
+private:
+    AnalogIn analogInput;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ThermistorLM60.cpp	Fri Sep 17 23:42:46 2010 +0000
@@ -0,0 +1,22 @@
+/**
+ * Sensor interface driver. (Version 0.0.1)
+ *
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ */
+
+#include "ThermistorLM60.h"
+
+ThermistorLM60::ThermistorLM60(PinName pin)
+        : analogInput(pin) {
+}
+
+ThermistorLM60::~ThermistorLM60() {
+}
+
+double ThermistorLM60::read() {
+    /*
+     * The value range of analogInput.read() is 0.0 to 1.0.
+     */
+    return ((analogInput.read() * 3.3) - 0.424) / 0.00625;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ThermistorLM60.h	Fri Sep 17 23:42:46 2010 +0000
@@ -0,0 +1,24 @@
+/**
+ * Sensor interface driver. (Version 0.0.1)
+ *
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ */
+
+#ifndef _THERMISTOR_LM60_H_
+#define _THERMISTOR_LM60_H_
+
+#include <mbed.h>
+
+#include "Thermistor.h"
+
+class ThermistorLM60 : public Thermistor {
+public:
+    explicit ThermistorLM60(PinName pin);
+    virtual ~ThermistorLM60();
+    virtual double read();
+private:
+    AnalogIn analogInput;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ThermistorMCP9701.cpp	Fri Sep 17 23:42:46 2010 +0000
@@ -0,0 +1,22 @@
+/**
+ * Sensor interface driver. (Version 0.0.1)
+ *
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ */
+
+#include "ThermistorMCP9701.h"
+
+ThermistorMCP9701::ThermistorMCP9701(PinName pin)
+        : analogInput(pin) {
+}
+
+ThermistorMCP9701::~ThermistorMCP9701() {
+}
+
+double ThermistorMCP9701::read() {
+    /*
+     * The value range of analogInput.read() is 0.0 to 1.0.
+     */
+    return (((analogInput.read() * 3.3) - 0.400) / 0.0195);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ThermistorMCP9701.h	Fri Sep 17 23:42:46 2010 +0000
@@ -0,0 +1,24 @@
+/**
+ * Sensor interface driver. (Version 0.0.1)
+ *
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ */
+
+#ifndef _THERMISTOR_MCP9701_H_
+#define _THERMISTOR_MCP9701_H_
+
+#include <mbed.h>
+
+#include "Thermistor.h"
+
+class ThermistorMCP9701 : public Thermistor {
+public:
+    explicit ThermistorMCP9701(PinName pin);
+    virtual ~ThermistorMCP9701();
+    virtual double read();
+private:
+    AnalogIn analogInput;
+};
+
+#endif