A public repository for BMS algorithms for a NUCLEO BOARD.

Dependencies:   mbed

Hi Everyone!

Welcome to this repository from Howey's Research Group at the University of Oxford.

The code published here incorporates BMS algorithms for diagnosis functions such as SOC, SOH and Power estimation on a Kokam 53Ah Li-ion battery. This code was designed to work with a NUCLEO F401-RE board and to be tested with a dSPACE HIL Simulator. A short guide on how the set up works is available at https://bitbucket.org/ff95/bms .

The code is made up of three key parts. "Headers" and "Source" folders and the "main.cpp" file. As the code was generated by converting a Simulink model ( available on the BitBucket page), the headers and source code files generated by the conversion are in the corresponding "Headers" and "Source" folders. The "main.cpp" file sets up the ADC, the USB data transmission and starts the estimation (once a character "y" has been received by the computer it is connected to). It also transmits the data from the estimation via USB. Explanation on how to set up the communication with the board is available at BitBucket webpage, from where a MATLAB file can be downloaded which allows real time communication.

For any questions you can contact the author at federicomariaferrari@gmail.com .

The Simulink and Matlab files, together with a short guide, are all available at: https://bitbucket.org/ff95/bms.

Thanks for trying this out!

Federico

Committer:
fmferrari
Date:
Thu Dec 08 18:46:51 2016 +0000
Revision:
8:339dd9885af3
Child:
11:e39c490420d2
First Successfully compiled of the EKF

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fmferrari 8:339dd9885af3 1 //
fmferrari 8:339dd9885af3 2 // Academic License - for use in teaching, academic research, and meeting
fmferrari 8:339dd9885af3 3 // course requirements at degree granting institutions only. Not for
fmferrari 8:339dd9885af3 4 // government, commercial, or other organizational use.
fmferrari 8:339dd9885af3 5 //
fmferrari 8:339dd9885af3 6 // File: rtGetInf.cpp
fmferrari 8:339dd9885af3 7 //
fmferrari 8:339dd9885af3 8 // Code generated for Simulink model 'EKF'.
fmferrari 8:339dd9885af3 9 //
fmferrari 8:339dd9885af3 10 // Model version : 1.6
fmferrari 8:339dd9885af3 11 // Simulink Coder version : 8.11 (R2016b) 25-Aug-2016
fmferrari 8:339dd9885af3 12 // C/C++ source code generated on : Thu Dec 8 19:03:07 2016
fmferrari 8:339dd9885af3 13 //
fmferrari 8:339dd9885af3 14 // Target selection: ert.tlc
fmferrari 8:339dd9885af3 15 // Embedded hardware selection: STMicroelectronics->ST10/Super10
fmferrari 8:339dd9885af3 16 // Code generation objectives: Unspecified
fmferrari 8:339dd9885af3 17 // Validation result: Not run
fmferrari 8:339dd9885af3 18 //
fmferrari 8:339dd9885af3 19
fmferrari 8:339dd9885af3 20 //
fmferrari 8:339dd9885af3 21 // Abstract:
fmferrari 8:339dd9885af3 22 // Function to initialize non-finite, Inf
fmferrari 8:339dd9885af3 23 #include "rtGetInf.h"
fmferrari 8:339dd9885af3 24 #define NumBitsPerChar 8U
fmferrari 8:339dd9885af3 25
fmferrari 8:339dd9885af3 26 extern "C" {
fmferrari 8:339dd9885af3 27 //
fmferrari 8:339dd9885af3 28 // Initialize rtInf needed by the generated code.
fmferrari 8:339dd9885af3 29 // Inf is initialized as non-signaling. Assumes IEEE.
fmferrari 8:339dd9885af3 30 //
fmferrari 8:339dd9885af3 31 real_T rtGetInf(void)
fmferrari 8:339dd9885af3 32 {
fmferrari 8:339dd9885af3 33 size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);
fmferrari 8:339dd9885af3 34 real_T inf = 0.0;
fmferrari 8:339dd9885af3 35 if (bitsPerReal == 32U) {
fmferrari 8:339dd9885af3 36 inf = rtGetInfF();
fmferrari 8:339dd9885af3 37 } else {
fmferrari 8:339dd9885af3 38 union {
fmferrari 8:339dd9885af3 39 LittleEndianIEEEDouble bitVal;
fmferrari 8:339dd9885af3 40 real_T fltVal;
fmferrari 8:339dd9885af3 41 } tmpVal;
fmferrari 8:339dd9885af3 42
fmferrari 8:339dd9885af3 43 tmpVal.bitVal.words.wordH = 0x7FF00000U;
fmferrari 8:339dd9885af3 44 tmpVal.bitVal.words.wordL = 0x00000000U;
fmferrari 8:339dd9885af3 45 inf = tmpVal.fltVal;
fmferrari 8:339dd9885af3 46 }
fmferrari 8:339dd9885af3 47
fmferrari 8:339dd9885af3 48 return inf;
fmferrari 8:339dd9885af3 49 }
fmferrari 8:339dd9885af3 50
fmferrari 8:339dd9885af3 51 //
fmferrari 8:339dd9885af3 52 // Initialize rtInfF needed by the generated code.
fmferrari 8:339dd9885af3 53 // Inf is initialized as non-signaling. Assumes IEEE.
fmferrari 8:339dd9885af3 54 //
fmferrari 8:339dd9885af3 55 real32_T rtGetInfF(void)
fmferrari 8:339dd9885af3 56 {
fmferrari 8:339dd9885af3 57 IEEESingle infF;
fmferrari 8:339dd9885af3 58 infF.wordL.wordLuint = 0x7F800000U;
fmferrari 8:339dd9885af3 59 return infF.wordL.wordLreal;
fmferrari 8:339dd9885af3 60 }
fmferrari 8:339dd9885af3 61
fmferrari 8:339dd9885af3 62 //
fmferrari 8:339dd9885af3 63 // Initialize rtMinusInf needed by the generated code.
fmferrari 8:339dd9885af3 64 // Inf is initialized as non-signaling. Assumes IEEE.
fmferrari 8:339dd9885af3 65 //
fmferrari 8:339dd9885af3 66 real_T rtGetMinusInf(void)
fmferrari 8:339dd9885af3 67 {
fmferrari 8:339dd9885af3 68 size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);
fmferrari 8:339dd9885af3 69 real_T minf = 0.0;
fmferrari 8:339dd9885af3 70 if (bitsPerReal == 32U) {
fmferrari 8:339dd9885af3 71 minf = rtGetMinusInfF();
fmferrari 8:339dd9885af3 72 } else {
fmferrari 8:339dd9885af3 73 union {
fmferrari 8:339dd9885af3 74 LittleEndianIEEEDouble bitVal;
fmferrari 8:339dd9885af3 75 real_T fltVal;
fmferrari 8:339dd9885af3 76 } tmpVal;
fmferrari 8:339dd9885af3 77
fmferrari 8:339dd9885af3 78 tmpVal.bitVal.words.wordH = 0xFFF00000U;
fmferrari 8:339dd9885af3 79 tmpVal.bitVal.words.wordL = 0x00000000U;
fmferrari 8:339dd9885af3 80 minf = tmpVal.fltVal;
fmferrari 8:339dd9885af3 81 }
fmferrari 8:339dd9885af3 82
fmferrari 8:339dd9885af3 83 return minf;
fmferrari 8:339dd9885af3 84 }
fmferrari 8:339dd9885af3 85
fmferrari 8:339dd9885af3 86 //
fmferrari 8:339dd9885af3 87 // Initialize rtMinusInfF needed by the generated code.
fmferrari 8:339dd9885af3 88 // Inf is initialized as non-signaling. Assumes IEEE.
fmferrari 8:339dd9885af3 89 //
fmferrari 8:339dd9885af3 90 real32_T rtGetMinusInfF(void)
fmferrari 8:339dd9885af3 91 {
fmferrari 8:339dd9885af3 92 IEEESingle minfF;
fmferrari 8:339dd9885af3 93 minfF.wordL.wordLuint = 0xFF800000U;
fmferrari 8:339dd9885af3 94 return minfF.wordL.wordLreal;
fmferrari 8:339dd9885af3 95 }
fmferrari 8:339dd9885af3 96 }
fmferrari 8:339dd9885af3 97 //
fmferrari 8:339dd9885af3 98 // File trailer for generated code.
fmferrari 8:339dd9885af3 99 //
fmferrari 8:339dd9885af3 100 // [EOF]
fmferrari 8:339dd9885af3 101 //