Initial commit
Dependencies: FastPWM Lamp_Intensity_Lock_withTempCo mbed
Fork of Lamp_Intensity_Lock_withTempCo by
Diff: main.cpp
- Revision:
- 3:a8ec3c6aeb08
- Parent:
- 2:1b142e2aa23e
- Child:
- 4:eb26ac5c3bd5
--- a/main.cpp Fri Jan 13 14:41:31 2017 +0000 +++ b/main.cpp Fri Jan 13 22:30:02 2017 +0000 @@ -8,7 +8,8 @@ const uint8_t waitIntervals = 100; //number of 2.73 ms waits const int measPeriod_ms = 699; const float tempRef = 29.5; //C temperature at which all optical powers are calculated to -const float Ch0tempCo = 0.0025; // % per degree C +const float Ch0tempCo = 0.00228; // % per degree C +const float Ch1tempCo = 0.001765; //% per degree C const float warmUp = 15; //number of measurements with a higher than usual pGain (to get to target faster); I2C i2c(I2C_SDA,I2C_SCL); @@ -119,6 +120,13 @@ } +float tempCorrectTMDCh1(float counts, float tempC) +{ + float tDiff = tempC-tempRef; + float delta = Ch1tempCo*tDiff; //the % difference observed vs. reference temperature + return counts *(1-delta); //the count value equivalent if measured at reference temperature (less counts if temp is higher) + +} int main() { float ratio; @@ -191,6 +199,7 @@ } ch0Data = tempCorrectTMDCh0(ch0Data,temperature); ch1Data = LSB_MSB_2uint16(data+2); + ch1Data = tempCorrectTMDCh1(ch0Data,temperature); ratio = (float)ch0Data/(float)ch1Data; err = ch0Data - setpoint; pc.printf( "%U,%U, %f, %f, %f, %f\r\n",ch0Data,ch1Data,ratio,mypwm.read(),temperature, step);