DC2100A  1.2.0
Bi-Directional Cell Balancer Using the LTC3300-1 and the LTC6804-2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Temperature.h
Go to the documentation of this file.
1 /*
2  Linear Technology DC2100A Demonstration Board.
3  Reference Application File for Monitoring Temperature Sensors through the LTC6804-2 Battery Monitor on the DC2100A PCB.
4  All datasheet references in this file refer to Vishay document number: 33011.
5 
6  @verbatim
7 
8  This code contains a task to read the temperature sensors in the DC2100A System at a rate set by TEMPERATURE_TASK_RATE.
9 
10  J17 of the DC2100A board has connections for DC2100A_NUM_TEMPS thermistors. The DC2100A hardware can only connect to one thermistor
11  at a time, as it is connected to the LTC6804 GPIO channel through one of two LTC1380 analog muxes. The task reads one thermistor each
12  execution, and allows the large time constants that result when switching mux channels to settle in between task executions. Therefore,
13  it takes TEMPERATURE_TASK_RATE * DC2100A_NUM_TEMPS time for all of the thermistor inputs to be read.
14 
15  This code module assumes the resistors are of the 100kOhm Curve Type 1 from Vishay document number 33011. The voltages are sampled,
16  accounting for the large time constants when performing the ADC conversion, with the results stored as to minimize RAM usage. The temperatures for
17  each DC2100A board can be retrieved with a function that converts them to °C. See "Temperature" worksheet on DC2100A_Design.xlsm for details of
18  conversion from ADC counts to °C.
19 
20  The raw ADC values for one DC2100A board can be stored for retrieval by the DC2100A GUI.
21 
22  @endverbatim
23 
24  http://www.linear.com/solutions/5126
25 
26  REVISION HISTORY
27  $Revision: 542 $
28  $Date: 2014-07-31 11:57:59 -0400 (Thu, 31 Jul 2014) $
29 
30  Copyright (c) 2013, Linear Technology Corp.(LTC)
31  All rights reserved.
32 
33  Redistribution and use in source and binary forms, with or without
34  modification, are permitted provided that the following conditions are met:
35 
36  1. Redistributions of source code must retain the above copyright notice, this
37  list of conditions and the following disclaimer.
38  2. Redistributions in binary form must reproduce the above copyright notice,
39  this list of conditions and the following disclaimer in the documentation
40  and/or other materials provided with the distribution.
41 
42  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
43  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
44  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
45  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
46  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
47  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
49  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
51  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 
53  The views and conclusions contained in the software and documentation are those
54  of the authors and should not be interpreted as representing official policies,
55  either expressed or implied, of Linear Technology Corp.
56 
57 */
58 
59 /*! @file
60  @ingroup Temperature
61  Reference Application File for Monitoring Temperature Sensors through the LTC6804-2 Battery Monitor on the DC2100A PCB.
62 */
63 
64 #ifndef __TEMPERATURE_H__
65 #define __TEMPERATURE_H__
66 
67 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
68 // Includes
69 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
70 
71 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
72 // Definitions
73 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
74 
75 //! @name Temperature Monitor Module Constants
76 //! @{
77 //! On DC2100A board, R35 and C30 form a 100ms time constant (thermistor resistance is insignificant to R35 at 0°C).
78 //! Wait 6 time constants before attempting to read thermistors. 3 time constants was determined to give unacceptable
79 //! error at temperatures below -20°C.
80 #define TEMPERATURE_THERMISTOR_DELAY 600 //!< in ms, the delay to wait between thermistor measurements
81 #define TEMPERATURE_TASK_RATE TEMPERATURE_THERMISTOR_DELAY //!< in ms, the rate at which the temperature monitor task is executed.
82 //! @}
83 
84 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
85 // Global Data
86 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
87 extern unsigned int32 temperature_timestamp; //!< Timestamp taken when last temperature measurement was started.
88 
89 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
90 // Global Prototypes
91 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
92 
93 //! Initializes the parts of the Temperature Module, that need to be initialized upon power-up of the PIC.
94 //! @return void
95 void Temperature_Init(void);
96 
97 //! Initializes the parts of the Temperature Module, that need to be initialized upon wakeup of the LTC6804.
98 //! @return TRUE if initialization was successful.
99 BOOLEAN Temperature_Wakeup_Init(void);
100 
101 
102 //! Executes the Temperature Monitor task.
103 //! - Measures one thermistor value on each DC2100 board in the system.
104 //! - Calculates the temperature from the thermistor ADC value..
105 //! - Sets up LTC1380 analog mux channel for the next thermistor measurement.
106 //! - This task must be executed at a maximum of TEMPERATURE_THERMISTOR_DELAY, to allow circuit to settled after analog mux is switched.
107 //! @return void
108 void Temperature_Monitor_Task(void);
109 
110 //! Gets one temperature from one DC2100A PCB.
111 //! @return the temperature in °C.
112 int16 Temperature_Get(int8 board_num, //!< The logical address for the PCB containing this Temperature.
113  int8 temperature_num //!< The temperature number to get from this PCB.
114  );
115 
116 //! Gets the raw ADC values for all of the thermistors on one DC2100A board.
117 //! @return a pointer to the thermistor ADC values for this board. Returns NULL if all ADC values have not yet been taken.
118 int16* Temperature_Adc_Value_Get(int8 board_num //!< The logical address for the PCB containing this Temperature.
119  );
120 
121 #endif
void Temperature_Init(void)
Initializes the parts of the Temperature Module, that need to be initialized upon power-up of the PIC...
Definition: Temperature.c:167
int16 Temperature_Get(int8 board_num, int8 temperature_num)
Gets one temperature from one DC2100A PCB.
Definition: Temperature.c:286
unsigned int32 temperature_timestamp
Timestamp taken when last temperature measurement was started.
Definition: Temperature.c:97
BOOLEAN Temperature_Wakeup_Init(void)
Initializes the parts of the Temperature Module, that need to be initialized upon wakeup of the LTC68...
Definition: Temperature.c:184
int16 * Temperature_Adc_Value_Get(int8 board_num)
Gets the raw ADC values for all of the thermistors on one DC2100A board.
Definition: Temperature.c:298
void Temperature_Monitor_Task(void)
Executes the Temperature Monitor task.
Definition: Temperature.c:217