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
Revision 42:4cad666e57f4, committed 2021-12-13
- Comitter:
- elizabethtaylor
- Date:
- Mon Dec 13 19:40:03 2021 +0000
- Parent:
- 41:9c7e35212c68
- Commit message:
- Made rubric items global variables
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Dec 10 21:58:49 2021 +0000
+++ b/main.cpp Mon Dec 13 19:40:03 2021 +0000
@@ -43,6 +43,12 @@
float accelData[3]; //global accel data
//float vessel_length=0.75; //vessel length 0.75 meters
+float part1_iterations=3;
+float part2_target_depth=2;
+float part2_timeout=60;
+float part3_target_depth=2;
+
+
//functions
void welcome();
void log_data();
@@ -100,7 +106,7 @@
//Part One
int count=0;
- while(count<3) {
+ while(count<part1_iterations) {
led1=1;
count=count+1;
float pw=percent;
@@ -112,14 +118,14 @@
//Part Two
timer2.start();
- while(timer2.read()<60) {
+ while(timer2.read()<part2_timeout) {
led1=0;
led2=1;
float current_depth=p_sensor.depth();
float pw=percent;
float on_time=2;
- if (current_depth<1.8) {
+ if (current_depth<part2_target_depth-.2) {
thrust_on(pw,on_time);
}
}
@@ -130,9 +136,8 @@
while(timer2.read()<60) {
led2=0;
led3=1;
- float error_deep = 2.3; //deep end of error band 2.5m ?
- float error_shallow = 1.7; //shallow end of error band 1.5m?
- float target_depth=2;
+ float error_deep = part3_target_depth +.3; //deep end of error band 2.3m ?
+ float error_shallow = part3_target_depth -.3; //shallow end of error band 1.7m?
float current_depth = p_sensor.depth();
float on_time=2;
@@ -141,11 +146,11 @@
float pw = 1.5;
thrust_on(pw,on_time);
} // turn on thruster at set pw and ontime
- else if ((current_depth>=error_shallow)&&(current_depth<=target_depth)) {//if float is between 1.6 & 2 meters deep
+ else if ((current_depth>=error_shallow)&&(current_depth<=part3_target_depth)) {//if float is between 1.6 & 2 meters deep
float pw = 1.2;
thrust_on(pw,on_time);
}
- else if ((current_depth>=target_depth)&&(current_depth<=error_deep)) {//if float is inbetween 2 & 2.4 meters deep
+ else if ((current_depth>=part3_target_depth)&&(current_depth<=error_deep)) {//if float is inbetween 2 & 2.4 meters deep
float pw = 1.0;
thrust_on(pw,on_time);
}
@@ -221,7 +226,7 @@
fp = fopen(fname, "a");
- fprintf(fp, "$DATA %f,%f,%f,%f,%f,%f,%f \r\n", ttime,depth,pressure,accelData[0],accelData[1],accelData[2],light.light());
+ fprintf(fp, "$DATA, %f,%f,%f,%f,%f,%f,%f \r\n", ttime,depth,pressure,accelData[0],accelData[1],accelData[2],light.light());
fclose(fp);
}
