Mercurial > public > ostc4
comparison Small_CPU/Src/pressure.c @ 867:3311b720a072 Evo_2_23
Decrease calculation interval for ascend speed:
In the previous version the ascend speed was calculated every 2 seconds. To improve the visualization the interval has been reduced to 400ms. The average function of the depth calculation ensures a smooth dynamic transition of the values. For testing a simulation profile, which changes between several speeds, may be acivated using the compile switch.
author | Ideenmodellierer |
---|---|
date | Mon, 12 Aug 2024 14:30:22 +0200 |
parents | 08ea8e9d6cfe |
children | 06aaccaf2e02 |
comparison
equal
deleted
inserted
replaced
863:0c89c6fa949c | 867:3311b720a072 |
---|---|
529 return statusReturn; | 529 return statusReturn; |
530 } | 530 } |
531 | 531 |
532 | 532 |
533 #ifdef SIMULATE_PRESSURE | 533 #ifdef SIMULATE_PRESSURE |
534 | |
535 #define SECDIV 10 /* update every 100ms */ | |
536 | |
534 void pressure_simulation() | 537 void pressure_simulation() |
535 { | 538 { |
536 static uint32_t tickstart = 0; | 539 static uint32_t tickstart = 0; |
537 static float pressure_sim_mbar = 0; | 540 static float pressure_sim_mbar = 0; |
538 static uint32_t passedSecond = 0; | 541 static uint32_t passedSecond = 0; |
539 static uint32_t secondtick = 0; | 542 static uint32_t secondtick = 0; |
543 static uint32_t lastsecondtick = 0; | |
544 static float delta_mbar = 0.0; | |
540 | 545 |
541 uint32_t lasttick = 0; | 546 uint32_t lasttick = 0; |
542 | 547 |
543 | 548 |
544 | 549 |
548 secondtick = tickstart; | 553 secondtick = tickstart; |
549 pressure_sim_mbar = 1000; | 554 pressure_sim_mbar = 1000; |
550 } | 555 } |
551 | 556 |
552 lasttick = HAL_GetTick(); | 557 lasttick = HAL_GetTick(); |
553 if(time_elapsed_ms(secondtick,lasttick) > 1000) /* one second passed since last tick */ | 558 if(time_elapsed_ms(secondtick,lasttick) >= (1000 / SECDIV)) /* one second passed since last tick */ |
554 { | 559 { |
560 if(time_elapsed_ms(lastsecondtick,lasttick) > 1000) | |
561 { | |
562 passedSecond++; | |
563 lastsecondtick = lasttick; | |
564 } | |
555 secondtick = lasttick; | 565 secondtick = lasttick; |
556 passedSecond++; | 566 |
557 | 567 #define DIVE_AT_SPEED 1 |
558 #ifdef DIVE_AFTER_LANDING | 568 #ifdef DIVE_AFTER_LANDING |
559 if(passedSecond < 10) pressure_sim_mbar = 1000.0; /* stay stable for 10 seconds */ | 569 if(passedSecond < 10) pressure_sim_mbar = 1000.0; /* stay stable for 10 seconds */ |
560 else if(passedSecond < 300) pressure_sim_mbar -= 1.0; /* decrease pressure in 5 minutes target 770mbar => delta 330 */ | 570 else if(passedSecond < 300) pressure_sim_mbar -= 1.0; /* decrease pressure in 5 minutes target 770mbar => delta 330 */ |
561 else if(passedSecond < 900) pressure_sim_mbar += 0.0; /*stay stable 10 minutes*/ | 571 else if(passedSecond < 900) pressure_sim_mbar += 0.0; /*stay stable 10 minutes*/ |
562 else if(passedSecond < 1500) pressure_sim_mbar += 0.5; /* return to 1 bar in 10 Minutes*/ | 572 else if(passedSecond < 1500) pressure_sim_mbar += 0.5; /* return to 1 bar in 10 Minutes*/ |
563 else if(passedSecond < 1800) pressure_sim_mbar += 0.0; /* 5 minutes break */ | 573 else if(passedSecond < 1800) pressure_sim_mbar += 0.0; /* 5 minutes break */ |
564 else if(passedSecond < 2000) pressure_sim_mbar += 10.0; /* start dive */ | 574 else if(passedSecond < 2000) pressure_sim_mbar += 10.0; /* start dive */ |
565 else if(passedSecond < 2300) pressure_sim_mbar += 0.0; /* stay on depth */ | 575 else if(passedSecond < 2300) pressure_sim_mbar += 0.0; /* stay on depth */ |
566 else if(passedSecond < 2500) pressure_sim_mbar -= 10.0; /* return to surface */ | 576 else if(passedSecond < 2500) pressure_sim_mbar -= 10.0; /* return to surface */ |
567 else pressure_sim_mbar = 1000.0; /* final state */ | 577 else pressure_sim_mbar = 1000.0; /* final state */ |
578 #endif | |
579 #ifdef DIVE_AT_SPEED | |
580 if(passedSecond < 10) pressure_sim_mbar = 1000.0; /* stay stable for 10 seconds */ | |
581 else if(passedSecond < 20) delta_mbar = 200.0 / SECDIV; /* Start dive */ | |
582 else if(passedSecond < 30) delta_mbar = 0.0; /*stay on depth*/ | |
583 else if(passedSecond < 45) delta_mbar -= 0.2 / SECDIV; /* return to surface */ | |
584 else if(passedSecond < 40) delta_mbar -= 0.4 / SECDIV; /* stay */ | |
585 else if(passedSecond < 50) delta_mbar += 0.3 / SECDIV; /* get ready for second dive */ | |
586 else if(passedSecond < 60) delta_mbar -= 0.4; /*stay on depth*/ | |
587 else if(passedSecond < 70) delta_mbar = 0.2; | |
588 else if(passedSecond < 1060) pressure_sim_mbar -= 10.0/ SECDIV; /* return to surface */ | |
589 else if(passedSecond < 1200) pressure_sim_mbar += 0.0; /* stay */ | |
590 else { pressure_sim_mbar = 1000.0; delta_mbar = 0.0;} /* final state */ | |
591 | |
592 pressure_sim_mbar += delta_mbar; | |
593 if(pressure_sim_mbar < surface_pressure_mbar) | |
594 { | |
595 pressure_sim_mbar = surface_pressure_mbar; | |
596 } | |
597 | |
568 #else /* short dive */ | 598 #else /* short dive */ |
569 if(passedSecond < 10) pressure_sim_mbar = 1000.0; /* stay stable for 10 seconds */ | 599 if(passedSecond < 10) pressure_sim_mbar = 1000.0; /* stay stable for 10 seconds */ |
570 else if(passedSecond < 180) pressure_sim_mbar += 10.0; /* Start dive */ | 600 else if(passedSecond < 180) pressure_sim_mbar += 10.0; /* Start dive */ |
571 else if(passedSecond < 300) pressure_sim_mbar += 0.0; /*stay on depth*/ | 601 else if(passedSecond < 300) pressure_sim_mbar += 0.0; /*stay on depth*/ |
572 else if(passedSecond < 460) pressure_sim_mbar -= 10.0; /* return to surface */ | 602 else if(passedSecond < 460) pressure_sim_mbar -= 10.0; /* return to surface */ |