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: ADXL345_I2C QEI SDFileSystem mbed
Diff: main.cpp
- Revision:
- 6:f725ca58583f
- Parent:
- 5:473edb6558fa
diff -r 473edb6558fa -r f725ca58583f main.cpp
--- a/main.cpp Thu Feb 09 07:10:47 2017 +0000
+++ b/main.cpp Thu Feb 09 08:59:18 2017 +0000
@@ -46,7 +46,7 @@
int main()
{
- char buffer[100][150];
+ char buffer[150][150];
int i,j;
double C;
float duty_output;
@@ -72,7 +72,7 @@
//---ammeter setting end---
- duty_output = 0.6;
+ duty_output = 0.0;
duty.period(0.00005);
// NVIC_SetPriority(0, 1);
@@ -94,24 +94,21 @@
while (1) {
accelerometer.getOutput(readings);
- if( abs((int16_t)readings[0]) > 10) {
+ if( abs((int16_t)readings[0]) > 20) {
myled3 = 1;
break;
}
- wait(0.01);
+ wait(0.001);
}
save.attach(&savedata, 0.01 );
t.start();
- while(t.read() <= 0.51) {
-// debug.printf("loop sensorB\n");
+ while(t.read() <= 0.50) {
if(flag) {
flag = 0;
controller( &v, &duty_output, &acce_device, &acce_output, &F_output);
-// duty.write(duty_output);
read_current( &C);
-// debug.printf("duty = %f\n",duty_output);
if(1) {
sprintf(buffer[i],"%f10,%f10,%f10,%f10,%f10,%f10",t.read(),C,acce_device,C,duty_output,F_output);
if( i > 299) {
@@ -258,6 +255,7 @@
while(!sensorD);
duty = 0.0f;
wait(2.0);
+ myled4 = 1;
}
void controller(double *v,float *duty_output,double *acce_device, double *acce_output, double *F)
@@ -283,17 +281,20 @@
if(abs(*v) > 0) {
F_1 = -1 * ( ka * *acce_device) + (kv * *v);
*F = 0.35 * F_1 + 0.4 * F_2 + 0.25 * F_3;
- *acce_output = *F / 8.5;
+ *acce_output = *F / 5.0;
*duty_output = *acce_output / 118 + *duty_output;
+
+ /*
+ if(intrrupt_checker <= intrrupt_cnt){
+ *duty_output = *duty_output + 0.2;
+ intrrupt_checker = intrrupt_cnt + 8;
+ }*/
if(*duty_output > 1.0) {
*duty_output = 1.0;
myled4 = 1;
}
- if(intrrupt_checker == intrrupt_cnt){
- *duty_output = *duty_output + 0.03;
- intrrupt_checker = intrrupt_checker + 2;
- }
+
duty.write(*duty_output);