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.
Fork of priustroller_2 by
inverter.cpp
00001 #include "includes.h" 00002 #include "core.h" 00003 #include "sensors.h" 00004 00005 Inverter::Inverter(PinName ph_a, PinName ph_b, PinName ph_c, PinName en, VoltageSensor *sense_bus, TempSensor *sense_t) { 00006 _en = new DigitalOut(en); 00007 Disable(); 00008 00009 _pwm_a = new PwmOut(ph_a); 00010 _pwm_b = new PwmOut(ph_b); 00011 _pwm_c = new PwmOut(ph_c); 00012 _pwm_a->period_us(100); 00013 _pwm_b->period_us(100); 00014 _pwm_c->period_us(100); 00015 00016 _sense_bus = sense_bus; 00017 _sense_t = sense_t; 00018 00019 SetDtcA(0); 00020 SetDtcB(0); 00021 SetDtcC(0); 00022 00023 TIM2->CR1 &= ~(TIM_CR1_CEN); 00024 TIM2->CR1 |= TIM_CR1_CMS; 00025 TIM2->CR1 |= TIM_CR1_CEN; 00026 00027 Enable(); 00028 } 00029 00030 void Inverter::SetDtcA(float dtc) { 00031 if (dtc < 0) dtc = 0.0f; 00032 if (dtc > 1.0f) dtc = 1.0f; 00033 *_pwm_a = dtc; 00034 } 00035 00036 void Inverter::SetDtcB(float dtc) { 00037 if (dtc < 0) dtc = 0.0f; 00038 if (dtc > 1.0f) dtc = 1.0f; 00039 *_pwm_b = dtc; 00040 } 00041 00042 void Inverter::SetDtcC(float dtc) { 00043 if (dtc < 0) dtc = 0.0f; 00044 if (dtc > 1.0f) dtc = 1.0f; 00045 *_pwm_c = dtc; 00046 } 00047 00048 void Inverter::Enable() { 00049 *_en = 1; 00050 } 00051 00052 void Inverter::Disable() { 00053 *_en = 0; 00054 } 00055 00056 float Inverter::GetVbus() { 00057 return _sense_bus->GetVoltage(); 00058 } 00059 00060 float Inverter::GetTemp() { 00061 return _sense_t->GetTemp(); 00062 }
Generated on Tue Jul 12 2022 18:31:15 by
1.7.2
