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
Diff: Lab3.cpp
- Revision:
- 6:1d16cc833e0d
- Parent:
- 5:e33e69d4eecf
- Child:
- 7:241bde733699
--- a/Lab3.cpp Thu Feb 25 17:13:30 2016 +0000
+++ b/Lab3.cpp Fri Feb 26 21:55:31 2016 +0000
@@ -24,8 +24,8 @@
// GLOBAL VARIABLE DECLARATIONS
// ********************************************************************
- signed int R_setpoint=0; // Desired Angular Speed ( rad/sec )
- signed int L_setpoint=0;
+ signed int R_setpoint; // Desired Angular Speed ( rad/sec )
+ signed int L_setpoint;
float R_e; // Velocity Error
float R_u; // Control Signal
float L_e;
@@ -69,7 +69,7 @@
//Serial
Serial pc(USBTX, USBRX); // tx and rx for PC serial channel via USB cable
- Serial Bluetooth(p9,p10); // Pins tx(p9) , rx(p10) for bluetooth serial channel
+ Serial Bluetooth(p9,p10); // Pins tx(p9) , rx(p10) for bluetooth serial channel
//SPI
@@ -110,9 +110,9 @@
int ID = DE0.write(SpiControlWord); // SPI Control Word specifies SPI settings
if(ID == 23){ // DE0 ID 23 (0x0017)
- printf("\n\r >> DE0 Initialized.\n\r");}
+ Bluetooth.printf("\n\r >> DE0 Initialized.\n\r");}
else{
- printf("\n\r >> Failed to initialize DE0 board.\n\r");}
+ Bluetooth.printf("\n\r >> Failed to initialize DE0 board.\n\r");}
}
// ***************************************************
@@ -163,10 +163,10 @@
signed int input;
- printf("\n\r Please enter a desired angular speed for the left motor (rad/sec) >> ");
- scanf("%i",&input);
+ Bluetooth.printf("\n\r Please enter a desired angular speed for the left motor (rad/sec) >> ");
+ Bluetooth.scanf("%i",&input);
- printf("\n\r Your setpoint is >> %i\n\r",input);
+ Bluetooth.printf("\n\r Your setpoint is >> %i\n\r",input);
return input;
@@ -180,10 +180,10 @@
signed int input;
- printf("\n\r Please enter a desired angular speed for the right motor (rad/sec) >> ");
- scanf("%i",&input);
+ Bluetooth.printf("\n\r Please enter a desired angular speed for the right motor (rad/sec) >> ");
+ Bluetooth.scanf("%i",&input);
- printf("\n\r Your setpoint is >> %i\n\r",input);
+ Bluetooth.printf("\n\r Your setpoint is >> %i\n\r",input);
return input;
@@ -323,6 +323,8 @@
R_setpoint = InputRight();
// Display Global Variables to Console
+ Bluetooth.printf("\n\r ========= LEFT ======= ========= RIGHT =======");
+ Bluetooth.printf("\n\r US VE IS CS US VE IS CS ");
while(1){
@@ -332,17 +334,8 @@
float R_error_t = R_e;
float R_u_t = R_u;
- printf("\n\r LEFT");
- printf("\n\r US : %i",L_setpoint); // User defined setpoint
- printf("\n\r VE : %2.2f",L_error_t); // Displays signed Velocity Error
- printf("\n\r IS : %i",L_integrator); // Displays currently state of the left integrator
- printf("\n\r CS : %2.4f",L_u_t); // Displays control signal
- printf("\n\r RIGHT");
- printf("\n\r US : %i",R_setpoint); // User defined setpoint
- printf("\n\r VE : %2.2f",R_error_t); // Displays signed Velocity Error
- printf("\n\r IS : %i",R_integrator); // Displays currently state of the left integrator
- printf("\n\r CS : %2.4f",R_u_t); // Displays control signal
- printf("\n\r\n\r");
+
+ Bluetooth.printf("\n\r %i %2.1f %i %2.2f %i %2.1f %i %2.2f",L_setpoint,L_error_t,L_integrator,L_u_t,R_setpoint,R_error_t,R_integrator,R_u_t);
wait(0.75);
}