Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
inc/adc_defs.h@22:2c37ac12746e, 2019-01-15 (annotated)
- Committer:
- mfwic
- Date:
- Tue Jan 15 01:32:33 2019 +0000
- Revision:
- 22:2c37ac12746e
- Parent:
- 18:78e982f31c6b
- Child:
- 24:078f62c8d0ed
Added hysteresis; Changed LUT to use v12*i12 instead of just i12.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mfwic | 11:01dcfb29fbc4 | 1 | //------------------------------------------------------------------------------- |
| mfwic | 11:01dcfb29fbc4 | 2 | // |
| mfwic | 11:01dcfb29fbc4 | 3 | // Treehouse Designs Inc. |
| mfwic | 11:01dcfb29fbc4 | 4 | // Colorado Springs, Colorado |
| mfwic | 11:01dcfb29fbc4 | 5 | // |
| mfwic | 11:01dcfb29fbc4 | 6 | // Copyright (c) 2016 by Treehouse Designs Inc. |
| mfwic | 11:01dcfb29fbc4 | 7 | // Copyright (c) 2018 by Agility Power Systems Inc. |
| mfwic | 11:01dcfb29fbc4 | 8 | // |
| mfwic | 11:01dcfb29fbc4 | 9 | // This code is the property of Treehouse Designs, Inc. (Treehouse) and |
| mfwic | 11:01dcfb29fbc4 | 10 | // Agility Power Systems Inc. (Agility) and may not be redistributed |
| mfwic | 11:01dcfb29fbc4 | 11 | // in any form without prior written permission from |
| mfwic | 11:01dcfb29fbc4 | 12 | // both copyright holders, Treehouse and Agility. |
| mfwic | 11:01dcfb29fbc4 | 13 | // |
| mfwic | 11:01dcfb29fbc4 | 14 | // The above copyright notice and this permission notice shall be included in |
| mfwic | 11:01dcfb29fbc4 | 15 | // all copies or substantial portions of the Software. |
| mfwic | 11:01dcfb29fbc4 | 16 | // |
| mfwic | 11:01dcfb29fbc4 | 17 | // |
| mfwic | 11:01dcfb29fbc4 | 18 | //------------------------------------------------------------------------------- |
| mfwic | 11:01dcfb29fbc4 | 19 | // |
| mfwic | 11:01dcfb29fbc4 | 20 | // REVISION HISTORY: |
| mfwic | 11:01dcfb29fbc4 | 21 | // |
| mfwic | 11:01dcfb29fbc4 | 22 | // $Author: $ |
| mfwic | 11:01dcfb29fbc4 | 23 | // $Rev: $ |
| mfwic | 11:01dcfb29fbc4 | 24 | // $Date: $ |
| mfwic | 11:01dcfb29fbc4 | 25 | // $URL: $ |
| mfwic | 11:01dcfb29fbc4 | 26 | // |
| mfwic | 11:01dcfb29fbc4 | 27 | //------------------------------------------------------------------------------- |
| mfwic | 11:01dcfb29fbc4 | 28 | |
| mfwic | 15:aed8f326c949 | 29 | #ifndef ADC_DEFS_H |
| mfwic | 15:aed8f326c949 | 30 | #define ADC_DEFS_H |
| mfwic | 15:aed8f326c949 | 31 | |
| mfwic | 11:01dcfb29fbc4 | 32 | #include "parameters.h" |
| mfwic | 11:01dcfb29fbc4 | 33 | |
| mfwic | 11:01dcfb29fbc4 | 34 | const unsigned int ADC_SCALE_FACTOR = ADC_MAX_VALUE/2; |
| mfwic | 11:01dcfb29fbc4 | 35 | |
| mfwic | 11:01dcfb29fbc4 | 36 | #define VOLTAGE_TARG_VALUE 1.65 |
| mfwic | 11:01dcfb29fbc4 | 37 | #define VOLTAGE_48_ACTUAL_VALUE 1.51 |
| mfwic | 11:01dcfb29fbc4 | 38 | #define VOLTAGE_24_ACTUAL_VALUE 1.55 |
| mfwic | 11:01dcfb29fbc4 | 39 | #define VOLTAGE_12_ACTUAL_VALUE 1.53 |
| mfwic | 11:01dcfb29fbc4 | 40 | const double VOLTAGE_48_CORRECTION = VOLTAGE_TARG_VALUE/VOLTAGE_48_ACTUAL_VALUE/ADC_SCALE_FACTOR; |
| mfwic | 11:01dcfb29fbc4 | 41 | const double VOLTAGE_24_CORRECTION = VOLTAGE_TARG_VALUE/VOLTAGE_24_ACTUAL_VALUE/ADC_SCALE_FACTOR; |
| mfwic | 11:01dcfb29fbc4 | 42 | const double VOLTAGE_12_CORRECTION = VOLTAGE_TARG_VALUE/VOLTAGE_12_ACTUAL_VALUE/ADC_SCALE_FACTOR; |
| mfwic | 11:01dcfb29fbc4 | 43 | const double VOLTAGE_48_FACTOR = 48.0*VOLTAGE_48_CORRECTION; |
| mfwic | 11:01dcfb29fbc4 | 44 | const double VOLTAGE_24_FACTOR = 24.0*VOLTAGE_24_CORRECTION; |
| mfwic | 11:01dcfb29fbc4 | 45 | const double VOLTAGE_12_FACTOR = 12.0*VOLTAGE_12_CORRECTION; |
| mfwic | 11:01dcfb29fbc4 | 46 | |
| mfwic | 18:78e982f31c6b | 47 | //#define CURRENT_ACTUAL_VALUE 1.7091 |
| mfwic | 18:78e982f31c6b | 48 | //#define CURRENT_TARG_VALUE 1.65 |
| mfwic | 11:01dcfb29fbc4 | 49 | //const double CURRENT_OFFSET = (CURRENT_ACTUAL_VALUE/CURRENT_TARG_VALUE)*ADC_SCALE_FACTOR; |
| mfwic | 17:454afe56eedb | 50 | //const double CURRENT_48_OFFSET = 33940; |
| mfwic | 17:454afe56eedb | 51 | //const double CURRENT_24_OFFSET = 33580; |
| mfwic | 17:454afe56eedb | 52 | //const double CURRENT_12_OFFSET = 33380; |
| mfwic | 11:01dcfb29fbc4 | 53 | //#define CURRENT_OFFSET 33940 |
| mfwic | 11:01dcfb29fbc4 | 54 | //#define CURRENT_DIV_FACTOR -390 |
| mfwic | 12:fd1fd1857628 | 55 | /* |
| mfwic | 11:01dcfb29fbc4 | 56 | #define CURRENT_48_DIV_FACTOR -368 |
| mfwic | 11:01dcfb29fbc4 | 57 | #define CURRENT_24_DIV_FACTOR -308 |
| mfwic | 12:fd1fd1857628 | 58 | #define CURRENT_12_DIV_FACTOR -324 |
| mfwic | 12:fd1fd1857628 | 59 | */ |
| mfwic | 18:78e982f31c6b | 60 | #define CURRENT_48_DIV_FACTOR -372 |
| mfwic | 18:78e982f31c6b | 61 | #define CURRENT_24_DIV_FACTOR -376 |
| mfwic | 22:2c37ac12746e | 62 | //#define CURRENT_12_DIV_FACTOR -356 |
| mfwic | 22:2c37ac12746e | 63 | #define CURRENT_12_DIV_FACTOR -208 |
| mfwic | 22:2c37ac12746e | 64 | |
| mfwic | 22:2c37ac12746e | 65 | const double ROW_CORRECTION_FACTOR = 1.017; |
| mfwic | 22:2c37ac12746e | 66 | #define ROW_HYSTERESIS 2 |
| mfwic | 15:aed8f326c949 | 67 | |
| mfwic | 17:454afe56eedb | 68 | extern double CURRENT_48_OFFSET; |
| mfwic | 17:454afe56eedb | 69 | extern double CURRENT_24_OFFSET; |
| mfwic | 17:454afe56eedb | 70 | extern double CURRENT_12_OFFSET; |
| mfwic | 17:454afe56eedb | 71 | |
| mfwic | 15:aed8f326c949 | 72 | #endif |