-
Notifications
You must be signed in to change notification settings - Fork 2
Motor Model #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Motor Model #3
Conversation
Updated to make concise and sweep more accurately to optimize torque and rpm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few small things to look at, reiteration of things we discussed on saturday
| switch chosenTemp | ||
| case 80 | ||
| dat = load('A2370DD_T80C.mat'); | ||
| case 100 | ||
| dat = load('A2370DD_T100C.mat'); | ||
| case 120 | ||
| dat = load('A2370DD_T120C.mat'); | ||
| otherwise | ||
| error('Unexpected temperature selection.'); | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
load seperately
| error('Unexpected temperature selection.'); | ||
| end | ||
|
|
||
| notes = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previously discussed notes method
| availableTemps = [80 100 120]; | ||
| [~, idxNearest] = min(abs(availableTemps - Temp)); | ||
| chosenTemp = availableTemps(idxNearest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
later interpolation?
| % Derive speed and current axes from matrix dimensions: | ||
| % assume speeds from 0 to 20000 rpm across NR rows (uniform) | ||
| % assume currents from 0 to 105 A across NC columns (uniform) | ||
| speeds = linspace(0,20000,NR).'; % column vector, rpm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
take speed as input (as previously discussed)
| % Check voltage satisfied (with tolerance) | ||
| v_ok = (Vv <= V_dc + epsV); | ||
| % Check torque satisfied (with tolerance downward) | ||
| t_ok = (Tv >= T_dmd - epsT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personal preference but write it as |x-y| <= eps
| for row = NR:-1:1 % highest speed first | ||
| for col = 1:NC % lowest current first | ||
| Tv = Tmat(row,col); | ||
| Vv = Vmat(row,col); | ||
| % Check voltage satisfied (with tolerance) | ||
| v_ok = (Vv <= V_dc + epsV); | ||
| % Check torque satisfied (with tolerance downward) | ||
| t_ok = (Tv >= T_dmd - epsT); | ||
| if v_ok && t_ok | ||
| % Exact acceptable operating point found (prefer high RPM, then low current) | ||
| selected_row = row; | ||
| selected_col = col; | ||
| found_exact = true; | ||
| notes{end+1} = sprintf('Exact operating point found at row %d (%.1f rpm), col %d (I=%.3g A): T=%.3g, V=%.3g.', ... | ||
| row, speeds(row), col, currents(col), Tv, Vv); | ||
| break; % break inner loop (we found the best point for this high RPM) | ||
| else | ||
| % If voltage satisfied but torque not, consider as fallback candidate | ||
| if v_ok && ~t_ok | ||
| if Tv > fallback_T | ||
| fallback_T = Tv; | ||
| fallback_row = row; | ||
| fallback_col = col; | ||
| fallback_exists = true; | ||
| end | ||
| end | ||
| % Otherwise (V not ok) we do nothing special, continue scanning | ||
| end | ||
| end | ||
| if found_exact | ||
| break; % exit outer loop | ||
| end | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can replace this with (assuming dimensions of Vmat, Tmat are the same)
| for row = NR:-1:1 % highest speed first | |
| for col = 1:NC % lowest current first | |
| Tv = Tmat(row,col); | |
| Vv = Vmat(row,col); | |
| % Check voltage satisfied (with tolerance) | |
| v_ok = (Vv <= V_dc + epsV); | |
| % Check torque satisfied (with tolerance downward) | |
| t_ok = (Tv >= T_dmd - epsT); | |
| if v_ok && t_ok | |
| % Exact acceptable operating point found (prefer high RPM, then low current) | |
| selected_row = row; | |
| selected_col = col; | |
| found_exact = true; | |
| notes{end+1} = sprintf('Exact operating point found at row %d (%.1f rpm), col %d (I=%.3g A): T=%.3g, V=%.3g.', ... | |
| row, speeds(row), col, currents(col), Tv, Vv); | |
| break; % break inner loop (we found the best point for this high RPM) | |
| else | |
| % If voltage satisfied but torque not, consider as fallback candidate | |
| if v_ok && ~t_ok | |
| if Tv > fallback_T | |
| fallback_T = Tv; | |
| fallback_row = row; | |
| fallback_col = col; | |
| fallback_exists = true; | |
| end | |
| end | |
| % Otherwise (V not ok) we do nothing special, continue scanning | |
| end | |
| end | |
| if found_exact | |
| break; % exit outer loop | |
| end | |
| end | |
| [n, m] = size(Vmat) | |
| k = find(abs(Vmat - T_dmd) <= epsT & abs(Vmat - V_dc) <= epsV, 1, 'first') | |
| found_exact=size(k) > 0 | |
| row, col = mod(k[0], n), floorDiv(k[0] / n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(double check my syntax but this is the main idea)
No description provided.