├── PL3GUI.mlapp ├── PL3GUI_exported.m └── README.md /PL3GUI.mlapp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kennet22/Matlab-App-Designer-GUI/8e17add9fe964bd6bcdf5ae1e631c9ddd8d04ebc/PL3GUI.mlapp -------------------------------------------------------------------------------- /PL3GUI_exported.m: -------------------------------------------------------------------------------- 1 | classdef PL3GUI_exported < matlab.apps.AppBase 2 | 3 | % Properties that correspond to app components 4 | properties (Access = public) 5 | UIFigure matlab.ui.Figure 6 | TabGroup matlab.ui.container.TabGroup 7 | SolarFarmTab matlab.ui.container.Tab 8 | PowerSwitchLabel matlab.ui.control.Label 9 | solarFarmSwitch matlab.ui.control.ToggleSwitch 10 | SolarFarmDetailsLabel matlab.ui.control.Label 11 | solarFarmCurrent matlab.ui.control.NumericEditField 12 | VoltageVEditField_7Label matlab.ui.control.Label 13 | solarFarmVoltage matlab.ui.control.NumericEditField 14 | PowerWEditField_7Label matlab.ui.control.Label 15 | solarFarmPower matlab.ui.control.NumericEditField 16 | CurrentmAEditField_2Label_2 matlab.ui.control.Label 17 | VoltageGaugeLabel matlab.ui.control.Label 18 | VoltageGauge matlab.ui.control.Gauge 19 | CurrentGaugeLabel matlab.ui.control.Label 20 | CurrentGauge matlab.ui.control.Gauge 21 | PowerGaugeLabel matlab.ui.control.Label 22 | PowerGauge matlab.ui.control.Gauge 23 | UIAxes matlab.ui.control.UIAxes 24 | solarFarmVGraphButton matlab.ui.control.Button 25 | solarFarmCGraphButton matlab.ui.control.Button 26 | BatteryOutputTab matlab.ui.container.Tab 27 | BatteryDetailsLabel matlab.ui.control.Label 28 | PowerSwitch_2Label matlab.ui.control.Label 29 | batterySwitch matlab.ui.control.ToggleSwitch 30 | BatteryPercentLabel matlab.ui.control.Label 31 | batteryPercent matlab.ui.control.NumericEditField 32 | VoltageVEditField_8Label matlab.ui.control.Label 33 | batteryVoltage matlab.ui.control.NumericEditField 34 | BatteryChargeGaugeLabel matlab.ui.control.Label 35 | BatteryChargeGauge matlab.ui.control.SemicircularGauge 36 | VoltageGauge_2Label matlab.ui.control.Label 37 | batteryVGauge matlab.ui.control.Gauge 38 | batteryVGraphButton matlab.ui.control.Button 39 | loadTwo matlab.ui.container.Tab 40 | loadTwoPowerGraph matlab.ui.control.UIAxes 41 | VDCLoadLabel_2 matlab.ui.control.Label 42 | PowerSwitch_6Label matlab.ui.control.Label 43 | loadTwoSwitch matlab.ui.control.ToggleSwitch 44 | VoltageVEditField_6Label matlab.ui.control.Label 45 | loadTwoVoltage matlab.ui.control.NumericEditField 46 | CurrentmAEditField_6Label matlab.ui.control.Label 47 | loadTwoCurrent matlab.ui.control.NumericEditField 48 | PowerWEditField_6Label matlab.ui.control.Label 49 | loadTwoPower matlab.ui.control.NumericEditField 50 | ResistanceLabel_3 matlab.ui.control.Label 51 | loadTwoResistance matlab.ui.control.NumericEditField 52 | VoltageGauge_3Label_2 matlab.ui.control.Label 53 | loadTwoVGauge matlab.ui.control.Gauge 54 | CurrentGauge_3Label_2 matlab.ui.control.Label 55 | loadTwoCGauge matlab.ui.control.Gauge 56 | PowerGauge_3Label_2 matlab.ui.control.Label 57 | loadTwoPowerGauge matlab.ui.control.Gauge 58 | loadTwoVGraphButton matlab.ui.control.Button 59 | loadTwoCGraphButton matlab.ui.control.Button 60 | loadThree matlab.ui.container.Tab 61 | loadThreePowerGraph matlab.ui.control.UIAxes 62 | VDCLoadLabel_3 matlab.ui.control.Label 63 | PowerSwitch_5Label matlab.ui.control.Label 64 | loadThreeSwitch matlab.ui.control.ToggleSwitch 65 | VoltageVEditField_5Label matlab.ui.control.Label 66 | loadThreeVoltage matlab.ui.control.NumericEditField 67 | CurrentmAEditField_5Label matlab.ui.control.Label 68 | loadThreeCurrent matlab.ui.control.NumericEditField 69 | PowerWEditField_5Label matlab.ui.control.Label 70 | loadThreePower matlab.ui.control.NumericEditField 71 | ResistanceLabel_4 matlab.ui.control.Label 72 | loadThreeResistance matlab.ui.control.NumericEditField 73 | VoltageGauge_3Label_3 matlab.ui.control.Label 74 | loadThreeVGauge matlab.ui.control.Gauge 75 | CurrentGauge_3Label_3 matlab.ui.control.Label 76 | loadThreeCGauge matlab.ui.control.Gauge 77 | PowerGauge_3Label_3 matlab.ui.control.Label 78 | loadThreePowerGauge matlab.ui.control.Gauge 79 | loadThreeVGraphButton matlab.ui.control.Button 80 | loadThreeCGraphButton matlab.ui.control.Button 81 | MicrogridStatusPanel matlab.ui.container.Panel 82 | SolarFarmLampLabel matlab.ui.control.Label 83 | SolarFarmLamp matlab.ui.control.Lamp 84 | BatteryLampLabel matlab.ui.control.Label 85 | BatteryLamp matlab.ui.control.Lamp 86 | VDCLoadLamp_2Label matlab.ui.control.Label 87 | loadThreeStatus matlab.ui.control.Lamp 88 | VDCLoadLabel matlab.ui.control.Label 89 | loadTwoStatus matlab.ui.control.Lamp 90 | SystemPowerSwitchLabel matlab.ui.control.Label 91 | SystemPowerSwitch matlab.ui.control.Switch 92 | BluetoothStatusPanel matlab.ui.container.Panel 93 | ConnectionLampLabel matlab.ui.control.Label 94 | ConnectionLamp matlab.ui.control.Lamp 95 | DisconnectButton matlab.ui.control.Button 96 | RemoteIDLabel matlab.ui.control.Label 97 | MicrogridbyLabel matlab.ui.control.Label 98 | JordanMorrisLabel matlab.ui.control.Label 99 | EskindirAbebeLabel matlab.ui.control.Label 100 | BradenLeeLabel matlab.ui.control.Label 101 | KennetThurmanLabel matlab.ui.control.Label 102 | BTIDLabel matlab.ui.control.Label 103 | ConnectButton matlab.ui.control.Button 104 | ProjectLab3Label matlab.ui.control.Label 105 | end 106 | 107 | 108 | properties (Access = public) 109 | i = 0; 110 | t; 111 | Bt; 112 | count = 0; 113 | oneSecondCounter = 0; 114 | selectedTab; 115 | validData = 1; 116 | voltage = 0; 117 | current = 0; 118 | currentFigure; 119 | voltageFigure; 120 | figure; 121 | 122 | oneS; 123 | twoS; 124 | threeS; 125 | batteryS; 126 | solarFarmS; 127 | 128 | oneT; 129 | twoT; 130 | threeT; 131 | batteryT; 132 | solarFarmT = 1; 133 | % SFV; 134 | % SFA; 135 | % SFP; 136 | % 137 | % BV; 138 | % 139 | % oneV; 140 | % oneA; 141 | % oneP; 142 | % 143 | % twoV; 144 | % twoA; 145 | % twoP; 146 | % 147 | % threeV; 148 | % threeA; 149 | % threeP; 150 | end 151 | 152 | methods (Access = private) 153 | 154 | function bluetoothSetup(app) 155 | 156 | % Create bluetooth object 157 | app.Bt = Bluetooth('btspp://000666EBE248', 1); 158 | % Open Bluetooth connection 159 | fopen(app.Bt); 160 | % Set terminator character 161 | set(app.Bt, 'Terminator', 'E'); 162 | % Indicate the program starts on the Solar Panel Tab 163 | fwrite(app.Bt, '1'); 164 | 165 | app.ConnectionLamp.Color = 'green'; 166 | app.BTIDLabel.Text = get(app.Bt, 'RemoteID'); 167 | app.BTIDLabel.Visible = 'on'; 168 | %app.selectedTab = app.TabGroup.SelectedTab; 169 | end 170 | 171 | 172 | 173 | function startSystem(app) 174 | 175 | app.solarFarmSwitch.Value = 'On'; 176 | app.SolarFarmLamp.Color = 'green'; 177 | app.solarFarmS = 1; 178 | 179 | app.batterySwitch.Value = 'On'; 180 | app.BatteryLamp.Color = 'green'; 181 | app.batteryS = 1; 182 | 183 | app.loadThreeSwitch.Value = 'On'; 184 | app.loadTwoStatus.Color = 'green'; 185 | app.threeS = 1; 186 | 187 | app.loadTwoSwitch.Value = 'On'; 188 | app.loadThreeStatus.Color = 'green'; 189 | app.twoS = 1; 190 | 191 | readData(app); 192 | end 193 | 194 | 195 | function stopSystem(app) 196 | 197 | app.solarFarmSwitch.Value = 'Off'; 198 | app.SolarFarmLamp.Color = 'red'; 199 | app.solarFarmS = 0; 200 | 201 | app.batterySwitch.Value = 'Off'; 202 | app.BatteryLamp.Color = 'red'; 203 | app.batteryS = 0; 204 | 205 | app.loadTwoSwitch.Value = 'Off'; 206 | app.loadThreeStatus.Color = 'red'; 207 | app.twoS = 0; 208 | 209 | app.loadThreeSwitch.Value = 'Off'; 210 | app.loadTwoStatus.Color = 'red'; 211 | app.threeS = 0; 212 | 213 | fwrite(app.Bt, '0'); 214 | end 215 | 216 | function [SFV, SFA, SFP, BV, BC, twoV, twoP, twoA, threeV, threeP, threeA] = ADC(app, SFV, SFA, BV, twoV, threeV) 217 | % Perfrom all ADC calculations 218 | 219 | SFV = ((23*SFV)/3290); 220 | SFA = (((3.3)/4096)*SFA)/0.05; 221 | SFP = SFV*SFA; 222 | 223 | BV = ((3.3)/4096)*BV; 224 | BC = ((BV*100)/3240); 225 | 226 | twoV = (((3.3)/4096)*twoV); 227 | twoP = ((twoV*twoV)/app.loadTwoResistance.Value); 228 | twoA = (twoP/twoV); 229 | 230 | threeV = (((3.3)/4096)*threeV); 231 | threeP = ((threeV*threeV)/app.loadThreeResistance.Value); 232 | threeA = (threeP/threeV); 233 | 234 | end 235 | 236 | 237 | 238 | function readData(app) 239 | disp("Read Data"); 240 | app.validData = 1; 241 | 242 | while(app.validData) 243 | % Request data from MCU 244 | fwrite(app.Bt, '9'); 245 | % Get line of data received via Bluetooth 246 | try 247 | data = fgetl(app.Bt); 248 | catch 249 | disp("Error getting data"); 250 | end 251 | app.selectedTab = app.TabGroup.SelectedTab; 252 | % If the data contains a ',' - Parse 253 | if (contains(data, ',')) 254 | [SFV,SFA,BV,twoV,threeV] = parseData(app, data); 255 | [SFV, SFA, SFP, BV, BC, twoV, twoP, twoA, threeV, threeP, threeA] = ADC(app, SFV, SFA, BV, twoV, threeV); 256 | assignData(app, SFV, SFA, SFP, BV, BC, twoV, twoA, twoP, threeV, threeA, threeP); 257 | elseif (data == "10") 258 | app.solarFarmS = 0; 259 | app.solarFarmSwitch.Value = 'Off'; 260 | app.SolarFarmLamp.Color = 'red'; 261 | elseif (data =="20") 262 | app.batteryS = 0; 263 | app.batterySwitch.Value = 'Off'; 264 | app.batteryLamp.Color ='red'; 265 | elseif (data == "40") 266 | app.twoS = 0; 267 | 268 | elseif (data == "50") 269 | app.threeS = 0; 270 | 271 | else 272 | disp('Data Error'); 273 | disp(data); 274 | app.validData = 0; 275 | end 276 | end 277 | end 278 | 279 | function assignData(app, SFV, SFA, SFP, BV, BC, twoV, twoA, twoP, threeV, threeA, threeP) 280 | 281 | app.count = app.count + 1; 282 | 283 | if (mod(app.count, 1) == 0) 284 | app.oneSecondCounter = app.oneSecondCounter + 1; 285 | 286 | if (app.oneSecondCounter > 60) 287 | app.oneSecondCounter = 0; 288 | end 289 | end 290 | 291 | if (isequal(app.solarFarmT, 1) && isequal(app.solarFarmS, 1)) % Solar Farm 292 | % Solar Panel data assignment 293 | 294 | 295 | % Detect if voltage or current has fallen below operating values 296 | if (SFV > 23) 297 | app.solarFarmS = 0; 298 | app.solarFarmSwitch.Value = 'Off'; 299 | app.SolarFarmLamp.Color = 'red'; 300 | 301 | elseif (SFA > 1.67) 302 | app.solarFarmS = 0; 303 | app.solarFarmSwitch.Value = 'Off'; 304 | app.SolarFarmLamp.Color = 'red'; 305 | else 306 | app.solarFarmVoltage.Value = SFV; 307 | app.VoltageGauge.Value = SFV; 308 | 309 | app.CurrentGauge.Value = SFA; 310 | app.solarFarmCurrent.Value = SFA; 311 | 312 | app.solarFarmPower.Value = SFP; 313 | app.PowerGauge.Value = SFP; 314 | 315 | powerGraph(app, app.UIAxes, SFP); 316 | end 317 | 318 | elseif (isequal(app.batteryT, 1) && isequal(app.batteryS, 1)) % Battery 319 | % Battery data assignment 320 | pause(0.25); 321 | 322 | disp("assigning battery data"); 323 | 324 | app.batteryVoltage.Value = BV; 325 | app.batteryVGauge.Value = BV; 326 | 327 | app.BatteryChargeGauge.Value = BC; 328 | app.batteryPercent.Value = BC; 329 | 330 | elseif (isequal(app.twoT, 1)&& isequal(app.twoS, 1)) % Battery 331 | % 12V AC Load data assignment 332 | 333 | if (twoA > 1 || twoV > 7) 334 | app.twoS = 0; 335 | app.loadTwoSwitch.Value = 'Off'; 336 | app.loadTwoStatus.Color = 'red'; 337 | else 338 | app.loadTwoCurrent.Value = twoA; 339 | app.loadTwoCGauge.Value = twoA; 340 | 341 | app.loadTwoVoltage.Value = twoV; 342 | app.loadTwoVGauge.Value = twoV; 343 | 344 | app.loadTwoPower.Value = twoP; 345 | app.loadTwoPowerGauge.Value = twoP; 346 | 347 | powerGraph(app, app.loadTwoPowerGraph, twoP); 348 | end 349 | 350 | elseif (isequal(app.threeT, 1) && isequal(app.threeS, 1)) % Battery 351 | % 24V DC Load data assignment 352 | 353 | if (threeA > 1 || threeV > 14) 354 | app.threeS = 0; 355 | app.loadThreeSwitch = 'Off'; 356 | app.loadThreeStatus.Color = 'red'; 357 | else 358 | app.loadThreeCurrent.Value = threeA; 359 | app.loadThreeCGauge.Value = threeA; 360 | 361 | app.loadThreeVoltage.Value = threeV; 362 | app.loadThreeVGauge.Value = threeV; 363 | 364 | app.loadThreePower.Value = threeP; 365 | app.loadThreePowerGauge.Value = threeP; 366 | 367 | powerGraph(app, app.loadThreePowerGraph, threeP); 368 | end 369 | else 370 | disp("No active tab or on switch. Stopping data stream..."); 371 | app.validData = 0; 372 | end 373 | 374 | end 375 | 376 | function powerGraph(app, axes, y) 377 | 378 | axes.XLim = [0,60]; 379 | axes.XTickMode = 'manual'; 380 | axes.XLimMode = 'manual'; 381 | 382 | hold(axes, 'on'); 383 | 384 | if (app.oneSecondCounter >= 60) 385 | axes.cla; 386 | hold(axes, 'off'); 387 | end 388 | try 389 | plot(axes, app.oneSecondCounter, y, 'bo') 390 | drawnow 391 | catch 392 | disp("Power graph error catch"); 393 | end 394 | end 395 | 396 | function graph(app, axes, y) 397 | 398 | try 399 | plot(axes, app.oneSecondCounter, y, 'bo'); 400 | drawnow 401 | 402 | if (app.oneSecondCounter >= 60) 403 | axes.cla; 404 | end 405 | catch 406 | end 407 | 408 | 409 | end 410 | 411 | function [SFV,SFA,BV,twoV,threeV] = parseData(~, data) 412 | 413 | split = strsplit(data, ','); 414 | 415 | SFV = str2double(split{1}); % 1 416 | 417 | SFA = str2double(split{2}); % 2 418 | 419 | BV = str2double(split{3}); % 3 420 | 421 | twoV = str2double(split{4}); % 5 422 | 423 | threeV = str2double(split{5}); % 6 424 | 425 | end 426 | 427 | end 428 | 429 | 430 | methods (Access = public) 431 | 432 | end 433 | 434 | 435 | methods (Access = private) 436 | 437 | % Code that executes after component creation 438 | function startupFcn(app) 439 | 440 | end 441 | 442 | % Value changed function: SystemPowerSwitch 443 | function SystemPowerSwitchValueChanged(app, event) 444 | value = app.SystemPowerSwitch.Value; 445 | 446 | if (strcmpi(value,'On')) 447 | startSystem(app); 448 | else 449 | stopSystem(app); 450 | end 451 | end 452 | 453 | % Button pushed function: DisconnectButton 454 | function DisconnectButtonPushed(app, event) 455 | app.Bt = Bluetooth('btspp://000666EBE248', 1); 456 | fclose(app.Bt); 457 | delete(app.Bt); 458 | clear Bt; 459 | app.ConnectionLamp.Color = 'red'; 460 | end 461 | 462 | % Button pushed function: ConnectButton 463 | function ConnectButtonPushed(app, event) 464 | bluetoothSetup(app); 465 | readData(app); 466 | end 467 | 468 | % Value changed function: solarFarmSwitch 469 | function solarFarmSwitchValueChanged(app, event) 470 | 471 | value = app.solarFarmSwitch.Value; % Solar Panel Status 472 | app.solarFarmSwitch.Interruptible = 'on'; 473 | 474 | if (strcmpi(value,'On') && strcmpi(app.SystemPowerSwitch.Value, 'On')) 475 | app.SolarFarmLamp.Color = 'green'; 476 | fwrite(app.Bt, "11"); 477 | app.solarFarmS = 1; 478 | readData(app); 479 | else 480 | app.SolarFarmLamp.Color = 'red'; 481 | fwrite(app.Bt, "10"); 482 | app.solarFarmS = 0; 483 | app.solarFarmPower.Value = 0; 484 | app.solarFarmVoltage.Value = 0; 485 | app.solarFarmCurrent.Value = 0; 486 | app.VoltageGauge.Value = 0; 487 | app.CurrentGauge.Value = 0; 488 | app.PowerGauge.Value = 0; 489 | readData(app); 490 | end 491 | end 492 | 493 | % Value changed function: batterySwitch 494 | function batterySwitchValueChanged(app, event) 495 | value = app.batterySwitch.Value; 496 | disp("in battery tab"); 497 | if (strcmpi(value,'On') && strcmpi(app.SystemPowerSwitch.Value, 'On')) 498 | app.BatteryLamp.Color = 'green'; 499 | fwrite(app.Bt, "21"); 500 | app.batteryS = 1; 501 | disp("battery tab on"); 502 | readData(app); 503 | 504 | else 505 | app.BatteryLamp.Color = 'red'; 506 | fwrite(app.Bt, "20"); 507 | app.batteryS = 0; 508 | disp("battery tab off"); 509 | readData(app); 510 | end 511 | end 512 | 513 | % Value changed function: loadThreeSwitch 514 | function loadThreeSwitchValueChanged(app, event) 515 | value = app.loadThreeSwitch.Value; 516 | if (strcmpi(value,'On')) 517 | if (strcmpi(app.SystemPowerSwitch.Value, 'On')) 518 | app.loadThreeStatus.Color = 'green'; 519 | fwrite(app.Bt, "51"); 520 | app.threeS = 1; 521 | readData(app); 522 | end 523 | else 524 | app.loadThreeStatus.Color = 'red'; 525 | fwrite(app.Bt, "50"); 526 | app.threeS = 0; 527 | app.loadThreeVoltage.Value = 0; 528 | app.loadThreeCurrent.Value = 0; 529 | app.loadThreePower.Value = 0; 530 | app.loadThreeVGauge.Value = 0; 531 | app.loadThreeCGauge.Value = 0; 532 | app.loadThreePowerGauge.Value = 0; 533 | 534 | readData(app); 535 | end 536 | end 537 | 538 | % Value changed function: loadTwoSwitch 539 | function loadTwoSwitchValueChanged(app, event) 540 | value = app.loadTwoSwitch.Value; 541 | if (strcmpi(value,'On')) 542 | if (strcmpi(app.SystemPowerSwitch.Value, 'On')) 543 | app.loadTwoStatus.Color = 'green'; 544 | fwrite(app.Bt, "41"); 545 | app.twoS = 1; 546 | readData(app); 547 | end 548 | else 549 | app.loadTwoStatus.Color = 'red'; 550 | fwrite(app.Bt, "40"); 551 | app.twoS = 0; 552 | app.loadTwoPower.Value = 0; 553 | app.loadTwoVoltage.Value = 0; 554 | app.loadTwoCurrent.Value = 0; 555 | app.loadTwoVGauge.Value = 0; 556 | app.loadTwoCGauge.Value = 0; 557 | app.loadTwoPowerGauge.Value = 0; 558 | readData(app); 559 | end 560 | end 561 | 562 | % Button pushed function: solarFarmVGraphButton 563 | function solarFarmVGraphButtonPushed(app, event) 564 | 565 | if (ishandle(app.currentFigure)) 566 | close(app.currentFigure); 567 | end 568 | 569 | app.voltageFigure = uifigure; 570 | ax = uiaxes(app.voltageFigure); 571 | 572 | ax.Title.String = 'Solar Farm Voltage'; 573 | ax.Title.FontWeight = 'normal'; 574 | ax.XLabel.String = "Time (sec)"; 575 | ax.YLabel.String = "Voltage (V)"; 576 | ax.XLabel.FontSize = 12; 577 | ax.YLabel.FontSize = 12; 578 | ax.XLim = [0 60]; 579 | ax.YLim = [0 25]; 580 | ax.XTickMode = 'manual'; 581 | ax.XLimMode = 'manual'; 582 | ax.XTick = 0:15:60; 583 | 584 | while (ishandle(app.voltageFigure)) 585 | hold(ax, 'on'); 586 | fwrite(app.Bt, "9"); 587 | data = fgetl(app.Bt); 588 | [SFV,SFA,BV,twoV,threeV] = parseData(app, data); 589 | [SFV, SFA, SFP, BV, BC, twoV, twoP, twoA, threeV, threeP, threeA] = ADC(app, SFV, SFA, BV, twoV, threeV); 590 | assignData(app, SFV, SFA, SFP, BV, BC, twoV, twoA, twoP, threeV, threeA, threeP); 591 | 592 | try 593 | plot(ax, app.oneSecondCounter, app.solarFarmVoltage.Value, 'bo'); 594 | drawnow 595 | catch 596 | disp("SF Graph Error"); 597 | end 598 | 599 | 600 | if (app.oneSecondCounter >= 60) 601 | ax.cla; 602 | hold(ax, 'off'); 603 | app.oneSecondCounter = 0; 604 | end 605 | end 606 | end 607 | 608 | % Button pushed function: solarFarmCGraphButton 609 | function solarFarmCGraphButtonPushed(app, event) 610 | if (ishandle(app.voltageFigure)) 611 | close(app.voltageFigure); 612 | end 613 | 614 | app.currentFigure = uifigure; 615 | ax1 = uiaxes(app.currentFigure); 616 | ax1.Title.String = 'Solar Farm Current'; 617 | ax1.Title.FontWeight = 'normal'; 618 | ax1.XLabel.String = "Time (sec)"; 619 | ax1.YLabel.String = "Current (mA)"; 620 | ax1.XLabel.FontSize = 12; 621 | ax1.YLabel.FontSize = 12; 622 | ax1.XLim = [0 60]; 623 | ax1.YLim = [0 200]; 624 | ax1.XTickMode = 'manual'; 625 | ax1.XLimMode = 'manual'; 626 | ax1.XTick = 0:15:60; 627 | hold(ax1, 'on'); 628 | while (ishandle(app.currentFigure)) 629 | 630 | fwrite(app.Bt, "9"); 631 | data = fgetl(app.Bt); 632 | [SFV,SFA,BV,twoV,threeV] = parseData(app, data); 633 | [SFV, SFA, SFP, BV, BC, twoV, twoP, twoA, threeV, threeP, threeA] = ADC(app, SFV, SFA, BV, twoV, threeV); 634 | assignData(app, SFV, SFA, SFP, BV, BC, twoV, twoA, twoP, threeV, threeA, threeP); 635 | 636 | try 637 | 638 | plot(ax1, app.oneSecondCounter, app.solarFarmCurrent.Value, 'bo'); 639 | drawnow 640 | catch 641 | end 642 | 643 | if (app.oneSecondCounter >= 60) 644 | ax1.cla; 645 | hold(ax1, 'off'); 646 | app.oneSecondCounter = 0; 647 | end 648 | end 649 | end 650 | 651 | % Button pushed function: batteryVGraphButton 652 | function batteryVGraphButtonPushed(app, event) 653 | 654 | if (ishandle(app.currentFigure)) 655 | close(app.currentFigure); 656 | end 657 | 658 | if (ishandle(app.voltageFigure)) 659 | close(app.voltageFigure); 660 | end 661 | 662 | app.voltageFigure = uifigure; 663 | ax1 = uiaxes(app.voltageFigure); 664 | ax1.Title.String = 'Battery Voltage'; 665 | ax1.Title.FontWeight = 'normal'; 666 | ax1.XLabel.String = "Time (sec)"; 667 | ax1.YLabel.String = "Voltage (V)"; 668 | ax1.XLabel.FontSize = 12; 669 | ax1.YLabel.FontSize = 12; 670 | ax1.XLim = [0 60]; 671 | ax1.YLim = [0 20]; 672 | ax1.XTickMode = 'manual'; 673 | ax1.XLimMode = 'manual'; 674 | ax1.XTick = 0:15:60; 675 | hold(ax1, 'on'); 676 | 677 | while (ishandle(app.voltageFigure)) 678 | 679 | fwrite(app.Bt, "9"); 680 | data = fgetl(app.Bt); 681 | [SFV,SFA,BV,twoV,threeV] = parseData(app, data); 682 | [SFV, SFA, SFP, BV, BC, twoV, twoP, twoA, threeV, threeP, threeA] = ADC(app, SFV, SFA, BV, twoV, threeV); 683 | assignData(app, SFV, SFA, SFP, BV, BC, twoV, twoA, twoP, threeV, threeA, threeP); 684 | graph(app, ax1, app.batteryVoltage.Value); 685 | 686 | end 687 | 688 | end 689 | 690 | % Callback function 691 | function batteryCGraphButtonPushed(app, event) 692 | if (ishandle(app.currentFigure)) 693 | close(app.currentFigure); 694 | end 695 | 696 | if (ishandle(app.voltageFigure)) 697 | close(app.voltageFigure); 698 | end 699 | app.currentFigure = uifigure; 700 | ax1 = uiaxes(app.currentFigure); 701 | ax1.Title.String = 'Battery Current'; 702 | ax1.Title.FontWeight = 'normal'; 703 | ax1.XLabel.String = "Time (sec)"; 704 | ax1.YLabel.String = "Current (mA)"; 705 | ax1.XLabel.FontSize = 12; 706 | ax1.YLabel.FontSize = 12; 707 | ax1.XLim = [0 60]; 708 | ax1.YLim = [0 7]; 709 | ax1.XTickMode = 'manual'; 710 | ax1.XLimMode = 'manual'; 711 | ax1.XTick = 0:15:60; 712 | hold(ax1, 'on'); 713 | 714 | while (ishandle(app.currentFigure)) 715 | 716 | fwrite(app.Bt, "9"); 717 | data = fgetl(app.Bt); 718 | [SFV,SFA,BV,twoV,threeV] = parseData(app, data); 719 | [SFV, SFA, SFP, BV, BC, twoV, twoP, twoA, threeV, threeP, threeA] = ADC(app, SFV, SFA, BV, twoV, threeV); 720 | assignData(app, SFV, SFA, SFP, BV, BC, twoV, twoA, twoP, threeV, threeA, threeP); 721 | 722 | graph(app, ax1, app.batteryPercent.Value); 723 | 724 | end 725 | end 726 | 727 | % Selection change function: TabGroup 728 | function TabGroupSelectionChanged(app, event) 729 | if (ishandle(app.currentFigure)) 730 | close(app.currentFigure); 731 | end 732 | 733 | if (ishandle(app.voltageFigure)) 734 | close(app.voltageFigure); 735 | end 736 | 737 | hold(app.UIAxes, 'off'); 738 | hold(app.loadTwoPowerGraph, 'off'); 739 | hold(app.loadThreePowerGraph, 'off'); 740 | 741 | app.UIAxes.cla; 742 | app.loadTwoPowerGraph.cla; 743 | app.loadThreePowerGraph.cla; 744 | 745 | disp("Changing tabs"); 746 | app.selectedTab = app.TabGroup.SelectedTab; 747 | app.validData = 0; 748 | 749 | if (app.selectedTab == app.SolarFarmTab) 750 | app.solarFarmT = 1; 751 | else 752 | app.solarFarmT = 0; 753 | end 754 | 755 | if (app.selectedTab == app.BatteryOutputTab) 756 | app.batteryT = 1; 757 | disp("battery tab selected"); 758 | else 759 | app.batteryT = 0; 760 | end 761 | 762 | if (app.selectedTab == app.loadTwo) 763 | app.twoT = 1; 764 | else 765 | app.twoT = 0; 766 | end 767 | 768 | if (app.selectedTab == app.loadThree) 769 | app.threeT = 1; 770 | else 771 | app.threeT = 0; 772 | end 773 | 774 | readData(app); 775 | end 776 | 777 | % Button pushed function: loadTwoVGraphButton 778 | function loadTwoVGraphButtonPushed(app, event) 779 | if (ishandle(app.currentFigure)) 780 | close(app.currentFigure); 781 | end 782 | 783 | if (ishandle(app.voltageFigure)) 784 | close(app.voltageFigure); 785 | end 786 | 787 | app.currentFigure = uifigure; 788 | ax1 = uiaxes(app.currentFigure); 789 | ax1.Title.String = 'DC Load Voltage Graph'; 790 | ax1.Title.FontWeight = 'normal'; 791 | ax1.XLabel.String = "Time (sec)"; 792 | ax1.YLabel.String = "Voltage (V)"; 793 | ax1.XLabel.FontSize = 12; 794 | ax1.YLabel.FontSize = 12; 795 | ax1.XLim = [0 60]; 796 | ax1.YLim = [0 7]; 797 | ax1.XTickMode = 'manual'; 798 | ax1.XLimMode = 'manual'; 799 | ax1.XTick = 0:15:60; 800 | hold(ax1, 'on'); 801 | 802 | while (ishandle(app.currentFigure)) 803 | 804 | fwrite(app.Bt, "9"); 805 | data = fgetl(app.Bt); 806 | [SFV,SFA,BV,twoV,threeV] = parseData(app, data); 807 | [SFV, SFA, SFP, BV, BC, twoV, twoP, twoA, threeV, threeP, threeA] = ADC(app, SFV, SFA, BV, twoV, threeV); 808 | assignData(app, SFV, SFA, SFP, BV, BC, twoV, twoA, twoP, threeV, threeA, threeP); 809 | 810 | graph(app, ax1, app.batteryPercent.Value); 811 | 812 | end 813 | end 814 | 815 | % Button pushed function: loadTwoCGraphButton 816 | function loadTwoCGraphButtonPushed(app, event) 817 | if (ishandle(app.currentFigure)) 818 | close(app.currentFigure); 819 | end 820 | 821 | if (ishandle(app.voltageFigure)) 822 | close(app.voltageFigure); 823 | end 824 | app.currentFigure = uifigure; 825 | ax1 = uiaxes(app.currentFigure); 826 | ax1.Title.String = 'DC Load Current Graph'; 827 | ax1.Title.FontWeight = 'normal'; 828 | ax1.XLabel.String = "Time (sec)"; 829 | ax1.YLabel.String = "Current (mA)"; 830 | ax1.XLabel.FontSize = 12; 831 | ax1.YLabel.FontSize = 12; 832 | ax1.XLim = [0 60]; 833 | ax1.YLim = [0 7]; 834 | ax1.XTickMode = 'manual'; 835 | ax1.XLimMode = 'manual'; 836 | ax1.XTick = 0:15:60; 837 | hold(ax1, 'on'); 838 | 839 | while (ishandle(app.currentFigure)) 840 | 841 | fwrite(app.Bt, "9"); 842 | data = fgetl(app.Bt); 843 | [SFV,SFA,BV,twoV,threeV] = parseData(app, data); 844 | [SFV, SFA, SFP, BV, BC, twoV, twoP, twoA, threeV, threeP, threeA] = ADC(app, SFV, SFA, BV, twoV, threeV); 845 | assignData(app, SFV, SFA, SFP, BV, BC, twoV, twoA, twoP, threeV, threeA, threeP); 846 | 847 | graph(app, ax1, app.batteryPercent.Value); 848 | 849 | end 850 | end 851 | 852 | % Button pushed function: loadThreeVGraphButton 853 | function loadThreeVGraphButtonPushed(app, event) 854 | if (ishandle(app.currentFigure)) 855 | close(app.currentFigure); 856 | end 857 | 858 | if (ishandle(app.voltageFigure)) 859 | close(app.voltageFigure); 860 | end 861 | app.currentFigure = uifigure; 862 | ax1 = uiaxes(app.currentFigure); 863 | ax1.Title.String = 'AC Load Voltage Graph'; 864 | ax1.Title.FontWeight = 'normal'; 865 | ax1.XLabel.String = "Time (sec)"; 866 | ax1.YLabel.String = "Voltage (V)"; 867 | ax1.XLabel.FontSize = 12; 868 | ax1.YLabel.FontSize = 12; 869 | ax1.XLim = [0 60]; 870 | ax1.YLim = [0 7]; 871 | ax1.XTickMode = 'manual'; 872 | ax1.XLimMode = 'manual'; 873 | ax1.XTick = 0:15:60; 874 | hold(ax1, 'on'); 875 | 876 | while (ishandle(app.currentFigure)) 877 | 878 | fwrite(app.Bt, "9"); 879 | data = fgetl(app.Bt); 880 | [SFV,SFA,BV,twoV,threeV] = parseData(app, data); 881 | [SFV, SFA, SFP, BV, BC, twoV, twoP, twoA, threeV, threeP, threeA] = ADC(app, SFV, SFA, BV, twoV, threeV); 882 | assignData(app, SFV, SFA, SFP, BV, BC, twoV, twoA, twoP, threeV, threeA, threeP); 883 | 884 | graph(app, ax1, app.batteryPercent.Value); 885 | 886 | end 887 | end 888 | 889 | % Button pushed function: loadThreeCGraphButton 890 | function loadThreeCGraphButtonPushed(app, event) 891 | if (ishandle(app.currentFigure)) 892 | close(app.currentFigure); 893 | end 894 | 895 | if (ishandle(app.voltageFigure)) 896 | close(app.voltageFigure); 897 | end 898 | app.currentFigure = uifigure; 899 | ax1 = uiaxes(app.currentFigure); 900 | ax1.Title.String = 'AC Load Current Graph'; 901 | ax1.Title.FontWeight = 'normal'; 902 | ax1.XLabel.String = "Time (sec)"; 903 | ax1.YLabel.String = "Current (A)"; 904 | ax1.XLabel.FontSize = 12; 905 | ax1.YLabel.FontSize = 12; 906 | ax1.XLim = [0 60]; 907 | ax1.YLim = [0 7]; 908 | ax1.XTickMode = 'manual'; 909 | ax1.XLimMode = 'manual'; 910 | ax1.XTick = 0:15:60; 911 | hold(ax1, 'on'); 912 | 913 | while (ishandle(app.currentFigure)) 914 | 915 | fwrite(app.Bt, "9"); 916 | data = fgetl(app.Bt); 917 | [SFV,SFA,BV,twoV,threeV] = parseData(app, data); 918 | [SFV, SFA, SFP, BV, BC, twoV, twoP, twoA, threeV, threeP, threeA] = ADC(app, SFV, SFA, BV, twoV, threeV); 919 | assignData(app, SFV, SFA, SFP, BV, BC, twoV, twoA, twoP, threeV, threeA, threeP); 920 | 921 | graph(app, ax1, app.batteryPercent.Value); 922 | 923 | end 924 | end 925 | end 926 | 927 | % App initialization and construction 928 | methods (Access = private) 929 | 930 | % Create UIFigure and components 931 | function createComponents(app) 932 | 933 | % Create UIFigure 934 | app.UIFigure = uifigure; 935 | app.UIFigure.Colormap = [0.2431 0.149 0.6588;0.251 0.1647 0.7059;0.2588 0.1804 0.7529;0.2627 0.1961 0.7961;0.2706 0.2157 0.8353;0.2745 0.2353 0.8706;0.2784 0.2549 0.898;0.2784 0.2784 0.9216;0.2824 0.302 0.9412;0.2824 0.3216 0.9569;0.2784 0.3451 0.9725;0.2745 0.3686 0.9843;0.2706 0.3882 0.9922;0.2588 0.4118 0.9961;0.2431 0.4353 1;0.2196 0.4588 0.9961;0.1961 0.4863 0.9882;0.1843 0.5059 0.9804;0.1804 0.5294 0.9686;0.1765 0.549 0.9529;0.1686 0.5686 0.9373;0.1529 0.5922 0.9216;0.1451 0.6078 0.9098;0.1373 0.6275 0.898;0.1255 0.6471 0.8902;0.1098 0.6627 0.8745;0.0941 0.6784 0.8588;0.0706 0.6941 0.8392;0.0314 0.7098 0.8157;0.0039 0.7216 0.7922;0.0078 0.7294 0.7647;0.0431 0.7412 0.7412;0.098 0.749 0.7137;0.1412 0.7569 0.6824;0.1725 0.7686 0.6549;0.1922 0.7765 0.6235;0.2157 0.7843 0.5922;0.2471 0.7922 0.5569;0.2902 0.7961 0.5176;0.3412 0.8 0.4784;0.3922 0.8039 0.4353;0.4471 0.8039 0.3922;0.5059 0.8 0.349;0.5608 0.7961 0.3059;0.6157 0.7882 0.2627;0.6706 0.7804 0.2235;0.7255 0.7686 0.1922;0.7725 0.7608 0.1647;0.8196 0.749 0.1529;0.8627 0.7412 0.1608;0.902 0.7333 0.1765;0.9412 0.7294 0.2118;0.9725 0.7294 0.2392;0.9961 0.7451 0.2353;0.9961 0.7647 0.2196;0.9961 0.7882 0.2039;0.9882 0.8118 0.1882;0.9804 0.8392 0.1765;0.9686 0.8627 0.1647;0.9608 0.8902 0.1529;0.9608 0.9137 0.1412;0.9647 0.9373 0.1255;0.9686 0.9608 0.1059;0.9765 0.9843 0.0824]; 936 | app.UIFigure.Position = [100 100 768 562]; 937 | app.UIFigure.Name = 'UI Figure'; 938 | 939 | % Create TabGroup 940 | app.TabGroup = uitabgroup(app.UIFigure); 941 | app.TabGroup.SelectionChangedFcn = createCallbackFcn(app, @TabGroupSelectionChanged, true); 942 | app.TabGroup.Position = [160 1 609 563]; 943 | 944 | % Create SolarFarmTab 945 | app.SolarFarmTab = uitab(app.TabGroup); 946 | app.SolarFarmTab.Title = 'Solar Farm'; 947 | app.SolarFarmTab.Scrollable = 'on'; 948 | 949 | % Create PowerSwitchLabel 950 | app.PowerSwitchLabel = uilabel(app.SolarFarmTab); 951 | app.PowerSwitchLabel.HorizontalAlignment = 'center'; 952 | app.PowerSwitchLabel.FontWeight = 'bold'; 953 | app.PowerSwitchLabel.Position = [21 330 42 22]; 954 | app.PowerSwitchLabel.Text = 'Power'; 955 | 956 | % Create solarFarmSwitch 957 | app.solarFarmSwitch = uiswitch(app.SolarFarmTab, 'toggle'); 958 | app.solarFarmSwitch.ValueChangedFcn = createCallbackFcn(app, @solarFarmSwitchValueChanged, true); 959 | app.solarFarmSwitch.BusyAction = 'cancel'; 960 | app.solarFarmSwitch.Interruptible = 'off'; 961 | app.solarFarmSwitch.FontWeight = 'bold'; 962 | app.solarFarmSwitch.Position = [28 388 26 60]; 963 | 964 | % Create SolarFarmDetailsLabel 965 | app.SolarFarmDetailsLabel = uilabel(app.SolarFarmTab); 966 | app.SolarFarmDetailsLabel.FontSize = 16; 967 | app.SolarFarmDetailsLabel.FontWeight = 'bold'; 968 | app.SolarFarmDetailsLabel.Position = [134 476 146 22]; 969 | app.SolarFarmDetailsLabel.Text = 'Solar Farm Details'; 970 | 971 | % Create solarFarmCurrent 972 | app.solarFarmCurrent = uieditfield(app.SolarFarmTab, 'numeric'); 973 | app.solarFarmCurrent.Position = [182 366 100 22]; 974 | 975 | % Create VoltageVEditField_7Label 976 | app.VoltageVEditField_7Label = uilabel(app.SolarFarmTab); 977 | app.VoltageVEditField_7Label.HorizontalAlignment = 'right'; 978 | app.VoltageVEditField_7Label.Position = [102 401 65 22]; 979 | app.VoltageVEditField_7Label.Text = 'Voltage (V)'; 980 | 981 | % Create solarFarmVoltage 982 | app.solarFarmVoltage = uieditfield(app.SolarFarmTab, 'numeric'); 983 | app.solarFarmVoltage.Position = [182 401 100 22]; 984 | 985 | % Create PowerWEditField_7Label 986 | app.PowerWEditField_7Label = uilabel(app.SolarFarmTab); 987 | app.PowerWEditField_7Label.HorizontalAlignment = 'right'; 988 | app.PowerWEditField_7Label.Position = [105 436 62 22]; 989 | app.PowerWEditField_7Label.Text = 'Power (W)'; 990 | 991 | % Create solarFarmPower 992 | app.solarFarmPower = uieditfield(app.SolarFarmTab, 'numeric'); 993 | app.solarFarmPower.Position = [182 436 100 22]; 994 | 995 | % Create CurrentmAEditField_2Label_2 996 | app.CurrentmAEditField_2Label_2 = uilabel(app.SolarFarmTab); 997 | app.CurrentmAEditField_2Label_2.HorizontalAlignment = 'right'; 998 | app.CurrentmAEditField_2Label_2.Position = [88 366 75 22]; 999 | app.CurrentmAEditField_2Label_2.Text = 'Current (mA)'; 1000 | 1001 | % Create VoltageGaugeLabel 1002 | app.VoltageGaugeLabel = uilabel(app.SolarFarmTab); 1003 | app.VoltageGaugeLabel.BackgroundColor = [1 1 1]; 1004 | app.VoltageGaugeLabel.HorizontalAlignment = 'center'; 1005 | app.VoltageGaugeLabel.Position = [103 28 46 22]; 1006 | app.VoltageGaugeLabel.Text = 'Voltage'; 1007 | 1008 | % Create VoltageGauge 1009 | app.VoltageGauge = uigauge(app.SolarFarmTab, 'circular'); 1010 | app.VoltageGauge.Limits = [0 20]; 1011 | app.VoltageGauge.MajorTicks = [0 5 10 15 20 25]; 1012 | app.VoltageGauge.ScaleColors = [1 0 0;1 1 0;0 1 0;0.902 0.902 0.902]; 1013 | app.VoltageGauge.ScaleColorLimits = [18 20;16 18;13 16;0 13]; 1014 | app.VoltageGauge.Position = [47 65 159 159]; 1015 | 1016 | % Create CurrentGaugeLabel 1017 | app.CurrentGaugeLabel = uilabel(app.SolarFarmTab); 1018 | app.CurrentGaugeLabel.HorizontalAlignment = 'center'; 1019 | app.CurrentGaugeLabel.Position = [279 27 46 22]; 1020 | app.CurrentGaugeLabel.Text = 'Current'; 1021 | 1022 | % Create CurrentGauge 1023 | app.CurrentGauge = uigauge(app.SolarFarmTab, 'circular'); 1024 | app.CurrentGauge.Limits = [0 6]; 1025 | app.CurrentGauge.MajorTicks = [0 1 2 3 4 5 6]; 1026 | app.CurrentGauge.ScaleColors = [1 0 0;1 1 0;0 1 0;0.902 0.902 0.902]; 1027 | app.CurrentGauge.ScaleColorLimits = [5.4 6;5 5.4;3 5;0 3]; 1028 | app.CurrentGauge.Position = [223 64 159 159]; 1029 | 1030 | % Create PowerGaugeLabel 1031 | app.PowerGaugeLabel = uilabel(app.SolarFarmTab); 1032 | app.PowerGaugeLabel.HorizontalAlignment = 'center'; 1033 | app.PowerGaugeLabel.Position = [464 27 40 22]; 1034 | app.PowerGaugeLabel.Text = 'Power'; 1035 | 1036 | % Create PowerGauge 1037 | app.PowerGauge = uigauge(app.SolarFarmTab, 'circular'); 1038 | app.PowerGauge.Limits = [0 125]; 1039 | app.PowerGauge.MajorTicks = [0 20 40 60 80 100 120]; 1040 | app.PowerGauge.Position = [404 64 160 160]; 1041 | 1042 | % Create UIAxes 1043 | app.UIAxes = uiaxes(app.SolarFarmTab); 1044 | title(app.UIAxes, 'Power') 1045 | xlabel(app.UIAxes, 'Time (sec)') 1046 | ylabel(app.UIAxes, 'Power (W)') 1047 | app.UIAxes.PlotBoxAspectRatio = [1 0.509881422924901 0.509881422924901]; 1048 | app.UIAxes.XLim = [0 60]; 1049 | app.UIAxes.YLim = [0 250]; 1050 | app.UIAxes.XTick = [0 15 30 45 60]; 1051 | app.UIAxes.XTickLabel = {'0'; '15'; '30'; '45'; '60'}; 1052 | app.UIAxes.YTick = [0 50 100 150 200 250]; 1053 | app.UIAxes.YTickLabel = {'0'; '50'; '100'; '150'; '200'; '250'}; 1054 | app.UIAxes.Position = [301 310 300 215]; 1055 | 1056 | % Create solarFarmVGraphButton 1057 | app.solarFarmVGraphButton = uibutton(app.SolarFarmTab, 'push'); 1058 | app.solarFarmVGraphButton.ButtonPushedFcn = createCallbackFcn(app, @solarFarmVGraphButtonPushed, true); 1059 | app.solarFarmVGraphButton.Position = [77 231 100 22]; 1060 | app.solarFarmVGraphButton.Text = 'Graph'; 1061 | 1062 | % Create solarFarmCGraphButton 1063 | app.solarFarmCGraphButton = uibutton(app.SolarFarmTab, 'push'); 1064 | app.solarFarmCGraphButton.ButtonPushedFcn = createCallbackFcn(app, @solarFarmCGraphButtonPushed, true); 1065 | app.solarFarmCGraphButton.Position = [252 231 100 22]; 1066 | app.solarFarmCGraphButton.Text = 'Graph'; 1067 | 1068 | % Create BatteryOutputTab 1069 | app.BatteryOutputTab = uitab(app.TabGroup); 1070 | app.BatteryOutputTab.Title = 'Battery Output'; 1071 | app.BatteryOutputTab.Interruptible = 'off'; 1072 | 1073 | % Create BatteryDetailsLabel 1074 | app.BatteryDetailsLabel = uilabel(app.BatteryOutputTab); 1075 | app.BatteryDetailsLabel.FontSize = 16; 1076 | app.BatteryDetailsLabel.FontWeight = 'bold'; 1077 | app.BatteryDetailsLabel.Position = [161 476 118 22]; 1078 | app.BatteryDetailsLabel.Text = 'Battery Details'; 1079 | 1080 | % Create PowerSwitch_2Label 1081 | app.PowerSwitch_2Label = uilabel(app.BatteryOutputTab); 1082 | app.PowerSwitch_2Label.HorizontalAlignment = 'center'; 1083 | app.PowerSwitch_2Label.FontWeight = 'bold'; 1084 | app.PowerSwitch_2Label.Position = [21 330 42 22]; 1085 | app.PowerSwitch_2Label.Text = 'Power'; 1086 | 1087 | % Create batterySwitch 1088 | app.batterySwitch = uiswitch(app.BatteryOutputTab, 'toggle'); 1089 | app.batterySwitch.ValueChangedFcn = createCallbackFcn(app, @batterySwitchValueChanged, true); 1090 | app.batterySwitch.FontWeight = 'bold'; 1091 | app.batterySwitch.Position = [28 388 26 60]; 1092 | 1093 | % Create BatteryPercentLabel 1094 | app.BatteryPercentLabel = uilabel(app.BatteryOutputTab); 1095 | app.BatteryPercentLabel.HorizontalAlignment = 'right'; 1096 | app.BatteryPercentLabel.Position = [85 436 110 22]; 1097 | app.BatteryPercentLabel.Text = 'Battery Percent (%)'; 1098 | 1099 | % Create batteryPercent 1100 | app.batteryPercent = uieditfield(app.BatteryOutputTab, 'numeric'); 1101 | app.batteryPercent.Position = [210 436 100 22]; 1102 | 1103 | % Create VoltageVEditField_8Label 1104 | app.VoltageVEditField_8Label = uilabel(app.BatteryOutputTab); 1105 | app.VoltageVEditField_8Label.HorizontalAlignment = 'right'; 1106 | app.VoltageVEditField_8Label.Position = [130 402 65 22]; 1107 | app.VoltageVEditField_8Label.Text = 'Voltage (V)'; 1108 | 1109 | % Create batteryVoltage 1110 | app.batteryVoltage = uieditfield(app.BatteryOutputTab, 'numeric'); 1111 | app.batteryVoltage.Position = [210 402 100 22]; 1112 | 1113 | % Create BatteryChargeGaugeLabel 1114 | app.BatteryChargeGaugeLabel = uilabel(app.BatteryOutputTab); 1115 | app.BatteryChargeGaugeLabel.HorizontalAlignment = 'center'; 1116 | app.BatteryChargeGaugeLabel.FontWeight = 'bold'; 1117 | app.BatteryChargeGaugeLabel.Position = [258 26 92 22]; 1118 | app.BatteryChargeGaugeLabel.Text = 'Battery Charge'; 1119 | 1120 | % Create BatteryChargeGauge 1121 | app.BatteryChargeGauge = uigauge(app.BatteryOutputTab, 'semicircular'); 1122 | app.BatteryChargeGauge.ScaleColors = [1 0 0;1 1 0;0 1 0]; 1123 | app.BatteryChargeGauge.ScaleColorLimits = [20 50;50 80;80 100]; 1124 | app.BatteryChargeGauge.Position = [115 52 379 205]; 1125 | 1126 | % Create VoltageGauge_2Label 1127 | app.VoltageGauge_2Label = uilabel(app.BatteryOutputTab); 1128 | app.VoltageGauge_2Label.BackgroundColor = [1 1 1]; 1129 | app.VoltageGauge_2Label.HorizontalAlignment = 'center'; 1130 | app.VoltageGauge_2Label.Position = [437 281 46 22]; 1131 | app.VoltageGauge_2Label.Text = 'Voltage'; 1132 | 1133 | % Create batteryVGauge 1134 | app.batteryVGauge = uigauge(app.BatteryOutputTab, 'circular'); 1135 | app.batteryVGauge.Limits = [0 20]; 1136 | app.batteryVGauge.MajorTicks = [0 5 10 15 20 25]; 1137 | app.batteryVGauge.ScaleColors = [1 0 0;1 1 0;0 1 0;0.902 0.902 0.902]; 1138 | app.batteryVGauge.ScaleColorLimits = [18 20;16 18;13 16;0 13]; 1139 | app.batteryVGauge.Position = [381 318 159 159]; 1140 | 1141 | % Create batteryVGraphButton 1142 | app.batteryVGraphButton = uibutton(app.BatteryOutputTab, 'push'); 1143 | app.batteryVGraphButton.ButtonPushedFcn = createCallbackFcn(app, @batteryVGraphButtonPushed, true); 1144 | app.batteryVGraphButton.Position = [411 484 100 22]; 1145 | app.batteryVGraphButton.Text = 'Graph'; 1146 | 1147 | % Create loadTwo 1148 | app.loadTwo = uitab(app.TabGroup); 1149 | app.loadTwo.Title = '12V DC Load'; 1150 | 1151 | % Create loadTwoPowerGraph 1152 | app.loadTwoPowerGraph = uiaxes(app.loadTwo); 1153 | title(app.loadTwoPowerGraph, 'Power') 1154 | xlabel(app.loadTwoPowerGraph, 'Time (sec)') 1155 | ylabel(app.loadTwoPowerGraph, 'Power (W)') 1156 | app.loadTwoPowerGraph.PlotBoxAspectRatio = [1 0.65948275862069 0.65948275862069]; 1157 | app.loadTwoPowerGraph.FontSize = 14; 1158 | app.loadTwoPowerGraph.XLim = [0 60]; 1159 | app.loadTwoPowerGraph.YLim = [0 50]; 1160 | app.loadTwoPowerGraph.XTick = [0 15 30 45 60]; 1161 | app.loadTwoPowerGraph.XTickLabel = {'0'; '15'; '30'; '45'; '60'}; 1162 | app.loadTwoPowerGraph.YTick = [0 10 20 30 40 50]; 1163 | app.loadTwoPowerGraph.YTickLabel = {'0'; '10'; '20'; '30'; '40'; '50'}; 1164 | app.loadTwoPowerGraph.Position = [301 288 290 220]; 1165 | 1166 | % Create VDCLoadLabel_2 1167 | app.VDCLoadLabel_2 = uilabel(app.loadTwo); 1168 | app.VDCLoadLabel_2.FontSize = 16; 1169 | app.VDCLoadLabel_2.FontWeight = 'bold'; 1170 | app.VDCLoadLabel_2.Position = [148 476 104 22]; 1171 | app.VDCLoadLabel_2.Text = '12V DC Load'; 1172 | 1173 | % Create PowerSwitch_6Label 1174 | app.PowerSwitch_6Label = uilabel(app.loadTwo); 1175 | app.PowerSwitch_6Label.HorizontalAlignment = 'center'; 1176 | app.PowerSwitch_6Label.FontWeight = 'bold'; 1177 | app.PowerSwitch_6Label.Position = [21 334 42 22]; 1178 | app.PowerSwitch_6Label.Text = 'Power'; 1179 | 1180 | % Create loadTwoSwitch 1181 | app.loadTwoSwitch = uiswitch(app.loadTwo, 'toggle'); 1182 | app.loadTwoSwitch.ValueChangedFcn = createCallbackFcn(app, @loadTwoSwitchValueChanged, true); 1183 | app.loadTwoSwitch.FontWeight = 'bold'; 1184 | app.loadTwoSwitch.Position = [29 392 25 57]; 1185 | 1186 | % Create VoltageVEditField_6Label 1187 | app.VoltageVEditField_6Label = uilabel(app.loadTwo); 1188 | app.VoltageVEditField_6Label.HorizontalAlignment = 'right'; 1189 | app.VoltageVEditField_6Label.Position = [102 400 65 22]; 1190 | app.VoltageVEditField_6Label.Text = 'Voltage (V)'; 1191 | 1192 | % Create loadTwoVoltage 1193 | app.loadTwoVoltage = uieditfield(app.loadTwo, 'numeric'); 1194 | app.loadTwoVoltage.Position = [182 400 100 22]; 1195 | 1196 | % Create CurrentmAEditField_6Label 1197 | app.CurrentmAEditField_6Label = uilabel(app.loadTwo); 1198 | app.CurrentmAEditField_6Label.HorizontalAlignment = 'right'; 1199 | app.CurrentmAEditField_6Label.Position = [88 366 75 22]; 1200 | app.CurrentmAEditField_6Label.Text = 'Current (mA)'; 1201 | 1202 | % Create loadTwoCurrent 1203 | app.loadTwoCurrent = uieditfield(app.loadTwo, 'numeric'); 1204 | app.loadTwoCurrent.Position = [182 364 100 22]; 1205 | 1206 | % Create PowerWEditField_6Label 1207 | app.PowerWEditField_6Label = uilabel(app.loadTwo); 1208 | app.PowerWEditField_6Label.HorizontalAlignment = 'right'; 1209 | app.PowerWEditField_6Label.Position = [105 436 62 22]; 1210 | app.PowerWEditField_6Label.Text = 'Power (W)'; 1211 | 1212 | % Create loadTwoPower 1213 | app.loadTwoPower = uieditfield(app.loadTwo, 'numeric'); 1214 | app.loadTwoPower.Position = [182 436 100 22]; 1215 | 1216 | % Create ResistanceLabel_3 1217 | app.ResistanceLabel_3 = uilabel(app.loadTwo); 1218 | app.ResistanceLabel_3.HorizontalAlignment = 'right'; 1219 | app.ResistanceLabel_3.Position = [78 328 85 22]; 1220 | app.ResistanceLabel_3.Text = 'Resistance (?)'; 1221 | 1222 | % Create loadTwoResistance 1223 | app.loadTwoResistance = uieditfield(app.loadTwo, 'numeric'); 1224 | app.loadTwoResistance.Limits = [0 Inf]; 1225 | app.loadTwoResistance.Position = [182 328 100 22]; 1226 | app.loadTwoResistance.Value = 15; 1227 | 1228 | % Create VoltageGauge_3Label_2 1229 | app.VoltageGauge_3Label_2 = uilabel(app.loadTwo); 1230 | app.VoltageGauge_3Label_2.BackgroundColor = [1 1 1]; 1231 | app.VoltageGauge_3Label_2.HorizontalAlignment = 'center'; 1232 | app.VoltageGauge_3Label_2.Position = [103 28 46 22]; 1233 | app.VoltageGauge_3Label_2.Text = 'Voltage'; 1234 | 1235 | % Create loadTwoVGauge 1236 | app.loadTwoVGauge = uigauge(app.loadTwo, 'circular'); 1237 | app.loadTwoVGauge.Limits = [0 20]; 1238 | app.loadTwoVGauge.MajorTicks = [0 5 10 15 20 25]; 1239 | app.loadTwoVGauge.ScaleColors = [1 0 0;1 1 0;0 1 0;0.902 0.902 0.902]; 1240 | app.loadTwoVGauge.ScaleColorLimits = [18 20;16 18;13 16;0 13]; 1241 | app.loadTwoVGauge.Position = [47 65 159 159]; 1242 | 1243 | % Create CurrentGauge_3Label_2 1244 | app.CurrentGauge_3Label_2 = uilabel(app.loadTwo); 1245 | app.CurrentGauge_3Label_2.HorizontalAlignment = 'center'; 1246 | app.CurrentGauge_3Label_2.Position = [279 27 46 22]; 1247 | app.CurrentGauge_3Label_2.Text = 'Current'; 1248 | 1249 | % Create loadTwoCGauge 1250 | app.loadTwoCGauge = uigauge(app.loadTwo, 'circular'); 1251 | app.loadTwoCGauge.Limits = [0 6]; 1252 | app.loadTwoCGauge.MajorTicks = [0 1 2 3 4 5 6]; 1253 | app.loadTwoCGauge.ScaleColors = [1 0 0;1 1 0;0 1 0;0.902 0.902 0.902]; 1254 | app.loadTwoCGauge.ScaleColorLimits = [5.4 6;5 5.4;3 5;0 3]; 1255 | app.loadTwoCGauge.Position = [223 64 159 159]; 1256 | 1257 | % Create PowerGauge_3Label_2 1258 | app.PowerGauge_3Label_2 = uilabel(app.loadTwo); 1259 | app.PowerGauge_3Label_2.HorizontalAlignment = 'center'; 1260 | app.PowerGauge_3Label_2.Position = [464 27 40 22]; 1261 | app.PowerGauge_3Label_2.Text = 'Power'; 1262 | 1263 | % Create loadTwoPowerGauge 1264 | app.loadTwoPowerGauge = uigauge(app.loadTwo, 'circular'); 1265 | app.loadTwoPowerGauge.Limits = [0 80]; 1266 | app.loadTwoPowerGauge.MajorTicks = [0 20 40 60 80 100 120]; 1267 | app.loadTwoPowerGauge.Position = [404 64 160 160]; 1268 | 1269 | % Create loadTwoVGraphButton 1270 | app.loadTwoVGraphButton = uibutton(app.loadTwo, 'push'); 1271 | app.loadTwoVGraphButton.ButtonPushedFcn = createCallbackFcn(app, @loadTwoVGraphButtonPushed, true); 1272 | app.loadTwoVGraphButton.Position = [77 231 100 22]; 1273 | app.loadTwoVGraphButton.Text = 'Graph'; 1274 | 1275 | % Create loadTwoCGraphButton 1276 | app.loadTwoCGraphButton = uibutton(app.loadTwo, 'push'); 1277 | app.loadTwoCGraphButton.ButtonPushedFcn = createCallbackFcn(app, @loadTwoCGraphButtonPushed, true); 1278 | app.loadTwoCGraphButton.Position = [252 231 100 22]; 1279 | app.loadTwoCGraphButton.Text = 'Graph'; 1280 | 1281 | % Create loadThree 1282 | app.loadThree = uitab(app.TabGroup); 1283 | app.loadThree.Title = '24V DC Load'; 1284 | 1285 | % Create loadThreePowerGraph 1286 | app.loadThreePowerGraph = uiaxes(app.loadThree); 1287 | title(app.loadThreePowerGraph, 'Power') 1288 | xlabel(app.loadThreePowerGraph, 'Time (sec)') 1289 | ylabel(app.loadThreePowerGraph, 'Power (W)') 1290 | app.loadThreePowerGraph.PlotBoxAspectRatio = [1 0.65948275862069 0.65948275862069]; 1291 | app.loadThreePowerGraph.FontSize = 14; 1292 | app.loadThreePowerGraph.XLim = [0 60]; 1293 | app.loadThreePowerGraph.YLim = [0 50]; 1294 | app.loadThreePowerGraph.XTick = [0 15 30 45 60]; 1295 | app.loadThreePowerGraph.XTickLabel = {'0'; '15'; '30'; '45'; '60'}; 1296 | app.loadThreePowerGraph.YTick = [0 10 20 30 40 50]; 1297 | app.loadThreePowerGraph.YTickLabel = {'0'; '10'; '20'; '30'; '40'; '50'}; 1298 | app.loadThreePowerGraph.Position = [301 288 290 220]; 1299 | 1300 | % Create VDCLoadLabel_3 1301 | app.VDCLoadLabel_3 = uilabel(app.loadThree); 1302 | app.VDCLoadLabel_3.FontSize = 16; 1303 | app.VDCLoadLabel_3.FontWeight = 'bold'; 1304 | app.VDCLoadLabel_3.Position = [149 476 104 22]; 1305 | app.VDCLoadLabel_3.Text = '24V DC Load'; 1306 | 1307 | % Create PowerSwitch_5Label 1308 | app.PowerSwitch_5Label = uilabel(app.loadThree); 1309 | app.PowerSwitch_5Label.HorizontalAlignment = 'center'; 1310 | app.PowerSwitch_5Label.FontWeight = 'bold'; 1311 | app.PowerSwitch_5Label.Position = [22 329 42 22]; 1312 | app.PowerSwitch_5Label.Text = 'Power'; 1313 | 1314 | % Create loadThreeSwitch 1315 | app.loadThreeSwitch = uiswitch(app.loadThree, 'toggle'); 1316 | app.loadThreeSwitch.ValueChangedFcn = createCallbackFcn(app, @loadThreeSwitchValueChanged, true); 1317 | app.loadThreeSwitch.FontWeight = 'bold'; 1318 | app.loadThreeSwitch.Position = [29 387 26 60]; 1319 | 1320 | % Create VoltageVEditField_5Label 1321 | app.VoltageVEditField_5Label = uilabel(app.loadThree); 1322 | app.VoltageVEditField_5Label.HorizontalAlignment = 'right'; 1323 | app.VoltageVEditField_5Label.Position = [102 400 65 22]; 1324 | app.VoltageVEditField_5Label.Text = 'Voltage (V)'; 1325 | 1326 | % Create loadThreeVoltage 1327 | app.loadThreeVoltage = uieditfield(app.loadThree, 'numeric'); 1328 | app.loadThreeVoltage.Position = [182 400 100 22]; 1329 | 1330 | % Create CurrentmAEditField_5Label 1331 | app.CurrentmAEditField_5Label = uilabel(app.loadThree); 1332 | app.CurrentmAEditField_5Label.HorizontalAlignment = 'right'; 1333 | app.CurrentmAEditField_5Label.Position = [88 366 75 22]; 1334 | app.CurrentmAEditField_5Label.Text = 'Current (mA)'; 1335 | 1336 | % Create loadThreeCurrent 1337 | app.loadThreeCurrent = uieditfield(app.loadThree, 'numeric'); 1338 | app.loadThreeCurrent.Position = [182 364 100 22]; 1339 | 1340 | % Create PowerWEditField_5Label 1341 | app.PowerWEditField_5Label = uilabel(app.loadThree); 1342 | app.PowerWEditField_5Label.HorizontalAlignment = 'right'; 1343 | app.PowerWEditField_5Label.Position = [105 436 62 22]; 1344 | app.PowerWEditField_5Label.Text = 'Power (W)'; 1345 | 1346 | % Create loadThreePower 1347 | app.loadThreePower = uieditfield(app.loadThree, 'numeric'); 1348 | app.loadThreePower.Position = [182 436 100 22]; 1349 | 1350 | % Create ResistanceLabel_4 1351 | app.ResistanceLabel_4 = uilabel(app.loadThree); 1352 | app.ResistanceLabel_4.HorizontalAlignment = 'right'; 1353 | app.ResistanceLabel_4.Position = [78 328 85 22]; 1354 | app.ResistanceLabel_4.Text = 'Resistance (?)'; 1355 | 1356 | % Create loadThreeResistance 1357 | app.loadThreeResistance = uieditfield(app.loadThree, 'numeric'); 1358 | app.loadThreeResistance.Position = [182 328 100 22]; 1359 | app.loadThreeResistance.Value = 40; 1360 | 1361 | % Create VoltageGauge_3Label_3 1362 | app.VoltageGauge_3Label_3 = uilabel(app.loadThree); 1363 | app.VoltageGauge_3Label_3.BackgroundColor = [1 1 1]; 1364 | app.VoltageGauge_3Label_3.HorizontalAlignment = 'center'; 1365 | app.VoltageGauge_3Label_3.Position = [103 28 46 22]; 1366 | app.VoltageGauge_3Label_3.Text = 'Voltage'; 1367 | 1368 | % Create loadThreeVGauge 1369 | app.loadThreeVGauge = uigauge(app.loadThree, 'circular'); 1370 | app.loadThreeVGauge.Limits = [0 20]; 1371 | app.loadThreeVGauge.MajorTicks = [0 5 10 15 20 25]; 1372 | app.loadThreeVGauge.ScaleColors = [1 0 0;1 1 0;0 1 0;0.902 0.902 0.902]; 1373 | app.loadThreeVGauge.ScaleColorLimits = [18 20;16 18;13 16;0 13]; 1374 | app.loadThreeVGauge.Position = [47 65 159 159]; 1375 | 1376 | % Create CurrentGauge_3Label_3 1377 | app.CurrentGauge_3Label_3 = uilabel(app.loadThree); 1378 | app.CurrentGauge_3Label_3.HorizontalAlignment = 'center'; 1379 | app.CurrentGauge_3Label_3.Position = [279 27 46 22]; 1380 | app.CurrentGauge_3Label_3.Text = 'Current'; 1381 | 1382 | % Create loadThreeCGauge 1383 | app.loadThreeCGauge = uigauge(app.loadThree, 'circular'); 1384 | app.loadThreeCGauge.Limits = [0 6]; 1385 | app.loadThreeCGauge.MajorTicks = [0 1 2 3 4 5 6]; 1386 | app.loadThreeCGauge.ScaleColors = [1 0 0;1 1 0;0 1 0;0.902 0.902 0.902]; 1387 | app.loadThreeCGauge.ScaleColorLimits = [5.4 6;5 5.4;3 5;0 3]; 1388 | app.loadThreeCGauge.Position = [223 64 159 159]; 1389 | 1390 | % Create PowerGauge_3Label_3 1391 | app.PowerGauge_3Label_3 = uilabel(app.loadThree); 1392 | app.PowerGauge_3Label_3.HorizontalAlignment = 'center'; 1393 | app.PowerGauge_3Label_3.Position = [464 27 40 22]; 1394 | app.PowerGauge_3Label_3.Text = 'Power'; 1395 | 1396 | % Create loadThreePowerGauge 1397 | app.loadThreePowerGauge = uigauge(app.loadThree, 'circular'); 1398 | app.loadThreePowerGauge.Limits = [0 80]; 1399 | app.loadThreePowerGauge.MajorTicks = [0 20 40 60 80 100 120]; 1400 | app.loadThreePowerGauge.Position = [404 64 160 160]; 1401 | 1402 | % Create loadThreeVGraphButton 1403 | app.loadThreeVGraphButton = uibutton(app.loadThree, 'push'); 1404 | app.loadThreeVGraphButton.ButtonPushedFcn = createCallbackFcn(app, @loadThreeVGraphButtonPushed, true); 1405 | app.loadThreeVGraphButton.Position = [77 231 100 22]; 1406 | app.loadThreeVGraphButton.Text = 'Graph'; 1407 | 1408 | % Create loadThreeCGraphButton 1409 | app.loadThreeCGraphButton = uibutton(app.loadThree, 'push'); 1410 | app.loadThreeCGraphButton.ButtonPushedFcn = createCallbackFcn(app, @loadThreeCGraphButtonPushed, true); 1411 | app.loadThreeCGraphButton.Position = [252 231 100 22]; 1412 | app.loadThreeCGraphButton.Text = 'Graph'; 1413 | 1414 | % Create MicrogridStatusPanel 1415 | app.MicrogridStatusPanel = uipanel(app.UIFigure); 1416 | app.MicrogridStatusPanel.TitlePosition = 'centertop'; 1417 | app.MicrogridStatusPanel.Title = 'Microgrid Status'; 1418 | app.MicrogridStatusPanel.FontWeight = 'bold'; 1419 | app.MicrogridStatusPanel.Position = [11 318 140 140]; 1420 | 1421 | % Create SolarFarmLampLabel 1422 | app.SolarFarmLampLabel = uilabel(app.MicrogridStatusPanel); 1423 | app.SolarFarmLampLabel.HorizontalAlignment = 'right'; 1424 | app.SolarFarmLampLabel.Position = [21 88 65 22]; 1425 | app.SolarFarmLampLabel.Text = 'Solar Farm'; 1426 | 1427 | % Create SolarFarmLamp 1428 | app.SolarFarmLamp = uilamp(app.MicrogridStatusPanel); 1429 | app.SolarFarmLamp.Position = [111 90 20 20]; 1430 | app.SolarFarmLamp.Color = [1 0 0]; 1431 | 1432 | % Create BatteryLampLabel 1433 | app.BatteryLampLabel = uilabel(app.MicrogridStatusPanel); 1434 | app.BatteryLampLabel.HorizontalAlignment = 'right'; 1435 | app.BatteryLampLabel.Position = [21 60 44 22]; 1436 | app.BatteryLampLabel.Text = 'Battery'; 1437 | 1438 | % Create BatteryLamp 1439 | app.BatteryLamp = uilamp(app.MicrogridStatusPanel); 1440 | app.BatteryLamp.Position = [111 62 20 20]; 1441 | app.BatteryLamp.Color = [1 0 0]; 1442 | 1443 | % Create VDCLoadLamp_2Label 1444 | app.VDCLoadLamp_2Label = uilabel(app.MicrogridStatusPanel); 1445 | app.VDCLoadLamp_2Label.HorizontalAlignment = 'right'; 1446 | app.VDCLoadLamp_2Label.Position = [22 8 78 22]; 1447 | app.VDCLoadLamp_2Label.Text = '24V DC Load'; 1448 | 1449 | % Create loadThreeStatus 1450 | app.loadThreeStatus = uilamp(app.MicrogridStatusPanel); 1451 | app.loadThreeStatus.Position = [112 8 20 20]; 1452 | app.loadThreeStatus.Color = [1 0 0]; 1453 | 1454 | % Create VDCLoadLabel 1455 | app.VDCLoadLabel = uilabel(app.MicrogridStatusPanel); 1456 | app.VDCLoadLabel.HorizontalAlignment = 'right'; 1457 | app.VDCLoadLabel.Position = [21 35 78 22]; 1458 | app.VDCLoadLabel.Text = '12V DC Load'; 1459 | 1460 | % Create loadTwoStatus 1461 | app.loadTwoStatus = uilamp(app.MicrogridStatusPanel); 1462 | app.loadTwoStatus.Position = [112 35 20 20]; 1463 | app.loadTwoStatus.Color = [1 0 0]; 1464 | 1465 | % Create SystemPowerSwitchLabel 1466 | app.SystemPowerSwitchLabel = uilabel(app.UIFigure); 1467 | app.SystemPowerSwitchLabel.HorizontalAlignment = 'center'; 1468 | app.SystemPowerSwitchLabel.FontSize = 14; 1469 | app.SystemPowerSwitchLabel.FontWeight = 'bold'; 1470 | app.SystemPowerSwitchLabel.Position = [29 477 101 22]; 1471 | app.SystemPowerSwitchLabel.Text = 'System Power'; 1472 | 1473 | % Create SystemPowerSwitch 1474 | app.SystemPowerSwitch = uiswitch(app.UIFigure, 'slider'); 1475 | app.SystemPowerSwitch.ValueChangedFcn = createCallbackFcn(app, @SystemPowerSwitchValueChanged, true); 1476 | app.SystemPowerSwitch.Position = [45 514 70 31]; 1477 | 1478 | % Create BluetoothStatusPanel 1479 | app.BluetoothStatusPanel = uipanel(app.UIFigure); 1480 | app.BluetoothStatusPanel.TitlePosition = 'centertop'; 1481 | app.BluetoothStatusPanel.Title = 'Bluetooth Status'; 1482 | app.BluetoothStatusPanel.FontWeight = 'bold'; 1483 | app.BluetoothStatusPanel.Position = [11 141 140 163]; 1484 | 1485 | % Create ConnectionLampLabel 1486 | app.ConnectionLampLabel = uilabel(app.BluetoothStatusPanel); 1487 | app.ConnectionLampLabel.HorizontalAlignment = 'right'; 1488 | app.ConnectionLampLabel.Position = [21 113 66 22]; 1489 | app.ConnectionLampLabel.Text = 'Connection'; 1490 | 1491 | % Create ConnectionLamp 1492 | app.ConnectionLamp = uilamp(app.BluetoothStatusPanel); 1493 | app.ConnectionLamp.Position = [111 114 20 20]; 1494 | app.ConnectionLamp.Color = [1 0 0]; 1495 | 1496 | % Create DisconnectButton 1497 | app.DisconnectButton = uibutton(app.BluetoothStatusPanel, 'push'); 1498 | app.DisconnectButton.ButtonPushedFcn = createCallbackFcn(app, @DisconnectButtonPushed, true); 1499 | app.DisconnectButton.Position = [29 9 75 22]; 1500 | app.DisconnectButton.Text = 'Disconnect'; 1501 | 1502 | % Create RemoteIDLabel 1503 | app.RemoteIDLabel = uilabel(app.BluetoothStatusPanel); 1504 | app.RemoteIDLabel.Position = [29 87 63 22]; 1505 | app.RemoteIDLabel.Text = 'RemoteID:'; 1506 | 1507 | % Create BTIDLabel 1508 | app.BTIDLabel = uilabel(app.BluetoothStatusPanel); 1509 | app.BTIDLabel.HorizontalAlignment = 'center'; 1510 | app.BTIDLabel.Visible = 'off'; 1511 | app.BTIDLabel.Position = [12 61 104 22]; 1512 | app.BTIDLabel.Text = 'BTID'; 1513 | 1514 | % Create ConnectButton 1515 | app.ConnectButton = uibutton(app.BluetoothStatusPanel, 'push'); 1516 | app.ConnectButton.ButtonPushedFcn = createCallbackFcn(app, @ConnectButtonPushed, true); 1517 | app.ConnectButton.Position = [29 35 75 22]; 1518 | app.ConnectButton.Text = 'Connect'; 1519 | 1520 | % Create MicrogridbyLabel 1521 | app.MicrogridbyLabel = uilabel(app.UIFigure); 1522 | app.MicrogridbyLabel.FontWeight = 'bold'; 1523 | app.MicrogridbyLabel.Position = [36 86 87 22]; 1524 | app.MicrogridbyLabel.Text = 'Microgrid by:'; 1525 | 1526 | % Create JordanMorrisLabel 1527 | app.JordanMorrisLabel = uilabel(app.UIFigure); 1528 | app.JordanMorrisLabel.FontWeight = 'bold'; 1529 | app.JordanMorrisLabel.Position = [36 65 87 22]; 1530 | app.JordanMorrisLabel.Text = 'Jordan Morris'; 1531 | 1532 | % Create EskindirAbebeLabel 1533 | app.EskindirAbebeLabel = uilabel(app.UIFigure); 1534 | app.EskindirAbebeLabel.FontWeight = 'bold'; 1535 | app.EskindirAbebeLabel.Position = [36 46 93 22]; 1536 | app.EskindirAbebeLabel.Text = 'Eskindir Abebe'; 1537 | 1538 | % Create BradenLeeLabel 1539 | app.BradenLeeLabel = uilabel(app.UIFigure); 1540 | app.BradenLeeLabel.FontWeight = 'bold'; 1541 | app.BradenLeeLabel.Position = [36 27 87 22]; 1542 | app.BradenLeeLabel.Text = 'Braden Lee'; 1543 | 1544 | % Create KennetThurmanLabel 1545 | app.KennetThurmanLabel = uilabel(app.UIFigure); 1546 | app.KennetThurmanLabel.FontWeight = 'bold'; 1547 | app.KennetThurmanLabel.Position = [36 8 101 22]; 1548 | app.KennetThurmanLabel.Text = 'Kennet Thurman'; 1549 | 1550 | % Create ProjectLab3Label 1551 | app.ProjectLab3Label = uilabel(app.UIFigure); 1552 | app.ProjectLab3Label.FontWeight = 'bold'; 1553 | app.ProjectLab3Label.Position = [36 107 87 22]; 1554 | app.ProjectLab3Label.Text = 'Project Lab 3'; 1555 | end 1556 | end 1557 | 1558 | methods (Access = public) 1559 | 1560 | % Construct app 1561 | function app = PL3GUI_exported 1562 | 1563 | % Create and configure components 1564 | createComponents(app) 1565 | 1566 | % Register the app with App Designer 1567 | registerApp(app, app.UIFigure) 1568 | 1569 | % Execute the startup function 1570 | runStartupFcn(app, @startupFcn) 1571 | 1572 | if nargout == 0 1573 | clear app 1574 | end 1575 | end 1576 | 1577 | % Code that executes before app deletion 1578 | function delete(app) 1579 | 1580 | % Delete UIFigure when app is deleted 1581 | delete(app.UIFigure) 1582 | end 1583 | end 1584 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Matlab-App-Designer-GUI 2 | Created by Kennet Thurman using Matlab Mathworks software. The GUI utilizes Bluetooth communication, real-time graphing, switches, and gauges to monitor a microgrids power, voltage, and current. 3 | --------------------------------------------------------------------------------