Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tango-ds
DeviceClasses
Acquisition
2D
AGIPD
Commits
2be5f7b5
Commit
2be5f7b5
authored
Jul 08, 2016
by
Yuelong Yu
Browse files
added temeprature read
parent
52e2ca5e
Changes
2
Hide whitespace changes
Inline
Side-by-side
agipdmc/MicroController.cpp
0 → 100644
View file @
2be5f7b5
#include
"MicroController.h"
namespace
AGIPDMC_ns
{
const
int
MicroController
::
RNTC
=
10000
;
const
int
MicroController
::
RF
=
100
;
const
int
MicroController
::
RI
=
10000
;
const
double
MicroController
::
TEMPERATURE_NOM
=
298.14
;
const
double
MicroController
::
BNTC
=
3901.3
;
const
double
MicroController
::
UNKNOWN_VALUE
=
-
9999
;
void
MicroController
::
SetRawData
(
vector
<
short
>&
vshData
)
{
m_vshMatrix
=
vshData
}
int
MicroController
::
CalculateAllTemperatures
();
{
}
vector
<
stTemperature
>
MicroController
::
GetAllTemperatures
()
const
{
return
m_vstTemperatures
;
}
double
MicroController
::
NormalizeResistor
(
double
dUu
,
double
dUuplusi
)
{
try
{
return
(
RI
*
(
dUu
/
(
dUuplusi
-
dUu
))
-
2
*
RF
)
/
RTC
;
}
catch
(
exception
&
e
)
{
cout
<<
"NormalizeResistor:"
<<
e
.
what
()
<<
endl
;
return
nan
(
""
);
}
}
double
MicroController
::
CalculateTemperatures
(
double
dRnorm
)
{
try
{
return
1
/
((
1
/
TEMPERATURE_NOM
)
+
(
1
/
BNTC
)
*
log
(
dRnorm
));
}
catch
(
exception
&
e
)
{
cout
<<
"CalculateTemperatures:"
<<
e
.
what
()
<<
endl
;
return
nan
(
""
);
}
}
}
agipdmc/MicroController.h
0 → 100644
View file @
2be5f7b5
#ifndef __MICRO_CONTROLLER_H__
#define __MICRO_CONTROLLER_H__
#include
<math.h>
namespace
AGIPDMC_ns
{
/**
* @brief \temprature for each module. Temperature unit is :Kelvin
* on the pcb board, there there are three temperature sensors
* there is also ltcc temperature. Needs to be added later.
*/
struct
stTemperature
{
double
dTemperature1
;
double
dTemperature2
;
double
dTemperature3
;
};
/**
* @brief class of microcontroller.
* used to process the raw data from microcontroller.
*/
class
MicroController
{
public:
/**
* @brief set raw data which is read from microcontroller
* @param vector of the raw data
*/
void
SetRawData
(
vector
<
short
>&
vshData
);
/**
* @brief calculate temperatures
* @return error code 0:OK; other:error;
* The temperature could be calculated with following way:
* 1.Getting the normalized resistor of th NTC @see NormalizeResistor();
* x=(Ri*(Uu/(Uu_plus_i-Uu))-2Rf)/Rntc where Uu,Uu_plus_i could be read from matrix
* 2. Getting the temperature in Kelvin from the normalized resistor X
* T=1/(1/Tnom+(1/Bntc)*ln(x))
*/
int
CalculateAllTemperatures
();
/**
* @brief get all temperatures
* @return vector of temperatures
*/
vector
<
stTemperature
>
GetAllTemperatures
()
const
;
private:
/**
* @brief normailize resistor
* @param dUu read from matrix
* @param dUuplusi read from matrix
* @return normalized resistor or nan if exception is caught
*/
double
NormalizeResistor
(
double
dUu
,
double
dUuplusi
);
/**
* @brief calcuate temperature
* @param normalized resistor value
* @return temperature in Kelvin or nan if exception is caught
*/
double
CalculateTemperatures
(
double
dRnorm
)
{
return
1
/
((
1
/
dTemperatureNOM
)
+
(
1
/
dBNTC
)
*
log
(
dRnorm
));
}
/* raw data from microcontroller */
vector
<
short
>
m_vshMatrix
;
/* temperatures list */
vector
<
stTemperature
>
m_vstTemperatures
;
/* const variables */
static
const
int
RNTC
;
/* unit:Ohm */
static
const
int
RF
;
/* unit:Ohm */
static
const
int
RI
;
/* unit:Ohm */
static
const
double
TEMPERATURE_NOM
;
/* unit:Kelvin */
static
const
double
BNTC
;
/* unit:Kelvin */
static
const
double
UNKNOW_VALUE
;
/* for exception */
};
}
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment