My modifications/additions to the code
Dependencies: ADXL345 ADXL345_I2C IMUfilter ITG3200 Servo fishgait mbed-rtos mbed pixy_cam
Fork of robotic_fish_ver_4_8 by
Revision 14:a5389e26a63b, committed 2014-02-04
- Comitter:
- rkk
- Date:
- Tue Feb 04 14:23:56 2014 +0000
- Parent:
- 13:5ed8fd870723
- Child:
- 15:dc5753a5b83e
- Commit message:
- bang bang controller
Changed in this revision
| MainController.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/MainController.cpp Mon Feb 03 21:04:35 2014 +0000
+++ b/MainController.cpp Tue Feb 04 14:23:56 2014 +0000
@@ -28,29 +28,29 @@
timer1.reset();
curTime = 0.0;
switched = false;
- goofftime = (1/(2*frq)*vol);
- amplitude = 1.0;
+ goofftime = (vol/(2*frq));
+ amplitude = vol;
}
//vol * sqrt(frq)/frqmxsqrt;
- if (curTime > 1/(2*frq))
- {
- switched = true;
- amplitude = -1.0;
- }
-
- if(!switched)
- {
- if(curTime > goofftime )
- amplitude = 0.0;
- }
- else
- {
- if(curTime > (1/(2*frq)+goofftime))
- amplitude = 0.0;
- }
+// if (curTime > 1/(2*frq) && (switched == false))
+// {
+// switched = true;
+// amplitude = -1.0;
+// }
+//
+// if(!switched)
+// {
+// if(curTime > goofftime )
+// amplitude = 0.0;
+// }
+// else
+// {
+// if(curTime > (1/(2*frq)+goofftime))
+// amplitude = 0.0;
+// }
dutyCycle = amplitude * signum(sin( 2.0 * MATH_PI * frq * curTime ));
@@ -121,9 +121,9 @@
float MainController::signum(float input)
{
if (input>0.0)
- return 1;
+ return 1.0;
else if (input<0.0)
- return -1;
+ return (-1.0);
else
- return 0;
+ return 0.0;
}
\ No newline at end of file
