![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
the fish that looks like a jet
Dependencies: ADXL345 ADXL345_I2C IMUfilter ITG3200 mbed Servo
main.cpp
- Committer:
- rkk
- Date:
- 2014-01-31
- Revision:
- 10:d9f1037f0cb0
- Parent:
- 9:8dd7a76756e2
- Child:
- 11:8ec915eb70f6
File content as of revision 10:d9f1037f0cb0:
#include "mbed.h" #include "motor_controller.h" #include "guardian.h" //#include "IMU.h" #include "Servo.h" //#include "rtos.h" //#include "PwmReader.h" #include "PwmIn.h" #define VOLUME_MAX 0.4 #define VOLUME_MIN 0.2 #define FREQUENCY_MAX 0.4 #define FREQUENCY_MIN 0.2 #define RUDDER_MAX 0.4 #define RUDDER_MIN 0.2 #define SIZE_ARRAY 500 bool quit=false; //InterruptIn event(p16); PololuMController mcon(p22, p6, p5); //Servo servo(p21); //Guardian ap(p21, p23, p24, p25, p26, p26); //Serial xbee(p13, p14); Serial pc(USBTX, USBRX); PwmIn ch3(p16,0.054,0.092); PwmIn ch6(p15,0.055,0.092); Timer t; float throttle, frequency, rudder; int main() { //ap.calibrate(); //ap.set2D(); //ap.setoff(); t.start(); while(t.read() < 500) { float vol_norm=ch6.dutycyclescaledup(); float freq_norm=ch3.dutycyclescaledup(); //mcon.drive_rectangular(t.read(), vol_norm*freq_norm, 3*freq_norm); //mcon.drive_sinusoidal(t.read(), vol_norm*freq_norm, 3*freq_norm); float dutycycle = mcon.drive_sinusoidal(t.read(), vol_norm*freq_norm, freq_norm); pc.printf("ch 3: %f, ch 6: %f, dc: %f, asin: %f\n", vol_norm, freq_norm, dutycycle, asin(sin(t.read())) ); //pc.printf("time: %f\n\r", t.read()); //pc.printf("throttle: %f frequency: %f rudder: %f\n\r",throttle,frequency,rudder); wait_ms(20); } t.stop(); }