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.
isr.cpp
00001 #include "isr.h" 00002 #include "mbed.h" 00003 #include "shared.h" 00004 #include "constants.h" 00005 00006 /* 00007 void commutate() { 00008 if(BROCK_COMMUTATE){ 00009 motor->hall = (halla.read() << 2) + (hallb.read() << 1) + hallc.read(); 00010 if (motor->hall != HNext[motor->last_hall] && motor->last_hall != 0) { 00011 motor->reverses++; 00012 if (motor->reverses < 2) return; 00013 } 00014 motor->reverses = 0; 00015 motor->last_hall = motor->hall; 00016 motor->last_time = motor->ticks; 00017 motor->major_pos = 60.0f * ATable[motor->hall]; 00018 motor->ticks = 0.0f; 00019 } 00020 else{ 00021 00022 } 00023 } 00024 */ 00025 00026 00027 00028 void dtc_update() { 00029 00030 float angle = motor->whangle; 00031 00032 00033 float ia = angle - motor->sensor_phase; 00034 if (ia < 0) ia += 360.0f; 00035 if (ia >= 360.0f) ia -= 360.0f; 00036 float ib = ia - 120.0f; 00037 if (ib < 0) ib += 360.0f; 00038 float ic = ia + 120.0f; 00039 if (ic >= 360.0f) ic -= 360.0f; 00040 00041 motor->dtc_a = sinetab[(int) (ia)] * motor->throttle; 00042 motor->dtc_b = sinetab[(int) (ib)] * motor->throttle; 00043 motor->dtc_c = sinetab[(int) (ic)] * motor->throttle; 00044 00045 if (motor->halt) { 00046 pha = 0.0f; 00047 phb = 1.0f; 00048 phc = 0.0f; 00049 } else { 00050 pha = DB_COEFF * motor->dtc_a + DB_OFFSET; 00051 phb = DB_COEFF * (1.0f - motor->dtc_b) + DB_OFFSET; 00052 phc = DB_COEFF * motor->dtc_c + DB_OFFSET; 00053 } 00054 }
Generated on Tue Jul 12 2022 18:49:22 by
1.7.2