first commit
Dependencies: PM2_Libary
Diff: main.cpp
- Revision:
- 7:c0f5bb355f41
- Parent:
- 6:e1fa1a2d7483
- Child:
- 8:9bb806a7f585
diff -r e1fa1a2d7483 -r c0f5bb355f41 main.cpp --- a/main.cpp Tue Apr 06 08:00:43 2021 +0200 +++ b/main.cpp Tue Apr 06 09:13:25 2021 +0200 @@ -1,6 +1,5 @@ #include "mbed.h" #include "platform/mbed_thread.h" -#include "string" /* PM2_Libary */ #include "EncoderCounter.h" @@ -18,7 +17,7 @@ bool executeMainTask = false; Timer user_button_timer, loop_timer; -int Ts_ms = 2; +int Ts_ms = 50; /* declaration of custom button functions */ void button_fall(); @@ -58,6 +57,7 @@ int main() { bufferedSerial.set_baud(115200); + // bufferedSerial.set_blocking(false); user_button.fall(&button_fall); user_button.rise(&button_rise); @@ -112,8 +112,8 @@ /* read analog input */ dist = analogIn.read() * 3.3f; - speedController_m0.setDesiredSpeedRPS( 1.0f); - speedController_m1.setDesiredSpeedRPS(-2.0f); + speedController_m0.setDesiredSpeedRPS( 0.5f); + speedController_m1.setDesiredSpeedRPS( 0.5f); pwmOut_m2.write(0.75f); servo_0.SetPosition(servo_desval_0); @@ -129,16 +129,16 @@ /* write output via serial buffer */ int act_buffer_length = snprintf (buffer, 100, "%3.6e, %3.6e; \r\n", - speedController_m0.getSpeedRPM(), - speedController_m1.getSpeedRPM()); - bufferedSerial.write(buffer, act_buffer_length); + speedController_m0.getSpeedRPS(), + speedController_m1.getSpeedRPS()); + // bufferedSerial.write(buffer, act_buffer_length); } else { dist = 0.0f; - speedController_m0.setDesiredSpeedRPS(0.0f); - speedController_m1.setDesiredSpeedRPS(0.0f); + speedController_m0.setDesiredSpeedRPS(0.2f); + speedController_m1.setDesiredSpeedRPS(0.2f); pwmOut_m2.write(0.5f); servo_desval_0 = 0;