CQ_KIT_Ver1_5
Dependencies: mbed RateLimiter BLDCmotorDriverCQ_KIT_Ver1_5
Diff: main.cpp
- Revision:
- 5:3290e8857120
- Parent:
- 4:3f63eed73ad1
- Child:
- 6:0eec4b6e94ba
diff -r 3f63eed73ad1 -r 3290e8857120 main.cpp --- a/main.cpp Fri Oct 14 13:45:35 2016 +0000 +++ b/main.cpp Mon Oct 17 11:11:52 2016 +0000 @@ -33,15 +33,29 @@ P_HALL1, P_HALL2, P_HALL3, // Hall sensors pins P_FAULT // Fault LED ); + +// Pin to check temperature on the X-NUCLEO-IHM07M1 board +AnalogIn temperature(PC_2); + +void checkTemperature() +{ + float t = temperature.read()* 100.0f; + + if (temperature.read() > 0.6f){ + printf("Overheating... Turning off now\n\r"); + M.setDutyCycle(0); + M.coast(); + } +} int main() { printf("Press 'w' to speed up, 's' to speed down\n\r"); // Duty cycle value to be used for speed control float dc = 0.0f; - - // sampleTime = 1e-3, switchingFrequency = 20e3, rampUpSlope = 1, rampDownSlope = -1 - //M.configure(1e-3, 50e3, 0.1f, -0.1f); + + Ticker ticker; + ticker.attach(checkTemperature, 1); // Periodic overheating check while(true) {