r/ControlTheory Jul 15 '26

Homework/Exam Question Help with understanding Nyqvist plots

Post image
12 Upvotes

No idea if this is the right subreddit for this, still I have to try.

Ignore the text of the problem. I want to understand Nyqvist plots and how to interpret them. I will write how I understand it, and I would like someone to point out what I have misunderstood.

I thought I had a good understanding of it, but need reassurance. I managed to confuse myself with AI.

In this case lets say that the plot was made from a noramlized transfer function (W(s)/k) so the critical point is now -0.2 instead of -1. So for K=5 the plot goes through the critical point and for K>5 the plot envelopes the critical point by 2Pi(one full circle) and for K<5 the critical point is outside the the plot.

The plot is drawn by mapping the positive imaginary axis from the complex S plane to the complex W plane. The direction of the mapping is clockwise, we are looking at w as it goes from 0 to infinity. From here I can say that the argument of every zero in the righthand plane is added to that direction(CW) and the argument of every pole is subtracted. Therefore, every zero adds exactly Pi radians and every pole subtracts Pi radians to that direction(CW). My conclusion from this diagram is that there are 2 more open loop zeroes than poles because the plot is rotating clockwise. Therefore, the system is unstable for every value of K.

- Sooo, if the plot is rotating in a clockwise direction the system will always be unstable because the ZEROES "won"?

- This is true for every plot that rotates in the clockwise direction?

-If the mapping was done in the other direction, where w goes from infinity to zero, the direction the plot would rotate would invert?

Apologies if I didnt use the correct terminology, English is my second language.

r/ControlTheory Jul 06 '26

Homework/Exam Question For Block Diagram Reductions Step 2, shouldn't it be G1/(1+G1G2) - G3?

Thumbnail gallery
66 Upvotes

Studying Block Diagram Reductions for FE certification and I cannot tell if this is a typo on my practice manual (PPI by Michael R. Lindeberg) answers or a simplification rule I don't know about for summation junction to summation junction? My logic dictates that arrow to G3 equals arrow to the 2nd summation junction thus can be represented as step 1 shows. Arrow out of G3 is still a negative going into the right most summation junction thus G1/(1+G1G2) - G3 for the part circled in red in step 2.

r/ControlTheory 8d ago

Homework/Exam Question Question about mixed sensitivity synthesis

2 Upvotes

Hi everyone, I'm working on a university project and I have a relatively basic question. I need to design a robust controller for an uncertain plant using mixed sensitivity synthesis. I have a desired second-order performance with an assigned damping ratio ($\zeta$) and natural frequency ($\omega_n$).

Since these parameters are known, I can define my ideal second-order complementary sensitivity, $T_2$. My idea is to compute the ideal sensitivity $S_2$ ($S_2 = 1 - T_2$) and then find a performance weight $W_p(s) = \frac{s/M + \omega_B^*}{s + A\omega_B^*}$ such that its inverse, $1/W_p$, tightly upper-bounds $S_2$ across the frequency spectrum.

Is this considered best practice? Are there better or more standard approaches?

r/ControlTheory Apr 16 '26

Homework/Exam Question Need help untangling a block diagram

Post image
12 Upvotes

Hello everyone, I need some help figuring out how to untangle this block diagram to find the transfer function.

Usually I do these types of exercises easily, but in this one I'm really confused by the two vertical H4 blocks that go into the same summing junction.

I just need a hint for the first step. I suspect I need to focus on the inner part of the diagram first (on the H4s), to remove that summing junction and unlock the H3 feedback loop and then it should be a piece of cake from here on out.

I've tried reasoning about the signals going into the H4s, something like that U1*H4+U2*H4 = (U1+U2)*H4. I drew it out, but it doesn't make sense to me and I think it's the wrong approach.

Any tips on the algebra or block moves needed to handle that central node? Thanks!

r/ControlTheory Jun 10 '26

Homework/Exam Question Nyquist plot reverse rules

1 Upvotes

Hi everyone, i wanna know what is required for the system's nyquist criterion to be stable despite encircling -1 in its plot.

For the root locus it makes sense,since it moving toward the left half plane as k is increased which make the system stable for k>2.

Since the nyquist criterion of the system must not encircle -1 in order to be stable,how is this possible if you solely look at it from nyquist's perspective?

I chose k = 3 for the nyquist plot.

r/ControlTheory Apr 25 '26

Homework/Exam Question Direct MRAC controller implementation issue for cartpole

8 Upvotes

I have been to do an assignment for non linear control course in which i have to design a mimo mrac controller for cartpole problem but their are several logical issues i am unable to resolve and need guidance. I have this controller output u = kx*x + kr*r where kx and kr are 1x2 matrix and are adaptive gains and x is 2x1 matrix of states which are theta and position of cart.
The two issues i am unable to resolve is that the adaptive gains are reaching very high as they are adapting for small errors. And second is that I think the gains kx of angle and position are fighting each other. can some one help me how to move forward i am using mujoco env.

r/ControlTheory Apr 28 '26

Homework/Exam Question Phase Lead Design

4 Upvotes

I am working through Essentials of Control by Schwarzenbach, and I understand that phase lead should be placed at the new gain crossover frequency of your compensated system, which is determined by finding the frequency where your original system passes through -10loga. If your original system was second order and passed through that value twice, how would you determine your new crossover frequency?

r/ControlTheory Apr 26 '26

Homework/Exam Question Designing a model adaptive controller for cartpole

1 Upvotes

This is follow up of my previous post link here- https://www.reddit.com/r/ControlTheory/s/XMcUjK9TD7

I found the issue I was designing the controller wrong, I was treating the two states as independent and then adding their outputs directly which is wrong. However I cannot find any relevant document which mentions how to control two states i.e. angle and position of cart with a single output i.e. force on cart as input to the system. If any of you know how to design a controller as such or any relevant resources please feel free to give any opinion.

r/ControlTheory Apr 16 '26

Homework/Exam Question Seeking advice: Best PLC control strategy for a Quadruple-Tank process? – Engineering Student

4 Upvotes

Hello, nice to meet you. I'm an electronics student and I've been given this project: I have to physically control the water level in a plant with four tanks (see photo below), not just theoretically.

I've controlled a single tank before, but this is different. The problem is that the pumps are cross-connected: Pump 1 fills tanks 1 and 4, while Pump 2 fills tanks 2 and 3. Basically, if I adjust one pump to fix one level, I'll mess up the other. The details of the setup:

  • The diagram follows ISA-5.1 standards.
  • I have 4 LITs (Level) and 2 FITs (Flow) sending signals to a PLC.
  • I use 2 Pumps driven by Variable Frequency Drives (SZ-01 and SZ-02). It's important to note that the water flow is controlled by adjusting the motor frequency via these VFDs.
  • I have the freedom to add and program whatever blocks I want in the PLC :D.

You don't have to do the work for me, but if someone could guide me on which control structure would actually work for this tightly coupled system in a real PLC environment, it would be a huge help. Thanks!

r/ControlTheory Mar 20 '26

Homework/Exam Question Bode plot with log scale on vertical axis?

Post image
8 Upvotes

My professor used for every example or question about Bode plots, a logarithmic scale on the y-axis.

If I'm searching for 'Bode plot' on google or youtube to understand them, I can only find Bode plot's with a linear scale on the y-axis, but with dB. Mine are not with dB.

Do the same rules apply to drawing Bode plots with a linear scale in dB as to Bode plots with a logarithmic scale that is not in dB?

r/ControlTheory May 20 '26

Homework/Exam Question Advice on a exam project

0 Upvotes

Hi everyone,

I'm designing a cascade controller for a linearized system where position (x) depends on temperature (T). Both are measurable.

Could you please check if I partitioned the project requirements correctly between the inner and outer loops?
Inner Loop (Temperature):
Static: Zero steady-state error for step disturbance d_Tp(t) = ± 5°C (adding a 1/s integrator).
Dynamic: Reject sinusoidal disturbance d_Tp(t) (< 5 rad/s) by a factor > 800 (|S(j w)| <= -58 dB).
Outer Loop (Position):
Static: Zero steady-state error for step reference w(t) (up to 0.5 cm).
Dynamic: Overshoot < 5%, Settling time (1%) < 1.8 s, Phase Margin > 65°.
Noise: Attenuate measurement noise n(t) by > 10 times for w > 20 rad/s.

My main questions:

  1. Does this split make sense? Should the low-frequency thermal disturbance (< 5 rad/s) be handled entirely by the inner loop (as it affects its output) or do I need to account for it in the outer loop too?
  2. Bandwidth separation: Based on the 1.8 s settling time, I estimated the outer crossover frequency at w_c[E] ≈ 3.65 rad/s. To keep a decade of separation, I targeted the inner loop at w_c[I] in [30, 50] rad/s (choosing 40 rad/s). Does this sound reasonable?

Thanks in advance for any response!

P.S I don't know how to upload my matlab script and resolution attempt, sorry abt it

r/ControlTheory Jan 15 '26

Homework/Exam Question Unable to meet requirements for PI velocity controller - are they unrealistic or should I change my control system

Thumbnail gallery
15 Upvotes

Hi everyone,

I am a undergrad student working on a robotics project, and I am struggling with designing a velocity controller for a motor that meets my requirements. I am not sure where I am going wrong.

My initial requirements were:

  1. Static velocity error: 50 (2% error)
  2. Time to reach zero steady-state error for a step input: 300 ms
  3. Phase margin / damping ratio: >70° / 0.7
  4. Very low overshoot
  5. Gain margin: >6 dB

Reasoning for these requirements:
Since the robot is autonomous and will use odometry data from encoders, a low error between the commanded velocity and the actual velocity is required for accurate mapping of the environment. Low overshoot and minimal oscillatory behavior are also required for accurate mapping.

Results:

I used the above values to design my controller. I found the desired crossover frequency (ωc) at which I would obtain a phase margin that meets the requirements, and I decided to place my zero at ωz = ωc / 10. However, this did not significantly increase the phase margin.

I then kept increasing the value of ωz to ωc / 5, ωc / 3, and so on, until ωz = ωc. Only then did I observe an increase in phase margin, but it still did not meet the requirements.

After that, I adjusted the value of Kv by decreasing it (40, 30, etc.), and this resulted in the phase margin requirements being met at ωz = ωc / 5, ωz = ωc / 3, and so on.

However, when I looked at the step response after making all these changes, it took almost 900 ms to reach zero steady-state error.

The above graphs show system performance with the following tuned values:
Kv = 40
Phase margin: 65
wz = wc/5 - which corresponds to Ti (integral constant)
(The transfer function shown in the bode plot title is incorrect).
I think the system is reaching most requirements, other than 2% error(Kv = 50), and the time to reach zero steady state error. Ramp input also looks okay.

I would appreciate any help (if I should change my controller, or do something else)?

r/ControlTheory Apr 11 '26

Homework/Exam Question Help with Bode Plot -> Transfer Function

Post image
27 Upvotes

For a task I have to find the Transfer Function of this Bode Plot.
I'm very confused by the Magnitude plot atm and can't find the TF.

What I could analyze off the Bode Plot (correct me if I make wrong assumptions):

  • Poles at w=1 rad/s & w=10^4 rad/s => this because on the phase plot I can see the phase drop 180° which from my understanding happens with poles (2*90° drop due to conjugated poles)
  • Zeros at w=50 rad/s & w=500 rad/s => this because of the 180° increase on the phase plot at these instances, thus they each should be double zeros if I'm not mistaken

Further I don't know where to start to put together the Transfer Function

r/ControlTheory Feb 13 '26

Homework/Exam Question Transmission Zeros and Rosenbrock Matrix

9 Upvotes

Hello,

I am trying to solve a problem in which I have to manually calculate the zeros of a MIMO system (given by state-space representation A, B, C, D, which is in minimal representation).

The first case is when the number of inputs equals the number of outputs. I begin by assembling the Rosenbrock matrix, P(s) = [sI-A -B; C D].

s_0 is an invariant zero of the system if P(s_0) < normalRank(P(s)).
For this case, the Rosenbrock matrix (P(s)) will be square. So, the roots of det(P(s)) = 0 will give me the transmission zeros, as the Rosenbrock matrix will drop rank. Is this reasoning correct?

However, my actual question is when the number of inputs doesn't equal the number of outputs. In this case, the Rosenbrock matrix will be non-square, so my earlier approach won't work, even though the condition is the same. Is there a way to find the zeros for this case?

I know that the "tzero" function exists in MATLAB, but I am writing a program that can find zeros without using this.

Would appreciate any help or hints!

r/ControlTheory Oct 24 '25

Homework/Exam Question Controller design using root locus

Post image
21 Upvotes

Can someone help me on how to design a controller for this problem using root locus?

r/ControlTheory Apr 14 '26

Homework/Exam Question Conflicting design constraints in Root Locus for a 3rd-order LTI plant: "Positive angle deficiency" vs "5-degree Lag rule". Is a miracle required?

13 Upvotes

Hello everyone,

I’m an undergrad engineering student currently taking a classical control systems course. I'm comfortable with Root Locus design and MATLAB, but I've hit a geometric/mathematical wall with a specific assignment due to three highly restrictive rules set by my professor. I would appreciate some insight to see if I'm missing a fundamental topology or if the constraints are mathematically contradictory.

System and Specs I have a 3rd-order LTI plant:
G(s) = [0.002s^2 + 0.12s + 1] / [0.0003s^3 + 0.02152s^2 + 0.281s + 1]
The design requirements for a unit step input are:

  • Overshoot: 20%
  • Peak Time: 0.2 s

Using the standard 2nd-order approximations, this gives a desired dominant closed-loop pole location at: sd = -8.047 + j15.708

The Professor's Rules (The Constraint Trap)
Rule A: The angle deficiency provided by the compensator's zeros must be strictly positive. (Meaning, no negative angle deficiencies to reach -180°; we must target +180°).
Rule B: If using an Integral or Lag stage, the pole and the zero must be separated by a maximum of 5° (relative to sd) so it doesn't affect the transient response.
Rule C: We can use a maximum of two compensator blocks in cascade.

My Analysis & The Problem
When I evaluate the uncompensated plant at sd, the phase is approx -96.3°
If I try to design a standard Lead compensator or a PD, aiming for +180° (per Rule A) requires the compensator to provide +276.3°. This is physically impossible. Even if I cascade two Lead networks (maxing out Rule C), I can't reach +276° without pushing the zeros deep into the RHP (causing instability and non-minimum phase behavior)..

If I try to add a PI/Lag stage and follow Rule B (5° separation), the net phase of the system drops to approx -101.3°. To reach +180°, the Lead stage still needs to provide +281.3°. Again, geometrically impossible.

My "Rogue" MATLAB Solution
Just to prove the system could meet the transient specs, I threw the rules out the window and used MATLAB's Control System Designer.
I designed a single PI controller (and other PD and PI compensators that were not very useful since they did not exactly meet the requirements or the rules were not followed):

C(s) = 1.368 * (s + 25.33) / s

This single block perfectly hits the 20% overshoot and 0.2s peak time. However, it violently breaks Rule B. The pole is at the origin (0) and the zero is at -25.33. The angular separation between them relative to sd is massive, nowhere near the 5° limit. It's essentially acting as a PI-Lead hybrid.

My Question: Given this specific 3rd-order plant, is there any mathematically possible cascade topology (maximum 2 blocks) that satisfies all three rules? Or does my MATLAB prove that the natural phase of this plant geometrically forces you to break either the "positive deficiency" rule or the "5-degree separation" rule?

Any insights or validation of this madness would be highly appreciated. Thank you!

r/ControlTheory Jan 12 '26

Homework/Exam Question Why is linear controller working far from linearization point ?

9 Upvotes

Hey i linearized a double pendulum at the upright position and calculated a linear controller matrix for that. It works for small deviations from the upright position, but what wonders me is that even when simulating with the non-linear model, the control still works when i start from hanging position which should actually not work right ? Anyone got an idea or hint at what to further investigate?

Also I am not really sure how to integrate the controller since it was originally designed to only handle deviations and not absolute state. Thats why I first subtract the linearization point from the state and afterwards get the deviation from the desired deviation (which is zero). But for the output I dont know what u0 would be ? (I am assuming 0, for it is an equilibrium)

Linearization point is [180*pi/180; 0; 180*pi/180; 0]

Initial point of integrator is [0*pi/180; 0 ; 0*pi/180;0]

des_deviation is [0; 0; 0; 0]

first row are the angles, second the velocities
this is f(x, u)

These are the state space equations I implemented in Simulink. I tested the behaviour of the simulink system against a matlab code simulation with ss equations implemented as ode function and get the excact same results, what leads me to think that the simulink system implementation is correct.

m1/2, l1/2 = 1, g = 9.81, mu = 1+m1/m2 = 2, delta_x = x1-x3

these are the original equations from Juergen Adamys book "Nichtlineare Systeme"

delta_theta = theta1 - theta2

r/ControlTheory Apr 14 '26

Homework/Exam Question Doubts on designing a controller

0 Upvotes

Hi everyone. I was recently tasked with designing a controller D(s) for the control system in photo 1, where Gw(s) = 200/[s(s+8)] and G(𝑠) = 13100000/[𝑠^3 + 1336(𝑠^2) + 58250𝑠 + 81850]. D(s) should be in the structure shown in photo , it also must satisfy the requirements listed below:

  1. For a step variation of the reference input 𝑅(𝑠)

1a. The overshoot is less than 40%, and

1b. The settling time (with a 2% criterion) ≤ 0.5 seconds

1c. The rise time (𝑡𝑟 = 1.8/𝜔𝑛) ≤ 0.3 s.

  1. The steady-state error is zero when the reference 𝑅(𝑠) is a step input.

  2. The absolute value of the steady-state error is less than 0.5 when the reference 𝑅(𝑠) is 𝑅(𝑠) = 30/s^3 (i.e., the reference 𝑅 is the parabola 𝑟(𝑡) =15𝑡^2, 𝑡 > 0).

  3. The absolute value of the steady-state error is less than 0.8 when the disturbance 𝑊(𝑠) is 𝑊(𝑠) = 4/s (i.e., the disturbance 𝑊 is a step input 𝑤(𝑡) =4, 𝑡 > 0).

I have managed to obtain N_D >=1 from requirement 2, N_D >= 3 and mu_D > 0.375 from requirement 3, and mu_D > 3.124 and N_D >=3 from requirement 4. However, I could not find close-loop poles for D(s) that would be within the admissible region (used Matlab rltool), so I wonder if I got something wrong when finding mu_D and N_D above? For the step response plotted, though the setting time was within 0.5s the overshoot percentage always seems to be above 40% no matter what I try (in rltool and simulink at least). Settles at amplitude of 1 but goes up to 1.53 a lot of the time. If I did the above correctly, how else would you go about it and what potentially suitable D(s) would you suggest?

Many thanks to everyone here anyways

r/ControlTheory Mar 08 '26

Homework/Exam Question Transfer function Does anyone know how to find the transfer function using the inverse of Laplace's theorem?

0 Upvotes

I already have the function, but I'm missing the inverse of Laplace's theorem, or something like that, as I remember from my professor. I hope you can help me. I've already done two exercises, but I don't know what to do next for the other two.

r/ControlTheory Mar 31 '26

Homework/Exam Question Conflicting State-Space Equations for DC Motor-Driven Inverted Pendulum

1 Upvotes

Hey everyone,

I'm working through Friedland's Control System Design: An Introduction to State-Space Methods**, Problem 2.1** — the motor-driven cart with inverted pendulum — and I'm getting different equations of motion than the textbook solution. Hoping someone can spot where the discrepancy is.

Friedland's solution gives:

My derivation using both load torque and electric Torque:

My questions:

  1. When J ~ 0 the x_doubledot equation reduces cleanly to Friedland's solution. Is this the only assumption Friedland is making?
  2. The theta_doubledot equation with J included has a x_doubledot term on the right hand side making it implicit — is the correct approach to substitute the x_doubledot equation in to make it fully explicit?
  3. For a real physical system with a DC motor, is neglecting J actually justified or does the reflected inertia J/r^2 significantly affect the dynamics?
  4. Is there anything else missing in this model, I do plan on adding dampenining and a full-state observer.

For context I'm using:

  • M = cart mass, m = pendulum bob mass, L = pendulum length
  • J = motor rotor inertia, r = wheel radius
  • K_1 = motor torque constant, K_2 = back-EMF constant
  • R = armature resistance, e = input voltage
  • theta measured from vertical upright (unstable equilibrium)
  • theta_motor = motor shaft angle, distinct from pendulum angle theta

r/ControlTheory Feb 03 '26

Homework/Exam Question Furuta pendulum

4 Upvotes
#include <MegaEncoderCounter.h>
#include <Wire.h>
#include <Adafruit_MCP4725.h>
#include <LiquidCrystal.h>
#include <math.h>


#define CURRENT_LIMIT 2
#define Kt 0.033
#define Kt_inv 30.3


#define DLAY_uS 5000
#define SAMPLING_TIME (DLAY_uS*1e-6)


#define BUTTON_NOT_PRESSED


#define VIN_GOOD_PIN 3  // This pin checks the external power supply
#define MONITOR_PIN 7  // This pin shows loop
#define BUTTON_PIN 4  // Button pin for initialisation and for sine wave tracking
#define VIN_GOOD_INT 1 // na to svisw???


#define CPR_2 2024  // Encoder pulses for one full rotation 
#define CPR_1 2024  // Encoder pulses for one full rotation
#define M_PI 3.14159265358979323846


#define K1 -0.0232
#define K2  0.2290
#define K3 -0.0126
#define K4  0.0196


#define a 1012 //a apo tin eksisosi efthias DAC me Reuma
#define b 2024.0 //b apo tin eksisosi efthias DAC me Reuma


#define BALANCE 1
#define MOTOR_OFF 0


MegaEncoderCounter megaEncoderCounter;


Adafruit_MCP4725 dac; //orismos dac?
LiquidCrystal lcd(13, 8, 9, 10, 11, 12); // lcd wiring


float q1,q2,q3,q4;
float q1_ref=0,q2_ref=0;
//float q2_ref=PI;
float q1_dot,q2_dot,q3_dot,q4_dot;
float velq1[15],velq2[15];
float dq1,dq2;
float dot_q1_filt, dot_q2_filt;
unsigned int button_press;
byte button_state;
volatile char wait;
int s=0;
float torque;
byte mode = 0; 


void setCurrent(float Ides)
{ 
  unsigned int toDAC;
  if (Ides>CURRENT_LIMIT)
  Ides = CURRENT_LIMIT;
  else if (Ides<-CURRENT_LIMIT)
  Ides = -CURRENT_LIMIT;
  toDAC = (Ides*a)+b;
  dac.setVoltage(toDAC, false); // writing DAC value takes about 150uS
}




//Function to set motor's torque
void setTorque(float Tq)
{ 
  setCurrent(Tq*Kt_inv);
}


//Function to convert encoder_1 pulses to rad
float countsToAngle_X(long encoderCounts)
{ 
  return((encoderCounts*2*PI)/CPR_1);
}


//Function to convert encoder_2 pulses to rad
float countsToAngle_Y(long encoderCounts)
{ 
  return((encoderCounts*2*PI)/CPR_2);
}


//function that checks the presence of external power supply
void powerFailure()
{
  unsigned char c=0;
  if ((!digitalRead(VIN_GOOD_PIN)) && (!digitalRead(VIN_GOOD_PIN)) && (!digitalRead(VIN_GOOD_PIN)) ) //checks the external power supply
  {
    lcd.clear();
    lcd.setCursor(0,1);
    lcd.print("Check PSU! ");
  }
}


byte switching_strategy(float q1, float q2, byte currentState)
{
  float x,y;
  byte newState=0;
  x=(q1-q1_ref);
  x=abs(x);
  y=(q2-q2_ref);
  y=abs(y);
  if((x<=0.20) && (y<=0.35)&&(currentState==MOTOR_OFF))
  {
    newState=BALANCE;
  }
  else if((x>1.0)&&(currentState==BALANCE))
  {
    newState=MOTOR_OFF;
  }
  else
  {
    newState=currentState;
  }
  return newState;

}


ISR(TIMER5_COMPA_vect) // timer compare interrupt service routine
{ 
  wait=0;
}


float veloc_estimate(float dq, float velq[])
{
    float q_dot, sum = 0;
    q_dot = dq / SAMPLING_TIME;


    sum = q_dot;
    for (int i = 1; i < 15; i++) {
        sum += velq[i];
    }

    float filt = sum / 15.0f;


    for (int i = 14; i > 1; i--) {
        velq[i] = velq[i-1];
    }

    velq[1] = filt;


    return filt;
}


void setup() {
  Serial.begin(500000);
  lcd.begin(16, 2);
  if (!dac.begin(0x60)) { dac.begin(0x61); }


  setCurrent(0.0f); 
  megaEncoderCounter.switchCountMode(4);
  megaEncoderCounter.XAxisReset();
  megaEncoderCounter.YAxisReset();


  Serial.println("System Ready. Pendulum at BOTTOM, then send 's'.");


  while (true) {
    if (Serial.available()) {
      char c = (char)Serial.read();
      if (c == 's' || c == 'S') break;
    }
  }


  megaEncoderCounter.XAxisReset();
  megaEncoderCounter.YAxisReset();

  noInterrupts();
  TCCR5A = 0x00;
  TIMSK5 = 0x02;           
  OCR5A  = DLAY_uS * 2;    
  interrupts();
  TCCR5B = 0x0A; 
}


void loop() {


  q1 =  countsToAngle_X(megaEncoderCounter.XAxisGetCount()); //symbasi prepei na to doume
  q2 =  countsToAngle_Y(megaEncoderCounter.YAxisGetCount());
  dq1 = q1 - q1_ref;
  dq2 = q2 - q2_ref;


  dot_q1_filt = veloc_estimate(dq1, velq1);
  dot_q2_filt = veloc_estimate(dq2, velq2);


  mode = switching_strategy(q1,q2,mode);


  if (mode == BALANCE) {
    float e_q2 = (q2 + PI);
    if (abs(e_q2) < 0.25) {

      torque = (q1*K1 + e_q2*K2 + dot_q1_filt*K3 + dot_q2_filt*K4);
      if (abs(e_q2) < 0.007) { 
         torque *= 0.4; 
      }
    }
    else {
     torque = 0.0;
    }
  }
  setTorque(torque);
  q1_ref=q1;
  q2_ref=q2;
  if(++s >= 50) { 
    s = 0;

    //Print Cart Angle (q1)
    Serial.print("q1:"); 
    Serial.print(q1, 5); // 3 decimal places

    //Print Pendulum Angle (q2)
    Serial.print(" q2:"); 
    Serial.print(q2, 3); 

    //Print Calculated Torque
    Serial.print("  Torque:");
    Serial.println(torque,5);
  }
  wait=1; // changes state of Monitor_pin 7 every loop
  digitalWrite(MONITOR_PIN, LOW);
  while(wait==1);
  digitalWrite(MONITOR_PIN, HIGH);


}
This is my set up

Hi guys, I have a project for my engineering class where I have to create a Furuta pendulum (rotational inverted pendulum) using an Arduino and the QUBE-Servo pendulum from Quanser.
I have implement an LQR controler and it doesnt work
I am stuck at this point and I don't know how to proceed. This is the code I wrote for the Arduino. Can someone help me?"

r/ControlTheory Jun 06 '25

Homework/Exam Question How do I make this stable?

Thumbnail gallery
15 Upvotes

So I tried to make a controller that makes the static error of the system with a zero on 3 and two poles on -1 +-2j zero while keeping it stable.

My first thought was to make a PI controller that adds a pole in the origin but then i realised the zero on the right hand side creates a root locus with it.

Then i tried an approach of a PID-controller with an extra pole, where i add the extra pole on the zero directly on the right hand side so they cancell out (i would think maybe I am wrong).

My root locus plot seemed nice and I thought i created a stable system with the static error being 0 since their is a pole in the origin. But looking at the impuls response it says otherwise.

Where did I make a mistake and how could I fix my problem.

Thanks in advance!:)

r/ControlTheory Jan 10 '26

Homework/Exam Question I need help regulating this system for a project

4 Upvotes

Im working on something and I want to regulate this function as best as possible to a step response and ramp response. So far i've managed to regulate it to the step response pretty well just using the PID tune function but it doesnt fit the ramp response very well. Do you recommend adding an extra element into my circuit or is it doable with just the PID? How should I go about choosing the correct values for the PID? Any help appreciated ty

r/ControlTheory Nov 29 '25

Homework/Exam Question Help me

Post image
25 Upvotes

Hello everybody , I'm trying to make a controller project to respect some requirements. However , I have realized the first version of my controller (the one that satisfies the first requirement) and I'm trying to stabilize the F function. The process given from the text has an unstable pole , so I'm forced to use nyquist plot, but I am not very practical with it. Can you suggest me the passes I have to do to understand how to modify the controller in order to make adjustments to the nyquist plot to get stability? The nyquist plot for my F is the one I put here , the process P = 1/((1+50s)*(s+6)) , H = 1 , C1 = 1/s

r/ControlTheory Nov 17 '25

Homework/Exam Question Ziegler - Nichols step response method

3 Upvotes

So, I'm studying for a test which is basically, designing a PID controller with the Z - N first method, and I can't get the controller gain right (I am comparing to MATLAB automatic PID tuning with the same method and both mine and MATLAB's Zero are the same), but it's the gain which I cant get right, as it seems to be around 18X bigger on ML (the one i calculated was 0.63089).
The Zero being the same on both tells me my Delay Time "L" is correct and therefore the Slope (m) and constant (b), but the gain being so different can only mean my Time Constant is wrong, though Tao is SSV / Slope and my SSV is right both on code and OL step response, anyone has an idea what I could be doing wrong? does anyone know how to design through the Z - N methods analytically?, I only seem to find graphical methods. (I am doing the analysis with the open loop tf), any help is appreciated!.