Skip to content

Instantly share code, notes, and snippets.

@n7275
Last active April 17, 2021 16:35
Show Gist options
  • Save n7275/537be959219aebbf806fd44a125e18bc to your computer and use it in GitHub Desktop.
Save n7275/537be959219aebbf806fd44a125e18bc to your computer and use it in GitHub Desktop.
Powermerge Demo
##clear;
##clc;
powerdraw = 700; #nominal watts at 28V
RL = 28^2/powerdraw; %Load Resistance
R1 = 0.014; %Wire Resistance
R2 = 0.015; %Wire Resistance
R3 = 0.012; %Wire Resistance
R4 = 0.015; %Wire Resistance
% Schematic showing current mesh. All current flows are clockwise (LH)
%
% *-------------*-------------*-------------*-------------*
% | | | | |
% | current(1) | current(2) | current(3) | current(4) |
% | ---- - ---- - ---- - ---- -
% RL | V1 | V2 | V3 | V4
% | | + | + | + | +
% | <-- | <-- | <-- | <-- |
% | R1 R2 R3 R4
% | | | | |
% *-------------*-------------*-------------*-------------*
% Source Voltages
V1 = 29.1
V2 = 29.0
V3 = 29.0
V4 = 29.0
% Loop Voltages
voltage = [V1, V2-V1, V3-V2, V4-V3]';
ImpedanceMatrix = [RL+R1, -R1, 0, 0;...
-R1, R1+R2, -R3, 0;...
0, -R2, R2+R3, -R4;
0, 0, -R3, R3+R4];
ImpedanceMatrixInv = inverse(ImpedanceMatrix);
current = ImpedanceMatrixInv*voltage;
% Current flow through Sources
I1 = current(1)-current(2)
I2 = current(2)-current(3)
I3 = current(3)-current(4)
I4 = current(4)
% Power Produced by sources
P1 = I1*V1
P2 = I2*V2
P3 = I3*V3
P4 = I4*V4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment