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: mbed MMA8452Q MS5837 SDFileSystem SCI_SENSOR
Diff: main.cpp
- Revision:
- 40:8a37ea9d006d
- Parent:
- 39:f2f0308ebecd
- Child:
- 41:9c7e35212c68
--- a/main.cpp Thu Dec 09 13:14:05 2021 +0000 +++ b/main.cpp Fri Dec 10 20:28:29 2021 +0000 @@ -41,7 +41,7 @@ int yo_num=0; //global yo_num default 0 float thrust_on_time=0; //global thrust_on time default 0 float accelData[3]; //global accel data -float vessel_length=1; +//float vessel_length=0.75; //vessel length 0.75 meters //functions void welcome(); @@ -51,8 +51,8 @@ void accel_update(); //update accelerometer related variables. we use imu_ticker to call this function //Control Parameters -float tim = 1; //define thruster on time -float percent = 1.5; //user defined percent of thrust power +float tim = 5; //define thruster on time +float percent = 1.7; //user defined percent of thrust power //Control related functions void thrust_on(float pw, float on_time); //input is pulse width @@ -93,7 +93,7 @@ //setup ticker to separate log and IMU data update. //so we could have all our control code in the while loop // //log at 2 Hz - accel_ticker.attach(&accel_update,0.1); //10Hz + accel_ticker.attach(&accel_update,1); // log_ticker.attach(&log_data,0.5); led2=0; led1=0; @@ -118,10 +118,10 @@ float pw=percent; float on_time=5; - if (current_depth-vessel_length<2) { + if (current_depth-vessel_lenght<2) { thrust_on(pw,on_time); } - if (timer2.read()>10) { //60 because counting in seconds? + if (timer2.read()>60) { //60 because counting in seconds? return 0; } } @@ -188,7 +188,7 @@ ///-----------log functions---------------------/// void log_data() { - + p_sensor.Barometer_MS5837(); //Code from Licht @@ -202,10 +202,13 @@ //Sample code indicates how to read accelerometer data: BLE.printf("Acceleration: %f %f %f\r\n",accelData[0],accelData[1],accelData[2]); //end of code from Licht + float ttime =t.read(); + float depth =p_sensor.depth(); + float pressure =p_sensor.MS5837_Pressure(); + fp = fopen(fname, "a"); - fprintf(fp, "$DATA"); - // Time:%f, Pressure:%f, Depth:%f, Acceleration:%f, %f, %f, Temp:%f, Light:%f, Percent:%f\r\n", t.read(),p_sensor.MS5837_Pressure(),p_sensor.depth(),accelData[0],accelData[1],accelData[2],temp.temp(),light.light(),percent); + fprintf(fp, "$DATA %f,%f,%f,%f,%f,%f \r\n", ttime,depth,pressure,accelData[0],accelData[1],accelData[2]); fclose(fp); }