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.
Diff: main.cpp
- Revision:
- 1:333d2cdd26d0
- Parent:
- 0:faa58403944a
- Child:
- 2:f23351f7af0b
diff -r faa58403944a -r 333d2cdd26d0 main.cpp
--- a/main.cpp Sun Feb 17 02:58:08 2019 +0000
+++ b/main.cpp Sat Nov 14 02:43:13 2020 +0000
@@ -15,7 +15,7 @@
int main(){
- // pc.baud(128000);
+ pc.baud(128000);
/* RtosTimer RtosTimerTS1(timerTS1);
RtosTimerTS1.start((unsigned int)(TS1*5000));//2000
Thread::wait(100);//1000*/
@@ -45,17 +45,17 @@
Vr_adc=V_adc.read();
y=Vr_adc- Vr_adc_i;
ay=fabs(y);
- power=ay;
- if(y>0.1){
+ power=ay*2.0;
+ if(y>0.05){
frd=0;
//aout=0.5;
}
- if(y<-0.1){
+ if(y<-0.05){
frd=1;
//aout=0.9;
}
- if(ay<0.1){
+ if(ay<0.05){
q=0;
aout=0.0;
//SH=HALL_U<<2|HALL_V<<1|HALL_W;
@@ -116,22 +116,22 @@
}
}
- if(Speed<1000){//2000
+ if(Speed<500){//2000
/**************矩形波駆動始動***************/
/*******Forward******************/
if(frd==0){
switch(SH){
- case 5: PWM_W();//W
+ case 5: PWM_W();//W5
break;
- case 4: EN_W();//W
+ case 4: EN_W();//W4
break;
- case 6: PWM_U();//U
+ case 6: PWM_U();//U6
break;
- case 2: EN_U();//U
+ case 2: EN_U();//U2
break;
- case 3: PWM_V();//V
+ case 3: PWM_V();//V3
break;
- case 1: EN_V();//V
+ case 1: EN_V();//V1
break;
default :PWM_W();//W
break;
@@ -171,7 +171,7 @@
}//Speed<2000
- if((Speed>=1000)){//&&(Speed<4000)){//2000
+ if((Speed>=500)){//&&(Speed<4000)){//2000
/************sin drive Forward************/
if(frd==1){
HALL_Ui.rise(&PWM_sinU);
@@ -214,11 +214,24 @@
if(wz[2]>=16383){
wz[2]=16383;
}
+ #if 1
PWM_IN1_U.write(((float(uz[2])/(16383*2))*(power*STOP))+0.5);
PWM_IN2_V.write(((float(vz[2])/(16383*2))*(power*STOP))+0.5);
PWM_IN3_W.write(((float(wz[2])/(16383*2))*(power*STOP))+0.5);
- aout=(float(uz[2])/(16383*2))*(power*STOP)+0.5;//16383
+ aout=(float(wz[2])/(16383*2))*(power*STOP)+0.5;//16383
+ #endif
+ #if 0
+ su=(((float(uz[2])/(16383*2))*(power*STOP))+0.5);
+ sv=(((float(vz[2])/(16383*2))*(power*STOP))+0.5);
+ sw=(((float(wz[2])/(16383*2))*(power*STOP))+0.5);
+
+ PWM_IN1_U.write(su);
+ PWM_IN2_V.write(sv);
+ PWM_IN3_W.write(sw);
+ aout=su;
+ //aout=(float(wz[2])/(16383*2))*(power*STOP)+0.5;//16383
+ #endif
//filterCurrent();
//aout=Curr_wf;
//HALL_Ui.rise(&cosU);
@@ -298,9 +311,12 @@
vsi=2*(vt2-vt1);
wsi=2*(wt2-wt1);
usic=2*(ut2c-ut1c);
- Speed=60*(1/(6.0*fabs(usi)*1E-6));//CQ 6
+ //Speed=60*(1/(7.0*(usi*0.5)*1E-6));//BullRun
/************************************************************/
-
+ Speed=60*(1/(7.0*usi*1E-6));
+ //pc.printf("%.3f , %.3f \r" ,Speed ,Vr_adc);
+ // UP=HALL_Ui;VP=HALL_Vi;WP=HALL_Wi;
+ // pc.printf("%d , %d , %d \r" , UP,VP,WP);
}
}
\ No newline at end of file