the fish that looks like a jet
Dependencies: ADXL345 ADXL345_I2C IMUfilter ITG3200 mbed Servo
Diff: motor_controller.cpp
- Revision:
- 6:a4d6f3e4bf28
- Parent:
- 5:090ef6275773
- Child:
- 7:e005cfaff8d1
--- a/motor_controller.cpp Tue Jan 28 23:59:21 2014 +0000 +++ b/motor_controller.cpp Wed Jan 29 05:04:50 2014 +0000 @@ -47,8 +47,11 @@ return; } -void PololuMController::drive_sinusoidal(float cur_time, float a, float w, float phi) +void PololuMController::drive_sinusoidal(float currentTime, float dutyCycle, float frequency) { - setpolarspeed(a*sin(w*cur_time+phi)); + //convert frequency form 0.0 to 1.0 + float f = (FREQ_MAX - FREQ_MIN) * f + FREQ_MIN; + + setpolarspeed(dutyCycle*sin( 2.0* MATH_PI* f * currentTime)); return; }