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.
Dependencies: mbed SpeedController
Revision 3:e7807f60c9bf, committed 2019-11-09
- Comitter:
- aoikoizumi
- Date:
- Sat Nov 09 03:35:33 2019 +0000
- Parent:
- 2:c4e456559941
- Commit message:
- 2019 11 9 ;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Nov 08 06:36:17 2019 +0000
+++ b/main.cpp Sat Nov 09 03:35:33 2019 +0000
@@ -3,7 +3,7 @@
#include "EC.h" //Encoderライブラリをインクルード
#include "SpeedController.h" //SpeedControlライブラリをインクルード
#define RESOLUTION 512 //分解能
-//#define BASIC_SPEED 1 //動確用
+#define BASIC_SPEED 40 //動確用
//#define TEST_DUTY 0.3 //動確用
@@ -21,30 +21,31 @@
int j=0;
double rotate_1=0,rotate_2=0;
-double motor1_omega[1000]={},motor2_omega[1000]={},time_when[1000];
-int motor1_count[1000]={},motor2_count[1000]={};
+double motor1_omega[1000]= {},motor2_omega[1000]= {},time_when[1000];
+int motor1_count[1000]= {},motor2_count[1000]= {};
void CalOmega()
{
motor1_count[j]=EC_1.getCount();
+ motor2_count[j]=EC_2.getCount();
+ EC_1.calOmega();
+ EC_2.calOmega();
motor1_omega[j]=EC_1.getOmega();
- motor2_count[j]=EC_2.getCount();
motor2_omega[j]=EC_2.getOmega();
// time_when[j]=EC_1.timer_.read();
if(rotate_1==0) motor_1.stop();
else motor_1.Sc(rotate_1);
if(rotate_2==0) motor_2.stop();
else motor_2.Sc(rotate_2);
- EC_1.calOmega();
- EC_2.calOmega();
+
j++;
}
int main()
{
motor_1.period_us(50);
motor_2.period_us(50);
- motor_1.setEquation(0.322,0.08,0,0.0100); //求めたC,Dの値を設定
- motor_2.setEquation(0.0302,0.0755,-0.0241,0.1301); //求めたC,Dの値を設定
+ motor_1.setEquation(0.0322,0.08,0.0322,0.0800); //求めたC,Dの値を設定
+ motor_2.setEquation(0.0302,0.0755,0.0241,0.1301); //求めたC,Dの値を設定
motor_1.setPDparam(0,0.0); //PIDの係数を設定
motor_2.setPDparam(0,0.0); //PIDの係数を設定
motor_tick.attach(&CalOmega,0.05);
@@ -58,7 +59,19 @@
pc.printf("%f,%f ",motor1_omega[i],motor2_omega[i]);
pc.printf("%d,%d\r\n",motor1_count[i],motor2_count[i]);
}
- }
+ } else if(sel=='i') {
+ pc.printf("fffff\r\n");
+ rotate_1=1*BASIC_SPEED;
+ rotate_2=1*BASIC_SPEED;
+ } else if(sel=='m') {
+ pc.printf("bbbbb\r\n");
+ rotate_1=-1*BASIC_SPEED;
+ rotate_2=-1*BASIC_SPEED;
+ }else if(sel=='s') {
+ pc.printf("sssss\r\n");
+ rotate_1=0;
+ rotate_2=0;
+ }
}
}
}
\ No newline at end of file