Cube Mini Solution

Dependencies:   mbed QEI MPU6050 BLE_API nRF51822 MCP4725 eMPL_MPU6050

Revision:
18:3b1aa67e11ca
Parent:
17:04eebb7c29b5
Child:
19:2ffbd2af2b7f
--- 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));
+        }
 
     // ----------------