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
Voltage.h
Go to the documentation of this file.
1 /*
2  Linear Technology DC2100A Demonstration Board.
3  Reference Application File for Monitoring Voltages from the LTC6804-2 Battery Monitor on the DC2100A PCB.
4 
5  @verbatim
6  This file contains the interface to a task to read the voltages in the DC2100A System at a rate set by VOLTAGE_TASK_RATE.
7 
8  The task measures all cell voltages in the system, and calculates the sum-of-cells voltages for each LTC6804 in the system.
9  Each cell is monitored for under-voltage (UV) and over-voltage (OV), and balancing is automatically stopped if these conditions occur.
10 
11  @endverbatim
12 
13  http://www.linear.com/solutions/5126
14 
15  REVISION HISTORY
16  $Revision: 565 $
17  $Date: 2014-08-13 16:11:06 -0400 (Wed, 13 Aug 2014) $
18 
19  Copyright (c) 2013, Linear Technology Corp.(LTC)
20  All rights reserved.
21 
22  Redistribution and use in source and binary forms, with or without
23  modification, are permitted provided that the following conditions are met:
24 
25  1. Redistributions of source code must retain the above copyright notice, this
26  list of conditions and the following disclaimer.
27  2. Redistributions in binary form must reproduce the above copyright notice,
28  this list of conditions and the following disclaimer in the documentation
29  and/or other materials provided with the distribution.
30 
31  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
32  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
35  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 
42  The views and conclusions contained in the software and documentation are those
43  of the authors and should not be interpreted as representing official policies,
44  either expressed or implied, of Linear Technology Corp.
45 
46 */
47 
48 /*! @file
49  @ingroup Voltage
50  Reference Application File for Monitoring Voltages from the LTC6804-2 Battery Monitor on the DC2100A PCB.
51 */
52 
53 #ifndef __VOLTAGE_H__
54 #define __VOLTAGE_H__
55 
56 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
57 // Includes
58 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
59 #include "Typedefs.h"
60 #include "LTC6804-2.h"
61 
62 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
63 // Definitions
64 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
65 
66 //! @name Voltage Monitor Module Constants
67 //! @{
68 #define VOLTAGE_TASK_RATE 100 //!< in ms, the rate at which the voltage monitor task is executed
69 #define VOLTAGE_CELL_BITS_PER_MV (UV_PER_V/MV_PER_V/LTC6804_VOLTAGE_RESOLUTION) //!< number of bits per mV in cell voltage measurements
70 //! @}
71 
72 typedef unsigned int16 VOLTAGE_CELL_PRESENT_TYPE; //!< Bitmap indicating if a cell input on the LTC6804 is populated or shorted.
73 
74 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
75 // Global Data
76 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
77 
78 //! @name Voltage Measurements
79 //! @{
80 extern unsigned int16 voltage_cell[DC2100A_MAX_BOARDS][DC2100A_NUM_CELLS]; //!< Measured cell voltages for each board in LTC6804_VOLTAGE_RESOLUTION.
81 extern unsigned int16 voltage_sum[DC2100A_MAX_BOARDS]; //!< Measured sum of the cell voltages for this board in LTC6804_SOC_RESOLUTION.
82 extern unsigned int32 voltage_timestamp; //!< Timestamp taken when voltage measurements were started.
83 extern unsigned int8 voltage_balancestamp; //!< 1 if balancers were on when these measurements were taken, otherwise 0
84 //! @}
85 
86 //! @name Under-Voltage and Over-Voltage Monitoring
87 //! @{
88 extern unsigned int16 voltage_vov_threshold; //!< over-voltage threshold in LTC6804_VOLTAGE_RESOLUTION.
89 extern unsigned int16 voltage_vuv_threshold; //!< under-voltage threshold in LTC6804_VOLTAGE_RESOLUTION.
90 extern unsigned int16 voltage_ov_flags[DC2100A_MAX_BOARDS]; //!< Bitmap indicating if a cell input on the LTC6804 is over-voltage (1) or not (0).
91 extern unsigned int16 voltage_uv_flags[DC2100A_MAX_BOARDS]; //!< Bitmap indicating if a cell input on the LTC6804 is under-voltage (1) or not (0).
92 extern VOLTAGE_CELL_PRESENT_TYPE voltage_cell_present_flags[DC2100A_MAX_BOARDS];//!< Bitmap indicating if a cell input on the LTC6804 is unpopulated (0), such that UV conditions should be ignored.
93 //! @}
94 
95 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
96 // Global Prototypes
97 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
98 
99 //! Initializes the parts of the Voltage Module, that need to be initialized upon power-up of the PIC.
100 //! @return void
101 void Voltage_Init(void);
102 
103 //! Initializes the parts of the Voltage Module, that need to be initialized upon wakeup of the LTC6804.
104 //! @return TRUE if initialization was successful.
105 BOOLEAN Voltage_Wakeup_Init(void);
106 
107 //! Executes the Voltage Monitor task.
108 //! - Measures all cell voltages in the system. Note that all DC2100A voltages are started simultaneously and read sequentially.
109 //! - A timestamp is attached to each voltage for mathematical operations to be performed on the samples.
110 //! - The state of the balancers is saved, as the cell voltage measurements are affected by the large DC2100A balance currents.
111 //! - Calculates the sum-of-cells voltages for each LTC6804 in the system.
112 //! - Monitors each cell for UV and OV. Balancing is stopped if UV or OV occurs, and in USB message is sent to the GUI
113 //! @return void
114 void Voltage_Monitor_Task(void);
115 
116 //! Sets the under-voltage and over-voltage thresholds in all DC2100A in the system.
117 //! @return TRUE if voltage thresholds successfully set.
118 BOOLEAN Voltage_UVOV_Thresholds_Set(unsigned int16 vuv_value, //!< over-voltage threshold in LTC6804_VOLTAGE_RESOLUTION.
119  unsigned int16 vov_value //!< under-voltage threshold in LTC6804_VOLTAGE_RESOLUTION.
120  );
121 
122 #endif
unsigned int16 voltage_cell[DC2100A_MAX_BOARDS][DC2100A_NUM_CELLS]
Measured cell voltages for each board in LTC6804_VOLTAGE_RESOLUTION.
Definition: Voltage.c:81
unsigned int8 voltage_balancestamp
1 if balancers were on when these measurements were taken, otherwise 0
Definition: Voltage.c:84
VOLTAGE_CELL_PRESENT_TYPE voltage_cell_present_flags[DC2100A_MAX_BOARDS]
Bitmap indicating if a cell input on the LTC6804 is unpopulated (0), such that UV conditions should b...
Definition: Voltage.c:90
void Voltage_Monitor_Task(void)
Executes the Voltage Monitor task.
Definition: Voltage.c:140
unsigned int32 voltage_timestamp
Timestamp taken when voltage measurements were started.
Definition: Voltage.c:83
unsigned int16 voltage_ov_flags[DC2100A_MAX_BOARDS]
Bitmap indicating if a cell input on the LTC6804 is over-voltage (1) or not (0).
Definition: Voltage.c:88
unsigned int16 voltage_sum[DC2100A_MAX_BOARDS]
Measured sum of the cell voltages for this board in LTC6804_SOC_RESOLUTION.
Definition: Voltage.c:82
BOOLEAN Voltage_Wakeup_Init(void)
Initializes the parts of the Voltage Module, that need to be initialized upon wakeup of the LTC6804...
Definition: Voltage.c:128
unsigned int16 voltage_uv_flags[DC2100A_MAX_BOARDS]
Bitmap indicating if a cell input on the LTC6804 is under-voltage (1) or not (0). ...
Definition: Voltage.c:89
API Header File for LTC6804-2 Multicell Battery Monitors.
void Voltage_Init(void)
Initializes the parts of the Voltage Module, that need to be initialized upon power-up of the PIC...
Definition: Voltage.c:106
unsigned int16 voltage_vov_threshold
over-voltage threshold in LTC6804_VOLTAGE_RESOLUTION.
Definition: Voltage.c:86
unsigned int16 voltage_vuv_threshold
under-voltage threshold in LTC6804_VOLTAGE_RESOLUTION.
Definition: Voltage.c:87
BOOLEAN Voltage_UVOV_Thresholds_Set(unsigned int16 vuv_value, unsigned int16 vov_value)
Sets the under-voltage and over-voltage thresholds in all DC2100A in the system.
Definition: Voltage.c:248
unsigned int16 VOLTAGE_CELL_PRESENT_TYPE
Bitmap indicating if a cell input on the LTC6804 is populated or shorted.
Definition: Voltage.h:72