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
edd4d2f5
Commit
edd4d2f5
authored
Aug 09, 2016
by
Yuelong Yu
Browse files
added LTCC temperature readout
parent
c2d13d34
Changes
3
Hide whitespace changes
Inline
Side-by-side
agipdmc/MicroController.cpp
View file @
edd4d2f5
...
...
@@ -9,6 +9,11 @@ namespace AGIPDMC_ns
const
double
MicroController
::
TEMPERATURE_NOM
=
298.14
;
const
double
MicroController
::
BNTC
=
3901.3
;
MicroController
::
MicroController
()
:
m_vstTemperatures
(
MODULE_NUMBERS
)
{
}
void
MicroController
::
SetRawData
(
vector
<
short
>&
vshData
)
{
m_vshMatrix
=
vshData
;
...
...
@@ -17,8 +22,28 @@ namespace AGIPDMC_ns
int
MicroController
::
CalculateAllTemperatures
()
{
m_vstTemperatures
.
clear
();
m_vstTemperatures
.
resize
(
MODULE_NUMBERS
);
//update temperature on board
int
i
=
0
;
for
(
auto
nIdx
:
TEMPERATURE_INDEX_TABLE
)
CalculateTemperaturesOnEachBoard
(
nIdx
/
2
);
{
vector
<
double
>
vdTmp
=
CalculateTemperaturesOnEachBoard
(
nIdx
/
2
);
m_vstTemperatures
[
i
].
dBoardTemperature1
=
vdTmp
[
0
];
m_vstTemperatures
[
i
].
dBoardTemperature2
=
vdTmp
[
1
];
m_vstTemperatures
[
i
].
dBoardTemperature3
=
vdTmp
[
2
];
i
++
;
}
//update temperature on LTCC
i
=
0
;
for
(
auto
nIdx
:
LTCC_INDEX_TABLE
)
{
short
shADCValue
=
m_vshMatrix
[
nIdx
/
2
];
shADCValue
=
(((
shADCValue
&
0xff00
)
>>
8
)
|
((
shADCValue
&
0xff
)
<<
8
))
&
0xfff
;
double
dTemp
=
CalculateLTCCTemperature
(
shADCValue
);
m_vstTemperatures
[
i
].
dLTCCTemperature
=
dTemp
;
i
++
;
}
}
vector
<
stTemperature
>
MicroController
::
GetAllTemperatures
()
const
...
...
@@ -52,10 +77,23 @@ namespace AGIPDMC_ns
}
}
void
MicroController
::
CalculateTemperaturesOnEachBoard
(
int
nIdxBegin
)
double
MicroController
::
CalculateLTCCTemperature
(
double
dADU
)
{
try
{
return
GetPt100Temperature
(
dADU
);
}
catch
(
exception
&
e
)
{
cout
<<
"CalculateTemperatures:"
<<
e
.
what
()
<<
endl
;
return
nan
(
""
);
}
}
vector
<
double
>
MicroController
::
CalculateTemperaturesOnEachBoard
(
int
nIdxBegin
)
{
stTemperature
stTmp
;
int
nOffSet
=
0x
8
;
int
nOffSet
=
0x
4
;
vector
<
double
>
vdTmp
;
double
dResult
;
...
...
@@ -66,13 +104,13 @@ namespace AGIPDMC_ns
// branch b
// temperature sensor(near voltage regulator ADC "U")
// big endian data, for high byte, only last 4 bits are used
short
shEntry1
=
m_vshMatrix
[
nIdxBegin
+
nOffSet
+
i
*
2
];
shEntry1
=
(((
shEntry1
&
0xff00
)
>>
8
)
&
0xf
)
|
((
shEntry1
&
0xff
)
<<
8
);
short
shEntry1
=
m_vshMatrix
[
nIdxBegin
+
nOffSet
+
i
];
shEntry1
=
(((
shEntry1
&
0xff00
)
>>
8
)
|
((
shEntry1
&
0xff
)
<<
8
)
)
&
0xfff
;
//branch b
//temperature sensor(near voltage regulator ADC "U_plus_I")
short
shEntry2
=
m_vshMatrix
[
nIdxBegin
+
nOffSet
+
(
i
+
1
)
*
2
];
shEntry2
=
(((
shEntry2
&
0xff00
)
>>
8
)
&
0xf
)
|
((
shEntry2
&
0xff
)
<<
8
);
short
shEntry2
=
m_vshMatrix
[
nIdxBegin
+
nOffSet
+
(
i
+
1
)
];
shEntry2
=
(((
shEntry2
&
0xff00
)
&
0xf
)
|
((
shEntry2
&
0xff
)
<<
8
)
)
&
0xfff
;
dResult
=
CalculateTemperatures
(
NormalizeResistor
(
shEntry1
,
shEntry2
));
...
...
@@ -85,11 +123,36 @@ namespace AGIPDMC_ns
vdTmp
.
push_back
(
dResult
);
}
stTmp
.
dBoardTemperature1
=
vdTmp
[
0
];
stTmp
.
dBoardTemperature2
=
vdTmp
[
1
];
stTmp
.
dBoardTemperature3
=
vdTmp
[
2
];
m_vstTemperatures
.
push_back
(
stTmp
);
return
vdTmp
;
}
double
MicroController
::
GetPt100Temperature
(
double
dADU
)
{
long
ADC_Value
=
0
;
double
const
A
=
3.9083E-3
;
double
const
B
=
-
5.775E-7
;
double
const
R0
=
1000
;
double
const
ADC_Res
=
4096.0
;
double
const
ADC_Ref
=
1.25
;
double
const
ADC_Const_Current
=
0.0005185
;
//0.0005175
double
T
=
0
;
// Temperatur bei 0°C
double
voltage
;
double
r
=
100
;
/* Read ADC-Values */
ADC_Value
=
dADU
;
/* Calculate Voltage according to ADC-Value */
voltage
=
ADC_Ref
*
ADC_Value
/
ADC_Res
;
/* Calculate pt1000 resistance*/
r
=
voltage
/
ADC_Const_Current
;
/* Get Temperature using pt1000 second degree polynomial */
T
=
((
-
A
*
R0
)
+
(
sqrt
(((
A
*
R0
)
*
(
A
*
R0
))
-
(
4
*
B
*
R0
*
(
R0
-
r
)))))
/
(
2
*
B
*
R0
);
return
T
;
}
}
agipdmc/MicroController.h
View file @
edd4d2f5
...
...
@@ -9,8 +9,9 @@ namespace AGIPDMC_ns
{
using
namespace
std
;
const
double
UNKNOWN_VALUE
=
-
9999
;
/* for exception */
const
int
MODULE_NUMBERS
=
16
;
/**
* @brief \temprature for each module. Temperature unit is :Kelvin
* on the pcb board, there there are three temperature sensors
...
...
@@ -21,21 +22,33 @@ namespace AGIPDMC_ns
double
dBoardTemperature1
;
double
dBoardTemperature2
;
double
dBoardTemperature3
;
double
dLTCCTemperature
;
stTemperature
()
:
dBoardTemperature1
(
UNKNOWN_VALUE
),
dBoardTemperature2
(
UNKNOWN_VALUE
),
dBoardTemperature3
(
UNKNOWN_VALUE
),
dLTCCTemperature
(
UNKNOWN_VALUE
)
{}
};
const
vector
<
int
>
TEMPERATURE_INDEX_TABLE
=
{
0x280
,
0x2C0
,
0x420
,
0x460
,
0x5c0
,
0x600
,
0x760
,
0x7a0
,
0x900
,
0x940
,
0xaa0
,
0xae0
,
0xc40
,
0xc80
,
0xde0
,
0xe20
0x760
,
0x7a0
/*
0x900,0x940,
*/
/*
0xaa0,0xae0,
*/
/*
0xc40,0xc80,
*/
/*
0xde0,0xe20
*/
};
const
double
UNKNOWN_VALUE
=
-
9999
;
/* for exception */
const
vector
<
int
>
LTCC_INDEX_TABLE
=
{
0x1C70
,
0x1DD0
,
0x1F30
,
0x2090
,
0x21F0
,
0x2350
,
0x24B0
,
0X2610
};
/**
* @brief class of microcontroller.
...
...
@@ -44,6 +57,7 @@ namespace AGIPDMC_ns
class
MicroController
{
public:
MicroController
();
/**
* @brief set raw data which is read from microcontroller
* @param vector of the raw data
...
...
@@ -82,15 +96,28 @@ namespace AGIPDMC_ns
* @return temperature in Kelvin or nan if exception is caught
*/
double
CalculateTemperatures
(
double
dRnorm
);
/**
* @brief calculate LTCC temperature
* @param adu value
* @return LTCC temperature
*/
double
CalculateLTCCTemperature
(
double
dADU
);
/**
* @brief calculate all temperatures of each board
* @param address of data
* The temperature related to each board are 32*short type
* Each index refers to 16bytes
* In order to get the temperature 12 bytes are related.
* The temperature related to each board are 32*short type
* Each index refers to 16bytes
* In order to get the temperature 12 bytes are related.
* @return temperature list
*/
vector
<
double
>
CalculateTemperaturesOnEachBoard
(
int
nIdxBegin
);
/**
* @brief get it from original code
*/
void
CalculateTemperaturesOnEachBoard
(
int
nIdxBegin
);
double
GetPt100Temperature
(
double
dADU
);
/* raw data from microcontroller */
...
...
agipdmc/UpdateDataThread.cpp
View file @
edd4d2f5
...
...
@@ -80,19 +80,35 @@ namespace AGIPDMC_ns
{
if
(
nIdx
<
m_vstTemperature
.
size
())
return
const_cast
<
char
*>
((
to_string
(
m_vstTemperature
[
nIdx
].
dBoardTemperature1
)
+
string
(
";"
)
+
to_string
(
m_vstTemperature
[
nIdx
].
dBoardTemperature2
)
+
string
(
";"
)
+
to_string
(
m_vstTemperature
[
nIdx
].
dBoardTemperature3
)).
c_str
());
{
string
strMsg
;
if
(
m_vstTemperature
[
nIdx
].
dBoardTemperature1
==
UNKNOWN_VALUE
)
strMsg
=
"X;"
;
else
strMsg
=
to_string
(
m_vstTemperature
[
nIdx
].
dBoardTemperature1
)
+
string
(
";"
);
if
(
m_vstTemperature
[
nIdx
].
dBoardTemperature2
==
UNKNOWN_VALUE
)
strMsg
+=
"X;"
;
else
strMsg
+=
to_string
(
m_vstTemperature
[
nIdx
].
dBoardTemperature2
)
+
string
(
";"
);
if
(
m_vstTemperature
[
nIdx
].
dBoardTemperature3
==
UNKNOWN_VALUE
)
strMsg
+=
"X;"
;
else
strMsg
+=
to_string
(
m_vstTemperature
[
nIdx
].
dBoardTemperature3
)
+
string
(
";"
);
if
(
m_vstTemperature
[
nIdx
].
dLTCCTemperature
==
UNKNOWN_VALUE
)
strMsg
+=
"X;"
;
else
strMsg
+=
to_string
(
m_vstTemperature
[
nIdx
].
dLTCCTemperature
)
+
string
(
";"
);
return
const_cast
<
char
*>
(
strMsg
.
c_str
());
}
else
{
return
const_cast
<
char
*>
((
to_string
(
UNKNOWN_VALUE
)
+
string
(
";"
)
+
to_string
(
UNKNOWN_VALUE
)
+
string
(
";"
)
+
to_string
(
UNKNOWN_VALUE
)).
c_str
());
return
const_cast
<
char
*>
(
string
(
"X;X;X;X"
).
c_str
());
}
}
void
UpdateDataThread
::
UpdateTemperatures
(
vector
<
short
>&
vshData
)
...
...
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