![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
the fish that looks like a jet
Dependencies: ADXL345 ADXL345_I2C IMUfilter ITG3200 mbed Servo
Diff: main.cpp
- Revision:
- 8:0574a5db1fc4
- Parent:
- 7:e005cfaff8d1
- Child:
- 9:8dd7a76756e2
--- a/main.cpp Thu Jan 30 02:04:23 2014 +0000 +++ b/main.cpp Fri Jan 31 04:33:44 2014 +0000 @@ -4,25 +4,27 @@ //#include "IMU.h" #include "Servo.h" //#include "rtos.h" -#include "PwmReader.h" +//#include "PwmReader.h" +#include "PwmIn.h" -#define THROTTLE_MAX 0.4 -#define THROTTLE_MIN 0.2 +#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); +//InterruptIn event(p16); PololuMController mcon(p22, p6, p5); -Servo servo(p21); -Guardian ap(p21, p23, p24, p25, p26, p26); -Serial xbee(p13, p14); +//Servo servo(p21); +//Guardian ap(p21, p23, p24, p25, p26, p26); +//Serial xbee(p13, p14); Serial pc(USBTX, USBRX); -PwmReader ch3(p16, 0.054, 0.094); -PwmReader ch6(p15, 0.054, 0.094); +PwmIn ch3(p16,0.054,0.092); +PwmIn ch6(p15,0.055,0.092); Timer t; float throttle, frequency, rudder; @@ -30,19 +32,23 @@ { //ap.calibrate(); //ap.set2D(); - ap.setoff(); + //ap.setoff(); t.start(); - while(1) { + + while(t.read() < 500) { - float vol_norm=ch3.getDuty(); - float freq_norm=ch6.getDuty(); + float vol_norm=ch6.dutycyclescaledup(); + float freq_norm=ch3.dutycyclescaledup(); + pc.printf("channel 3: %f, channel 6: %f\n", vol_norm, freq_norm); + //mcon.drive_rectangular(t.read(), vol_norm*freq_norm, 3*freq_norm); + //mcon.drive_sinusoidal(t.read(), vol_norm*freq_norm, 3*freq_norm); mcon.drive_sinusoidal(t.read(), vol_norm*freq_norm, 3*freq_norm); //pc.printf("time: %f\n\r", t.read()); //pc.printf("throttle: %f frequency: %f rudder: %f\n\r",throttle,frequency,rudder); - //wait_ms(10); + wait_ms(1); } t.stop(); }