diff --git a/source_code/Teensy35/.vscode/ipch/14cbe486409a6b76/ENCODER.ipch b/source_code/Teensy35/.vscode/ipch/14cbe486409a6b76/ENCODER.ipch deleted file mode 100644 index 66d66f7137b7e466c9f49f18e76a541259bac535..0000000000000000000000000000000000000000 Binary files a/source_code/Teensy35/.vscode/ipch/14cbe486409a6b76/ENCODER.ipch and /dev/null differ diff --git a/source_code/Teensy35/.vscode/ipch/14cbe486409a6b76/mmap_address.bin b/source_code/Teensy35/.vscode/ipch/14cbe486409a6b76/mmap_address.bin deleted file mode 100644 index 862b8428b9e068428b1a4e8a38f94019008d8940..0000000000000000000000000000000000000000 Binary files a/source_code/Teensy35/.vscode/ipch/14cbe486409a6b76/mmap_address.bin and /dev/null differ diff --git a/source_code/Teensy35/.vscode/ipch/1cb69e9f519845bb/UTILS.ipch b/source_code/Teensy35/.vscode/ipch/1cb69e9f519845bb/UTILS.ipch deleted file mode 100644 index bde1979a083e566448268b9a30221c3ec78a1e05..0000000000000000000000000000000000000000 Binary files a/source_code/Teensy35/.vscode/ipch/1cb69e9f519845bb/UTILS.ipch and /dev/null differ diff --git a/source_code/Teensy35/.vscode/ipch/1cb69e9f519845bb/mmap_address.bin b/source_code/Teensy35/.vscode/ipch/1cb69e9f519845bb/mmap_address.bin deleted file mode 100644 index 862b8428b9e068428b1a4e8a38f94019008d8940..0000000000000000000000000000000000000000 Binary files a/source_code/Teensy35/.vscode/ipch/1cb69e9f519845bb/mmap_address.bin and /dev/null differ diff --git a/source_code/Teensy35/.vscode/ipch/6772f3aa2747424b/mmap_address.bin b/source_code/Teensy35/.vscode/ipch/6772f3aa2747424b/mmap_address.bin deleted file mode 100644 index 862b8428b9e068428b1a4e8a38f94019008d8940..0000000000000000000000000000000000000000 Binary files a/source_code/Teensy35/.vscode/ipch/6772f3aa2747424b/mmap_address.bin and /dev/null differ diff --git a/source_code/Teensy35/.vscode/ipch/8c5111ec85d5935b/MOTOR_CTRL.ipch b/source_code/Teensy35/.vscode/ipch/8c5111ec85d5935b/MOTOR_CTRL.ipch deleted file mode 100644 index eeb40cb13ec0cc78c3d5ac794580dca8aa130af8..0000000000000000000000000000000000000000 Binary files a/source_code/Teensy35/.vscode/ipch/8c5111ec85d5935b/MOTOR_CTRL.ipch and /dev/null differ diff --git a/source_code/Teensy35/.vscode/ipch/8c5111ec85d5935b/mmap_address.bin b/source_code/Teensy35/.vscode/ipch/8c5111ec85d5935b/mmap_address.bin deleted file mode 100644 index 862b8428b9e068428b1a4e8a38f94019008d8940..0000000000000000000000000000000000000000 Binary files a/source_code/Teensy35/.vscode/ipch/8c5111ec85d5935b/mmap_address.bin and /dev/null differ diff --git a/source_code/Teensy35/.vscode/ipch/c7b2d5234dd9a51/MAIN.ipch b/source_code/Teensy35/.vscode/ipch/c7b2d5234dd9a51/MAIN.ipch deleted file mode 100644 index 05cca2b631f832eb8f8c6494992d9e1ca2292eb2..0000000000000000000000000000000000000000 Binary files a/source_code/Teensy35/.vscode/ipch/c7b2d5234dd9a51/MAIN.ipch and /dev/null differ diff --git a/source_code/Teensy35/.vscode/ipch/c7b2d5234dd9a51/mmap_address.bin b/source_code/Teensy35/.vscode/ipch/c7b2d5234dd9a51/mmap_address.bin deleted file mode 100644 index 862b8428b9e068428b1a4e8a38f94019008d8940..0000000000000000000000000000000000000000 Binary files a/source_code/Teensy35/.vscode/ipch/c7b2d5234dd9a51/mmap_address.bin and /dev/null differ diff --git a/source_code/Teensy35/.vscode/settings.json b/source_code/Teensy35/.vscode/settings.json index e666c20d0dfdb405a2b6a6ddd68b2656e3b7270d..152560a2b2f52179d65f5a026969f3af7ab5d7b4 100644 --- a/source_code/Teensy35/.vscode/settings.json +++ b/source_code/Teensy35/.vscode/settings.json @@ -1,6 +1,6 @@ { "terminal.integrated.env.windows": { - "PATH": "C:\\Users\\Matt\\.platformio\\penv\\Scripts;C:\\Users\\Matt\\.platformio\\penv;C:\\Program Files\\Dell\\DW WLAN Card;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;c:\\Program Files\\WIDCOMM\\Bluetooth Software\\;c:\\Program Files\\WIDCOMM\\Bluetooth Software\\syswow64;C:\\WINDOWS\\system32\\config\\systemprofile\\.dnx\\bin;C:\\Program Files\\Microsoft DNX\\Dnvm\\;C:\\Program Files (x86)\\Windows Kits\\8.1\\Windows Performance Toolkit\\;C:\\Program Files\\Microsoft SQL Server\\130\\Tools\\Binn\\;C:\\Program Files\\PuTTY\\;C:\\Program Files (x86)\\Xoreax\\IncrediBuild;C:\\Program Files\\MATLAB\\R2017b\\runtime\\win64;C:\\Program Files\\MATLAB\\R2017b\\bin;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Git\\mingw64\\bin;C:\\Program Files\\Git\\usr\\bin;C:\\Program Files (x86)\\Microsoft VS Code\\bin;C:\\Users\\Matt\\Anaconda3;C:\\Users\\Matt\\Anaconda3\\Library\\mingw-w64\\bin;C:\\Users\\Matt\\Anaconda3\\Library\\usr\\bin;C:\\Users\\Matt\\Anaconda3\\Library\\bin;C:\\Users\\Matt\\Anaconda3\\Scripts;C:\\Users\\Matt\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files (x86)\\Microsoft VS Code\\bin;C:\\Users\\Matt\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Program Files\\Dell\\DW WLAN Card;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;c:\\Program Files\\WIDCOMM\\Bluetooth Software\\;c:\\Program Files\\WIDCOMM\\Bluetooth Software\\syswow64;C:\\WINDOWS\\system32\\config\\systemprofile\\.dnx\\bin;C:\\Program Files\\Microsoft DNX\\Dnvm\\;C:\\Program Files (x86)\\Windows Kits\\8.1\\Windows Performance Toolkit\\;C:\\Program Files\\Microsoft SQL Server\\130\\Tools\\Binn\\;C:\\Program Files\\PuTTY\\;C:\\Program Files (x86)\\Xoreax\\IncrediBuild;C:\\Program Files\\MATLAB\\R2017b\\runtime\\win64;C:\\Program Files\\MATLAB\\R2017b\\bin;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Git\\mingw64\\bin;C:\\Program Files\\Git\\usr\\bin;C:\\Program Files (x86)\\Microsoft VS Code\\bin;C:\\Users\\Matt\\Anaconda3;C:\\Users\\Matt\\Anaconda3\\Library\\mingw-w64\\bin;C:\\Users\\Matt\\Anaconda3\\Library\\usr\\bin;C:\\Users\\Matt\\Anaconda3\\Library\\bin;C:\\Users\\Matt\\Anaconda3\\Scripts;C:\\Users\\Matt\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files (x86)\\Microsoft VS Code\\bin;C:\\Users\\Matt\\AppData\\Local\\Programs\\Microsoft VS Code\\bin", + "PATH": "C:\\Users\\zatar\\.platformio\\penv\\Scripts;C:\\Users\\zatar\\.platformio\\penv;C:\\ProgramData\\Anaconda3;C:\\ProgramData\\Anaconda3\\Library\\mingw-w64\\bin;C:\\ProgramData\\Anaconda3\\Library\\usr\\bin;C:\\ProgramData\\Anaconda3\\Library\\bin;C:\\ProgramData\\Anaconda3\\Scripts;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\PuTTY\\;C:\\Users\\zatar\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\zatar\\AppData\\Local\\GitHubDesktop\\bin;C:\\Users\\zatar\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\zatar\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;c:\\Cygwin64\\bin;C:\\src\\flutter\\bin;;C:\\ProgramData\\Anaconda3;C:\\ProgramData\\Anaconda3\\Library\\mingw-w64\\bin;C:\\ProgramData\\Anaconda3\\Library\\usr\\bin;C:\\ProgramData\\Anaconda3\\Library\\bin;C:\\ProgramData\\Anaconda3\\Scripts;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\PuTTY\\;C:\\Users\\zatar\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\zatar\\AppData\\Local\\GitHubDesktop\\bin;C:\\Users\\zatar\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\zatar\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;c:\\Cygwin64\\bin;C:\\src\\flutter\\bin;", "PLATFORMIO_CALLER": "vscode" } } \ No newline at end of file diff --git a/source_code/Teensy35/src/encoder.cpp b/source_code/Teensy35/src/encoder.cpp index cc19dcb1cfa0d6b0fe840bdcf14cd576f8339b18..4b5dca28879598f975f72f45f044cad61e738f72 100644 --- a/source_code/Teensy35/src/encoder.cpp +++ b/source_code/Teensy35/src/encoder.cpp @@ -23,7 +23,7 @@ int Zoffset = 0; // This is the difference in encoder tics from the Z index to // the electrical encoder zero (which is found by powering the // AB block and waiting for the motor to settle) -int hard_coded_offset = -615; +int hard_coded_offset = -420 - 50; //Invert position to invert position add 341 to any offset @@ -59,6 +59,7 @@ int get_phase_number(int elec_position); void print_speed_ISR(void); void buttonA_ISR(void); void buttonB_ISR(void); +void set_calibration_complete(void); @@ -320,7 +321,12 @@ void debug_encoder(void) delayMicroseconds(1000); } - -} +} + +void set_calibration_comlete() { + cli(); + calibration_complete = true; + sei(); +} diff --git a/source_code/Teensy35/src/encoder.h b/source_code/Teensy35/src/encoder.h index b50544da5320e58618922b8dbfeacb558d2d63e3..893ce6699870ca1955a2875d26bf31fef2636974 100644 --- a/source_code/Teensy35/src/encoder.h +++ b/source_code/Teensy35/src/encoder.h @@ -13,8 +13,7 @@ int get_elec_rev_position_ticks(int mechanical_position); int get_phase_number(int elec_position); int get_Zoffset(void); bool is_calibration_complete(); -void set_calibration_complete(); - +void set_calibration_comlete(void); diff --git a/source_code/Teensy35/src/motor_ctrl.cpp b/source_code/Teensy35/src/motor_ctrl.cpp index c6165c3ae49cf3f5eeb20ad429cb93b90b9248e9..e276ab2931f2d0acf1304dc20fee8bbbd817d39e 100644 --- a/source_code/Teensy35/src/motor_ctrl.cpp +++ b/source_code/Teensy35/src/motor_ctrl.cpp @@ -29,7 +29,7 @@ const int time_led = 1; int const SCALE_FACTOR = 255; // This is the PWM frequency and it is very important -int FREQ = 22000; //8000 was our original value; +int FREQ = 22000;//22000; //8000 was our original value; // This is the lower limit of PWM frequency // its important for not breaking gate drivers @@ -135,7 +135,9 @@ int one_to_scaleFactor(int x) { // NOTE: The scale factor is the max value we want out of // the potentiometer - return get_pot_0_scaled(SCALE_FACTOR, PERIOD_OVER_255); + cli(); + return POT_0_VALUE; + sei(); } else{ return 0; @@ -183,10 +185,13 @@ void set_block_phase(int phase) // This function takes in a seris of 1 and 0s void set_phase(int high1, int high2, int high3, int low1, int low2, int low3) { + high1 = one_to_scaleFactor(high1); high2 = one_to_scaleFactor(high2); high3 = one_to_scaleFactor(high3); + + //turn the stuff that should be off, off first cli(); if (! low1) analogWrite(L1, 0); @@ -399,9 +404,15 @@ void motor_butt_control_precalculated(void) //and torque (potentiometer on pin A0) void open_loop_control(void) { + // This is just a stupid work around for now + // Open Loop doesn't really need to calibrate, but + // get_pot_0_scaled requires calibration + set_calibration_comlete(); + + while(1) { - for(int p = 1; p <= 6; p++) + for(int p = 6; p >= 1; p--) { set_block_phase(p); //What's going on with this math, explination: @@ -410,7 +421,7 @@ void open_loop_control(void) // we want the maximum speed to be 2800 us per phase // the max speed corresponds to 5 rev/sec // we know we need to go faster but this is just testing - volatile int myDelay = 1500 + (get_pot_1_inv() * 300); + volatile int myDelay = 6000; // Serial.println("my delay:"); // Serial.println(myDelay); // Serial.println("my speed:"); @@ -569,7 +580,7 @@ void debug_motor(void) { case 3: set_phase(0,1,0,0,0,1); - Serial.println("I AM IN STATE 3-EC"); + Serial.println("I AM IN STATE 3-BC"); break; case 4: