Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnConstants.h@56:0bba0ef15697, 2014-10-30 (annotated)
- Committer:
- uci1
- Date:
- Thu Oct 30 06:42:17 2014 +0000
- Revision:
- 56:0bba0ef15697
- Parent:
- 55:6767c08111c0
- Child:
- 67:ec999336fcd1
update ext libs, add tempr, allow SST/ATWD, improve handshaking, run/seq list, req seq range, allow SBD only in low pwr, all pins start off, can collect data to ram w/o SD card, add parameters to status update
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
uci1 | 1:e392595b4b76 | 1 | #ifndef SN_SnConstants |
uci1 | 1:e392595b4b76 | 2 | #define SN_SnConstants |
uci1 | 1:e392595b4b76 | 3 | |
uci1 | 56:0bba0ef15697 | 4 | // available CHIPBOARDs |
uci1 | 56:0bba0ef15697 | 5 | #define ATWD4CH 0 // set CHIPBOARD to this to get firmware for the 2012-2013 stations (value is arbitrary but unique) |
uci1 | 56:0bba0ef15697 | 6 | #define SST4CH 1 // set CHIPBOARD to this to get firmware for the 2014 stations with a single SST chip (value is arbitrary but unique) |
uci1 | 56:0bba0ef15697 | 7 | |
uci1 | 56:0bba0ef15697 | 8 | // which chip/board combination to build this firmware for |
uci1 | 56:0bba0ef15697 | 9 | //#define CHIPBOARD ATWD4CH |
uci1 | 56:0bba0ef15697 | 10 | #define CHIPBOARD SST4CH |
uci1 | 56:0bba0ef15697 | 11 | |
uci1 | 1:e392595b4b76 | 12 | #include "SnBitUtils.h" |
uci1 | 37:ff95e7070f26 | 13 | #include "SnCommConstants.h" |
uci1 | 25:57b2627fe756 | 14 | |
uci1 | 1:e392595b4b76 | 15 | // |
uci1 | 1:e392595b4b76 | 16 | // constants |
uci1 | 1:e392595b4b76 | 17 | // |
uci1 | 40:1324da35afd4 | 18 | // if these change, it is likely that some i/o version (config, event, etc) will need to change |
uci1 | 56:0bba0ef15697 | 19 | static const bool kIridPwrFromAfar = false; // true if Iridium & Afar are on the same relay, false if not |
uci1 | 1:e392595b4b76 | 20 | static const uint32_t kBStime = 946684800u; // 1/1/2000 00:00:00 UTC |
uci1 | 56:0bba0ef15697 | 21 | |
uci1 | 56:0bba0ef15697 | 22 | // these constants are used to specify the size of a specific i/o version of a frame, even if e.g. the number of samples changes for later i/o versions |
uci1 | 56:0bba0ef15697 | 23 | // these values should NEVER be changed!! |
uci1 | 56:0bba0ef15697 | 24 | // these values should be used in i/o functions |
uci1 | 56:0bba0ef15697 | 25 | static const uint8_t kNplasV1 = 5u; // to preserve i/o version sizes |
uci1 | 56:0bba0ef15697 | 26 | static const uint16_t kNsampsAtwd = 128u; |
uci1 | 56:0bba0ef15697 | 27 | static const uint16_t kNsampsSst = 256u; |
uci1 | 56:0bba0ef15697 | 28 | static const uint8_t kNchanDacsAtwd = 4u; |
uci1 | 56:0bba0ef15697 | 29 | static const uint8_t kNchanDacsSst = 2u; |
uci1 | 56:0bba0ef15697 | 30 | static const uint8_t kNchansFourAnt = 4u; |
uci1 | 56:0bba0ef15697 | 31 | static const uint16_t kTotSampsAtwd4ch = kNchansFourAnt*kNsampsAtwd; |
uci1 | 56:0bba0ef15697 | 32 | static const uint16_t kTotDacsAtwd4ch = kNchansFourAnt*kNchanDacsAtwd; |
uci1 | 56:0bba0ef15697 | 33 | static const uint16_t kTotSampsSst4ch = kNchansFourAnt*kNsampsSst; |
uci1 | 56:0bba0ef15697 | 34 | static const uint16_t kTotDacsSst4ch = kNchansFourAnt*kNchanDacsSst; |
uci1 | 56:0bba0ef15697 | 35 | static const uint16_t kNstopBytesSst4ch = kNsampsSst / BITS_IN_CHAR; // if the values change, may need to round this numebr |
uci1 | 56:0bba0ef15697 | 36 | |
uci1 | 56:0bba0ef15697 | 37 | // these are the station config sizes, and may change. they should not be used in i/o functions. i/o versions need updating as these change! |
uci1 | 56:0bba0ef15697 | 38 | #if CHIPBOARD==ATWD4CH |
uci1 | 56:0bba0ef15697 | 39 | static const uint8_t kNchans = kNchansFourAnt; |
uci1 | 56:0bba0ef15697 | 40 | static const uint16_t kNsamps = kNsampsAtwd; |
uci1 | 40:1324da35afd4 | 41 | static const uint8_t kNplas = kNplasV1; // update config i/o version if this changes |
uci1 | 56:0bba0ef15697 | 42 | static const uint8_t kNchanDacs = kNchanDacsAtwd; |
uci1 | 1:e392595b4b76 | 43 | static const uint16_t kNoTrigPla = 0x0000u; |
uci1 | 56:0bba0ef15697 | 44 | static const float kAsfClkPrdUs = 8.535; // us -- change kAdcToMBtimeCut if this is <=2us |
uci1 | 56:0bba0ef15697 | 45 | static const float kAdcToMBtimeCut = (kNsamps*kAsfClkPrdUs)+(kAsfClkPrdUs/2.0); |
uci1 | 56:0bba0ef15697 | 46 | #elif CHIPBOARD==SST4CH |
uci1 | 56:0bba0ef15697 | 47 | static const uint8_t kNchans = kNchansFourAnt; |
uci1 | 56:0bba0ef15697 | 48 | static const uint16_t kNsamps = kNsampsSst; |
uci1 | 56:0bba0ef15697 | 49 | static const uint8_t kNchanDacs = kNchanDacsSst; |
uci1 | 56:0bba0ef15697 | 50 | static const uint16_t kNstopBytes = kNstopBytesSst4ch; |
uci1 | 56:0bba0ef15697 | 51 | static const uint8_t kAllLTC2657 = 0x73u << 1; // slave address that every LTC2657 DAC chip will respond to |
uci1 | 56:0bba0ef15697 | 52 | static const uint8_t kUpdateDacCmd = 0x3u; // LTC2657 DAC chip command bits that write to & update DAC value |
uci1 | 56:0bba0ef15697 | 53 | static const uint8_t kMaxDacSetTries = 3u; // how many times to retry setting a dac in case no ACK is received from the DAC chip |
uci1 | 56:0bba0ef15697 | 54 | #endif |
uci1 | 51:b2bc37d660c0 | 55 | static const uint8_t kNcomms = 2u; |
uci1 | 8:95a325df1f6b | 56 | static const uint16_t kNvoltsAve = 500u; // must be greater than ~10 (but not checked. <2 will result in divide by 0) |
uci1 | 16:744ce85aede2 | 57 | |
uci1 | 1:e392595b4b76 | 58 | static const uint32_t kAbsMaxTimer = 1800u; // timers use integers counting us and can't go longer than ~ this many secs |
uci1 | 3:24c5f0f50bf1 | 59 | |
uci1 | 40:1324da35afd4 | 60 | // NOTE: these times (in sec) must be less than kAbsMaxTimer (this is not checked, however) |
uci1 | 40:1324da35afd4 | 61 | static const uint8_t kDefTimeoutMin = 3u; // minutes. used in case a clock error is detected or range needs enforcing |
uci1 | 40:1324da35afd4 | 62 | static const uint32_t kCommWinLongPrdTk = 300u; // seconds. check if it's time for a comm win every X sec. this way comm per can be longer than Timer allows |
uci1 | 40:1324da35afd4 | 63 | |
uci1 | 40:1324da35afd4 | 64 | static const uint16_t kMaxConsecCommFails = 4; // (exclusive) number of times a comm win can fail before the mbed resets |
uci1 | 40:1324da35afd4 | 65 | |
uci1 | 28:484943132bb0 | 66 | // safety nets |
uci1 | 40:1324da35afd4 | 67 | static const uint16_t kMaxFirstSeq = 25000; // max specifiable seq number -- leave room to grow |
uci1 | 28:484943132bb0 | 68 | static const float kMinForcePer = 0.05; // seconds -- safety net for max force trigger rate |
uci1 | 28:484943132bb0 | 69 | static const uint16_t kMaxThrottlePerMs = 60000; // ms -- max time between thermal triggers |
uci1 | 28:484943132bb0 | 70 | static const uint16_t kMaxBatVoltLowPwr = 25000; // ADCs -- probably futile, but try to prevent it from being in low power mode always |
uci1 | 40:1324da35afd4 | 71 | static const uint32_t kMinCommWinPeriod = 120; // seconds -- min time between communication windows |
uci1 | 28:484943132bb0 | 72 | static const uint32_t kMaxCommWinPeriod = 259200; // seconds -- max time between communication windows |
uci1 | 40:1324da35afd4 | 73 | static const uint32_t kMinCommWinDur = 600; // seconds -- min communication window duration -- must be >= Ncomms*listen/connect timeout |
uci1 | 28:484943132bb0 | 74 | static const uint32_t kMaxWatchDogPer = 3600; // seconds -- max time before watchdog reset on idle |
uci1 | 40:1324da35afd4 | 75 | static const uint32_t kMinWatchDogPer = 300; // seconds -- min time before watchdog reset on idle |
uci1 | 28:484943132bb0 | 76 | |
uci1 | 1:e392595b4b76 | 77 | static const uint16_t kTotSamps = kNchans*kNsamps; |
uci1 | 56:0bba0ef15697 | 78 | static const uint16_t kTotDacs = kNchans*kNchanDacs; |
uci1 | 1:e392595b4b76 | 79 | |
uci1 | 16:744ce85aede2 | 80 | |
uci1 | 1:e392595b4b76 | 81 | enum ESnTrgTypes { |
uci1 | 16:744ce85aede2 | 82 | kThmTrg=0, |
uci1 | 56:0bba0ef15697 | 83 | kFrcTrg=1, |
uci1 | 56:0bba0ef15697 | 84 | kExtTrg=2, |
uci1 | 56:0bba0ef15697 | 85 | kAdcToMBflag=3, |
uci1 | 16:744ce85aede2 | 86 | |
uci1 | 1:e392595b4b76 | 87 | kNumTrgs |
uci1 | 1:e392595b4b76 | 88 | }; |
uci1 | 16:744ce85aede2 | 89 | // order must match ESnTrgTypes |
uci1 | 16:744ce85aede2 | 90 | static const uint8_t kTrgBW[kNumTrgs] = { BIT(0), BIT(1), BIT(2), BIT(7) }; |
uci1 | 1:e392595b4b76 | 91 | |
uci1 | 1:e392595b4b76 | 92 | |
uci1 | 1:e392595b4b76 | 93 | |
uci1 | 0:664899e0b988 | 94 | #endif // SN_SnConstants |