baseline build

Dependencies:   FastPWM mbed-os mbed

Committer:
jrhodes5150
Date:
Mon Jun 19 15:55:51 2017 +0000
Revision:
0:8a420ac6394e
initial build - baseline;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jrhodes5150 0:8a420ac6394e 1 #ifndef __DEVICE_PROPERTIES_H__
jrhodes5150 0:8a420ac6394e 2 #define __DEVICE_PROPERTIES_H__
jrhodes5150 0:8a420ac6394e 3
jrhodes5150 0:8a420ac6394e 4 #include "Mutex.h"
jrhodes5150 0:8a420ac6394e 5 #include "DataContainer.h"
jrhodes5150 0:8a420ac6394e 6 const int MAX_ACQUISITION_SAMPLES = 500;
jrhodes5150 0:8a420ac6394e 7
jrhodes5150 0:8a420ac6394e 8 enum OutputMode
jrhodes5150 0:8a420ac6394e 9 {
jrhodes5150 0:8a420ac6394e 10 OMRamp = 0,
jrhodes5150 0:8a420ac6394e 11 OMConstantVoltage = 1,
jrhodes5150 0:8a420ac6394e 12 OMConstantPower = 2,
jrhodes5150 0:8a420ac6394e 13 OMCalibrate = 3
jrhodes5150 0:8a420ac6394e 14 };
jrhodes5150 0:8a420ac6394e 15
jrhodes5150 0:8a420ac6394e 16 struct DeviceConfig
jrhodes5150 0:8a420ac6394e 17 {
jrhodes5150 0:8a420ac6394e 18 DeviceConfig(void);
jrhodes5150 0:8a420ac6394e 19
jrhodes5150 0:8a420ac6394e 20 // Control Parameters
jrhodes5150 0:8a420ac6394e 21 OutputMode outputMode;
jrhodes5150 0:8a420ac6394e 22 double constantVoltage;
jrhodes5150 0:8a420ac6394e 23 double constantPower;
jrhodes5150 0:8a420ac6394e 24 double kp;
jrhodes5150 0:8a420ac6394e 25 double ki;
jrhodes5150 0:8a420ac6394e 26 double kd;
jrhodes5150 0:8a420ac6394e 27 double voltageCal;
jrhodes5150 0:8a420ac6394e 28 double currentCal;
jrhodes5150 0:8a420ac6394e 29 double vLim;
jrhodes5150 0:8a420ac6394e 30 double iLim;
jrhodes5150 0:8a420ac6394e 31 double hvLim;
jrhodes5150 0:8a420ac6394e 32 // Activation Parameters
jrhodes5150 0:8a420ac6394e 33 double pwmFrequency;
jrhodes5150 0:8a420ac6394e 34 uint8_t msOpenLoopDuration;
jrhodes5150 0:8a420ac6394e 35 int TotalDurationSeconds;
jrhodes5150 0:8a420ac6394e 36 double msRampDuration;
jrhodes5150 0:8a420ac6394e 37 double rampStartPower;
jrhodes5150 0:8a420ac6394e 38 double rampEndPower;
jrhodes5150 0:8a420ac6394e 39 double startVoltage;
jrhodes5150 0:8a420ac6394e 40 uint8_t msSamplePeriod;
jrhodes5150 0:8a420ac6394e 41 uint8_t doneBit;
jrhodes5150 0:8a420ac6394e 42 double pwrCalLow;
jrhodes5150 0:8a420ac6394e 43 double pwrCalHigh;
jrhodes5150 0:8a420ac6394e 44 double vCalLow;
jrhodes5150 0:8a420ac6394e 45 double vCalHigh;
jrhodes5150 0:8a420ac6394e 46 bool PID_GOOD;
jrhodes5150 0:8a420ac6394e 47 double voltageSensed;
jrhodes5150 0:8a420ac6394e 48 double currentSensed;
jrhodes5150 0:8a420ac6394e 49 double sensedResistance;
jrhodes5150 0:8a420ac6394e 50 double sensedPower;
jrhodes5150 0:8a420ac6394e 51 };
jrhodes5150 0:8a420ac6394e 52
jrhodes5150 0:8a420ac6394e 53 struct AcquisitionData
jrhodes5150 0:8a420ac6394e 54 {
jrhodes5150 0:8a420ac6394e 55 float timestampMilliseconds;
jrhodes5150 0:8a420ac6394e 56 float targetVoltage;
jrhodes5150 0:8a420ac6394e 57 float vSense;
jrhodes5150 0:8a420ac6394e 58 float iSense;
jrhodes5150 0:8a420ac6394e 59 float vRMS;
jrhodes5150 0:8a420ac6394e 60 float iRMS;
jrhodes5150 0:8a420ac6394e 61 float power;
jrhodes5150 0:8a420ac6394e 62 float resistence;
jrhodes5150 0:8a420ac6394e 63 };
jrhodes5150 0:8a420ac6394e 64
jrhodes5150 0:8a420ac6394e 65
jrhodes5150 0:8a420ac6394e 66
jrhodes5150 0:8a420ac6394e 67 class DeviceProperties
jrhodes5150 0:8a420ac6394e 68 {
jrhodes5150 0:8a420ac6394e 69 public:
jrhodes5150 0:8a420ac6394e 70 DeviceProperties(void);
jrhodes5150 0:8a420ac6394e 71 void AddAcquisitionSample( AcquisitionData &data);
jrhodes5150 0:8a420ac6394e 72 void ClearAcquisitionData(void);
jrhodes5150 0:8a420ac6394e 73 int GetAcquisitionNumber(void);
jrhodes5150 0:8a420ac6394e 74 int GetAcquisitionSampleCount(void);
jrhodes5150 0:8a420ac6394e 75
jrhodes5150 0:8a420ac6394e 76 AcquisitionData GetAcquisitionSample(int acquisition, int sample);
jrhodes5150 0:8a420ac6394e 77
jrhodes5150 0:8a420ac6394e 78 void SetActualPWMFrequency(double frequency);
jrhodes5150 0:8a420ac6394e 79 double GetActualPWMFrequency(void) const;
jrhodes5150 0:8a420ac6394e 80
jrhodes5150 0:8a420ac6394e 81 public:
jrhodes5150 0:8a420ac6394e 82 DeviceConfig deviceConfig;
jrhodes5150 0:8a420ac6394e 83
jrhodes5150 0:8a420ac6394e 84 private:
jrhodes5150 0:8a420ac6394e 85 int acquisitionSampleCount;
jrhodes5150 0:8a420ac6394e 86 int acquisitionNumber;
jrhodes5150 0:8a420ac6394e 87 AcquisitionData acquisitionData[MAX_ACQUISITION_SAMPLES];
jrhodes5150 0:8a420ac6394e 88 mutable rtos::Mutex mutex;
jrhodes5150 0:8a420ac6394e 89 double actualPwmFrequency;
jrhodes5150 0:8a420ac6394e 90
jrhodes5150 0:8a420ac6394e 91 };
jrhodes5150 0:8a420ac6394e 92
jrhodes5150 0:8a420ac6394e 93 extern DeviceProperties Device;
jrhodes5150 0:8a420ac6394e 94
jrhodes5150 0:8a420ac6394e 95 #endif
jrhodes5150 0:8a420ac6394e 96
jrhodes5150 0:8a420ac6394e 97