aboutsummaryrefslogtreecommitdiffstats
path: root/cphidgettemperaturesensor.h
blob: 867562c92736d2425158d43b885da83af79ca048 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#ifndef __CPHIDGETTEMPERATURESENSOR
#define __CPHIDGETTEMPERATURESENSOR
#include "cphidget.h"

/** \defgroup phidtemp Phidget Temperature Sensor 
 * \ingroup phidgets
 * These calls are specific to the Phidget Temperature Sensor object. See your device's User Guide for more specific API details, technical information, and revision details. The User Guide, along with other resources, can be found on the product page for your device.
 *
 * All temperatures are in degrees celcius.
 * @{
 */

DPHANDLE(TemperatureSensor)
CHDRSTANDARD(TemperatureSensor)

/**
 * The Phidget Temperature Sensor supports these types of thermocouples.
 */
typedef enum {
	PHIDGET_TEMPERATURE_SENSOR_K_TYPE = 1,	/**< K-Type thermocouple */
	PHIDGET_TEMPERATURE_SENSOR_J_TYPE,		/**< J-Type thermocouple */
	PHIDGET_TEMPERATURE_SENSOR_E_TYPE,		/**< E-Type thermocouple */
	PHIDGET_TEMPERATURE_SENSOR_T_TYPE		/**< T-Type thermocouple */
}  CPhidgetTemperatureSensor_ThermocoupleType;

/**
 * Gets the number of thermocouple inputs supported by this board.
 * @param phid An attached phidget themperature sensor handle.
 * @param count The thermocouple input count.
 */
CHDRGET(TemperatureSensor,TemperatureInputCount,int *count)
/**
 * Gets the temperature measured by a thermocouple input.
 * @param phid An attached phidget themperature sensor handle.
 * @param index The thermocouple index.
 * @param temperature The temperature.
 */
CHDRGETINDEX(TemperatureSensor,Temperature,double *temperature)
/**
 * Gets the maximum temperature that can be measured by a thermocouple input. This depends on the type of thermocouple attached, as well as the ambient temperature.
 * @param phid An attached phidget themperature sensor handle.
 * @param index The thermocouple index.
 * @param max The maximum temperature.
 */
CHDRGETINDEX(TemperatureSensor,TemperatureMax,double *max)
/**
 * Gets the minimum temperature that can be measured by a thermocouple input. This depends on the type of thermocouple attached, as well as the ambient temperature.
 * @param phid An attached phidget themperature sensor handle.
 * @param index The thermocouple index.
 * @param min The minimum temperature.
 */
CHDRGETINDEX(TemperatureSensor,TemperatureMin,double *min)
/**
 * Set a temperature change handler. This is called when the temperature changes by more then the change trigger.
 * @param phid An attached phidget temperature sensor handle.
 * @param fptr Callback function pointer.
 * @param userPtr A pointer for use by the user - this value is passed back into the callback function.
 */
CHDREVENTINDEX(TemperatureSensor,TemperatureChange,double temperature)
/**
 * Gets the change trigger for a thermocouple input.
 * @param phid An attached phidget themperature sensor handle.
 * @param index The thermocouple index.
 * @param trigger The change trigger.
 */
CHDRGETINDEX(TemperatureSensor,TemperatureChangeTrigger,double *trigger)
/**
 * Sets the change trigger for a thermocouple input.
 * @param phid An attached phidget themperature sensor handle.
 * @param index The thermocouple index.
 * @param trigger The change trigger.
 */
CHDRSETINDEX(TemperatureSensor,TemperatureChangeTrigger,double trigger)

/**
 * Gets the currently sensed potential for a thermocouple input.
 * @param phid An attached phidget themperature sensor handle.
 * @param index The thermocouple index.
 * @param potential The potential.
 */
CHDRGETINDEX(TemperatureSensor,Potential,double *potential)
/**
 * Gets the maximum potential that a thermocouple input can measure.
 * @param phid An attached phidget themperature sensor handle.
 * @param index The thermocouple index.
 * @param max The maximum potential.
 */
