RLC circuit analysis

Hi everybody!
I have a assignment that needs your help.
I have to build a program using C++ to analyse a random R,L,C circuit. The circuit structure is described in a input file form, for instance, R1 para L1 para C1 ( R1 // L1 // C1), and their value. Once running program, user can enter a random circuit structure ( that's the biggest problem , i think), this program will read it . The result is currents and voltage on each element and it is save in a .txt file that can be redrawn on MATLAB.
Anyone has ideas which can help me??? Im stuck!
Thanks for your help and sorry for my bad English!
Last edited on
Show exactly what the input will look like. Give three examples. Show exactly what the output will look like in each case.

And post any links you have to further information, such as how to do the calculations.

Your title is uninformative. We know you need help. How about "RLC circuit analysis".
Last edited on
thank you, i 'll edit it
Any references appreciated
You have apparently declined to give proper examples and links. Therefore I decline to help you.
Sorry I have no idea, all I have are as described as above. thanks for your attention
Last edited on
So... your circuit looks like this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
     ┌──────────────┐
  ┌──┤ ~V_in(freq)  ├───┐
  │  └──────────────┘   │
  │                     │
  │  ┌──────────────┐   │
  ├──┤      R       ├───┤
  │  └──────────────┘   │
  │                     │
  │  ┌──────────────┐   │
  ├──┤      L       ├───┤
  │  └──────────────┘   │
  │                     │
  │  ┌──────────────┐   │
  └──┤      C       ├───┘
     └──────────────┘


Here's a nice looking webpage that explains parallel RLC circuits with complex analysis of the impedance.
https://www.electronics-tutorials.ws/accircuits/parallel-circuit.html

How does a person enter a "random circuit structure"?
What information should be put in a text file?
Do you already have a Matlab program that reads from a formatted text file?

We are not psychics.

I'm probably misinterpreting your question because obviously all three components would have the same voltage in parallel. Each component will, however, have a different current passing through it. I could go through it... but the parallel-circuit link above goes through finding the impedances and currents of each component in its examples. It's basically just plugging in and making sure you typed the formulas right, if you don't actually care how the equations are derived.

https://medium.com/@gordon_zhu/how-to-be-great-at-asking-questions-e37be04d0603
https://zellwk.com/blog/asking-questions/

But what have you tried so far?


Last edited on
Based on @Ganado's circuit; numbers taken from the second example in his link.

As the others have already said, the OP must explain what he means by a "random circuit structure". It's not very exciting if all components are in parallel: they share the same voltage across their terminals.

matlab? Do you mean simulink?
https://www.mathworks.com/help/physmod/sps/powersys/ug/building-and-simulating-a-simple-circuit.html


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <complex>
#include <iomanip>
using namespace std;

constexpr double PI = 3.14159265358979;
constexpr double radToDeg = 180.0 / PI;
using COMPLX = complex<double>;
#define TAB << setw( 15 ) <<

//======================================================================

double phase( COMPLX Z ) { return radToDeg * arg( Z ); }

//======================================================================

int main()
{
   double V0 = 50;                     // Supply voltage
   double f  = 100;                    // Supply frequency in Hz (cycles/s)
   double R  = 50;                     // Resistance in Ohms
   double L  = 0.02;                   // Inductance in Henrys
   double C  = 5.0e-6;                 // Capacitance in Farad

   double omega = 2 * PI * f;          // Circular frequency (rad/s)

   // Calculate impedances
   COMPLX ZR( R, 0.0 );
   COMPLX ZL( 0.0, omega * L );
   COMPLX ZC( 0.0, -1.0 / ( omega * C ) );


   // Specialised case - all components in parallel
   COMPLX V = V0;
   COMPLX Z = 1.0 / ( 1.0 / ZR + 1.0 / ZL + 1.0 / ZC );
   COMPLX I  = V / Z;                  // Current through source
   COMPLX IR = V / ZR;                 // Current through resistor
   COMPLX IL = V / ZL;                 // Current through inductor
   COMPLX IC = V / ZC;                 // Current through capacitor

   // Summary
   cout << "For all components in parallel (hmmm!):\n";
   cout << "Source voltage (max or rms): " << V0 << " V\n";
   cout << "Source frequency: " << f << " Hz\n";
   cout << '\n';
   cout TAB "Component" TAB "Impedance" TAB "Voltage"       TAB "Current mag" TAB "Phase (deg)" << '\n';
   cout TAB "Overall"   TAB  abs( Z )   TAB  abs( I * Z )   TAB  abs( I  )    TAB  phase( I  )  << '\n';
   cout TAB "Resistor"  TAB  abs( ZR )  TAB  abs( IR * ZR ) TAB  abs( IR )    TAB  phase( IR )  << '\n';
   cout TAB "Inductor"  TAB  abs( ZL )  TAB  abs( IL * ZL ) TAB  abs( IL )    TAB  phase( IL )  << '\n';
   cout TAB "Capacitor" TAB  abs( ZC )  TAB  abs( IC * ZC ) TAB  abs( IC )    TAB  phase( IC )  << '\n';
}


For all components in parallel (hmmm!):
Source voltage (max or rms): 50 V
Source frequency: 100 Hz

      Component      Impedance        Voltage    Current mag    Phase (deg)
        Overall        12.6568             50        3.95046       -75.3369
       Resistor             50             50              1              0
       Inductor        12.5664             50        3.97887            -90
      Capacitor         318.31             50        0.15708             90

Last edited on
Topic archived. No new replies allowed.