Dependencies:   mbed QEI MPU6050 BLE_API nRF51822 MCP4725 eMPL_MPU6050

Files at this revision

API Documentation at this revision

Comitter:
BoulusAJ
Date:
Fri May 29 15:40:58 2020 +0000
Parent:
17:04eebb7c29b5
Commit message:
Version May 29, 2020

Changed in this revision

MCP4725.lib Show annotated file Show diff for this revision Revisions of this file
MPU6050.lib Show annotated file Show diff for this revision Revisions of this file
QEI.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 04eebb7c29b5 -r 3b1aa67e11ca MCP4725.lib
--- a/MCP4725.lib	Fri May 29 13:57:32 2020 +0000
+++ b/MCP4725.lib	Fri May 29 15:40:58 2020 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/donalm/code/MCP4725/#28af46e7207f
+https://os.mbed.com/users/BoulusAJ/code/MCP4725/#28af46e7207f
diff -r 04eebb7c29b5 -r 3b1aa67e11ca MPU6050.lib
--- a/MPU6050.lib	Fri May 29 13:57:32 2020 +0000
+++ b/MPU6050.lib	Fri May 29 15:40:58 2020 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/teams/Seeed/code/MPU6050/#8d033f880fce
+https://os.mbed.com/teams/GRT_FS2019_VoiceCoil/code/MPU6050/#8d033f880fce
diff -r 04eebb7c29b5 -r 3b1aa67e11ca QEI.lib
--- a/QEI.lib	Fri May 29 13:57:32 2020 +0000
+++ b/QEI.lib	Fri May 29 15:40:58 2020 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/aberk/code/QEI/#c20c6a8e709b
+https://os.mbed.com/users/BoulusAJ/code/QEI/#c20c6a8e709b
diff -r 04eebb7c29b5 -r 3b1aa67e11ca main.cpp
--- a/main.cpp	Fri May 29 13:57:32 2020 +0000
+++ b/main.cpp	Fri May 29 15:40:58 2020 +0000
@@ -10,6 +10,36 @@
 */
 
 /*
+
+    // Physical Model of Cuboid 2.0
+    
+    % Mass Parameters
+    Cube Mini - Mass = 0.6 + 0.170 + 0.015 = 0.7850 Kg, Mass of the Full Cuboid with Motor and Flywheel
+    Cube Mini - Flywheel Mass = 0.170 kg
+    Cube Mini - Without Flywheel Mass = 0.6150 kg
+    
+    % Dimensions Parameters
+    % Cube Mini Dimensions (10x10x10) cm
+    Cube Mini - Length = 0.90*100e-3 m (The multiplication by 0.9 is to compensate for the rounded edges)
+    Cube Mini - CoM = Cube Mini - Length * 0.5,  Center of Mass Location 
+    % Inertia Parameters
+    Cube Mini - Inertia (J) of the Body from the edge Edge = 0.003044 Kg.m^2,  Inertia about the edge
+    Cube Mini - Inertia (J) of Flyhweel and Rotor from Center = (0.0002104064 + 0.0000181) kg.m^2,
+    
+    % Motor Parameters
+    % Motor: Maxon Flat EC45, Part number: 411812, Specs: 24V, Km 36.9e-3
+    Cube Mini - Motor.Km = 36.9e-3 % Torque Constant % Unit: Nm/A
+    Cube Mini - Motor.Resistance = 0.608 % Terminal Resistance % Unit: Ohm
+    Cube Mini - Motor.Inductance = 0.463e-3 % Unit: H, Henry
+    
+    % PI Controller Escon 
+    Cube Mini - Escon.PI_Tn = 500e-6; %945e-6
+    Cube Mini - Escon.PI_Kp = 100*(10/2^11);%576*(10/2^11)
+    
+    % RC Physical Velocity Voltage Filter
+    Filter.Velocity.R = 1e3 Ohm
+    Filter.Velocity.C = 10e-6 F
+
     Settings for Maxon ESCON controller (upload via ESCON Studio)
     Escon Studio file Location: ...
 
@@ -343,7 +373,7 @@
             VoltageOut.write(CurrentToVoltage(Sys_input_Amps));
             //pc.printf("%0.7f, %0.7f, \n\r", abs(Cuboid_Angle_Degrees), abs(Velocity));
 
-            if (abs(Velocity) < 10.0f) {
+            if (abs(Velocity) < 15.0f) {
                 Sys_input_Amps = 0.0;
                 Button_Status = 2;
                 break;
@@ -358,8 +388,14 @@
     if (Sys_input_Amps < uMin) {
         Sys_input_Amps = uMin;
     }
+    if (Cuboid_Angle_Degrees > -50.0f && Cuboid_Angle_Degrees < 50.0f) {
     // Scaling the controller output from -15 A --> 15 A to 0 V --> 5 V
     VoltageOut.write(CurrentToVoltage(Sys_input_Amps));
+    }
+    else {
+        Sys_input_Amps = 0.0f;
+        VoltageOut.write(CurrentToVoltage(Sys_input_Amps));
+        }
 
     // ----------------