CHDRGETINDEX(TemperatureSensor,PotentialMax,double *max)
/**
 * Gets the minimum potential that a thermocouple input can measure.
 * @param phid An attached phidget themperature sensor handle.
 * @param index The thermocouple index.
 * @param min The minimum potential.
 */
CHDRGETINDEX(TemperatureSensor,PotentialMin,double *min)

/**
 * Gets the ambient (board) temperature.
 * @param phid An attached phidget themperature sensor handle.
 * @param ambient The ambient (board) temperature.
 */
CHDRGET(TemperatureSensor,AmbientTemperature,double *ambient)
/**
 * Gets the maximum temperature that the ambient onboard temperature sensor can measure.
 * @param phid An attached phidget themperature sensor handle.
 * @param max The maximum temperature.
 */
CHDRGET(TemperatureSensor,AmbientTemperatureMax,double *max)
/**
 * Gets the minimum temperature that the ambient onboard temperature sensor can measure.
 * @param phid An attached phidget themperature sensor handle.
 * @param min The minimum temperature.
 */
CHDRGET(TemperatureSensor,AmbientTemperatureMin,double *min)

/**
 * Gets the type of thermocouple set to be at a thermocouple input. By default this is K-Type.
 * @param phid An attached phidget themperature sensor handle.
 * @param index The thermocouple index.
 * @param type The thermocouple type.
 */
CHDRGETINDEX(TemperatureSensor, ThermocoupleType, CPhidgetTemperatureSensor_ThermocoupleType *type)
/**
 * Sets the type of thermocouple plugged into a thermocouple input. By default this is K-Type.
 * @param phid An attached phidget themperature sensor handle.
 * @param index The thermocouple index.
 * @param type The thermocouple type.
 */
CHDRSETINDEX(TemperatureSensor, ThermocoupleType, CPhidgetTemperatureSensor_ThermocoupleType type)

#ifndef REMOVE_DEPRECATED
DEP_CHDRGET("Deprecated - use CPhidgetTemepratureSensor_getTemperatureInputCount",TemperatureSensor,NumTemperatureInputs,int *)
#endif

#ifndef EXTERNALPROTO
#define TEMPSENSOR_MAXSENSORS 8

#define GAIN 85.0
#define OFFSET_200 -6.5
#define OFFSET_300 ((200.0/237.0)*5.0)

#define PHIDID_TEMPERATURESENSOR_4_GAIN		((80 / 2.2) + 5)
//using 53.6K + 10K offset resistors: VOffset = (4.096Vref * 10K) / (10K + 53.6K)
#define PHIDID_TEMPERATURESENSOR_4_OFFSET	(4.096 / 6.36)

struct _CPhidgetTemperatureSensor {
	CPhidget phid;

	int (CCONV *fptrTemperatureChange)(CPhidgetTemperatureSensorHandle, void *, int, double);
	void *fptrTemperatureChangeptr;

	double AmbientTemperature;
	double Temperature[TEMPSENSOR_MAXSENSORS];
	double Potential[TEMPSENSOR_MAXSENSORS];

	double lastTrigger[TEMPSENSOR_MAXSENSORS];

	double TempChangeTrigger[TEMPSENSOR_MAXSENSORS];
	CPhidgetTemperatureSensor_ThermocoupleType ThermocoupleType[TEMPSENSOR_MAXSENSORS];

	double ambientTemperatureMax, ambientTemperatureMin;
	double temperatureMax[TEMPSENSOR_MAXSENSORS], temperatureMin[TEMPSENSOR_MAXSENSORS];
	double potentialMax, potentialMin;

	unsigned char AmbientTemperatureError, TemperatureError[TEMPSENSOR_MAXSENSORS], PotentialError[TEMPSENSOR_MAXSENSORS];

} typedef CPhidgetTemperatureSensorInfo;
#endif

/** @} */

#endif