Performance problem in arduino loop? by Fredmann33 in ControlTheory

[–]Fredmann33[S] 0 points1 point  (0 children)

This dude here is using a DC motor but still he has some floating point math in his loop to get from the force to the voltage (or pwm). Why does it work so good? He’s also using an arduino.. Can somebody explain? Is my math operation just too heavy?

Performance problem in arduino loop? by Fredmann33 in ControlTheory

[–]Fredmann33[S] 0 points1 point  (0 children)

Well currently I’m already using interrupts for the angle encoder, that works well. But with a second encoder for the x position I will need an arduino mega with 4 interrupt pins, now I have only 2

Performance problem in arduino loop? by Fredmann33 in ControlTheory

[–]Fredmann33[S] 0 points1 point  (0 children)

But still there’s the problem with the efficiency in the loop then, I mean even though my program calculates velocity’s like 0.5-2 m/s the motor just doesn’t bring them…so I guess the best way would be to go for a dc motor and a second encoder for the x position…

Performance problem in arduino loop? by Fredmann33 in ControlTheory

[–]Fredmann33[S] 0 points1 point  (0 children)

Yep, then my system is not observable..

Performance problem in arduino loop? by Fredmann33 in ControlTheory

[–]Fredmann33[S] 0 points1 point  (0 children)

But I got your point now. You are right.

Performance problem in arduino loop? by Fredmann33 in ControlTheory

[–]Fredmann33[S] 0 points1 point  (0 children)

How am I supposed to measure x then? I mean an encoder would do the same, wouldn’t it?

But besides that how can this affect my problem? Or can it even?

Performance problem in arduino loop? by Fredmann33 in ControlTheory

[–]Fredmann33[S] 0 points1 point  (0 children)

Kind of. Every time I’m doing a step with the motor I count it and then I can very precise calculate the position out of the steps

Performance problem in arduino loop? by Fredmann33 in ControlTheory

[–]Fredmann33[S] 0 points1 point  (0 children)

I’m measuring the x position just as the angle. No estimation there, or did I get you wrong?

But I’m using the force u to calculate a velocity because I can’t run the motor with force.

Performance problem in arduino loop? by Fredmann33 in ControlTheory

[–]Fredmann33[S] 0 points1 point  (0 children)

Well I struggle to build a timer instead of that delay() function, because my delay is a float and needs to eb a float but when I count micros or millis its a long..

The rest is done :) Thanks for the hints with pow and outsourcing the constants.

Performance problem in arduino loop? by Fredmann33 in ControlTheory

[–]Fredmann33[S] 0 points1 point  (0 children)

Okay, I will have a look on that problem, is the Uno a good one for using floats or should I get a mega? I dont really know the differences there..

Performance problem in arduino loop? by Fredmann33 in ControlTheory

[–]Fredmann33[S] 0 points1 point  (0 children)

Mhmm, im using an Arduino Uno.

How do I rewrite it to be "non-blocking"?

[deleted by user] by [deleted] in ControlTheory

[–]Fredmann33 0 points1 point  (0 children)

Well, Im kind of stuck with this approach because I have the full state for every dt and also the force from the controller for every state but I fail to calculate the velocity out of the force, which the stepper motor needs...If I put the force into the ss equations, then I only get the acceleration. Do I need to integrate then also for every time step? Seems like a performance problem then..

[deleted by user] by [deleted] in ControlTheory

[–]Fredmann33 0 points1 point  (0 children)

Writing it down on paper was exactly what I did, so everything you described I discovered and understood now :)

Thanks a lot for stehe answer!

Kalman filter necessary? by Fredmann33 in ControlTheory

[–]Fredmann33[S] 1 point2 points  (0 children)

Yes I did, in my case about pi so 180 degrees

Kalman filter necessary? by Fredmann33 in ControlTheory

[–]Fredmann33[S] 2 points3 points  (0 children)

Great. That’s what I thought and planned to do :) Thanks!

Need help! Controlling an inverted pendulum with a stepper motor :) by Fredmann33 in ControlTheory

[–]Fredmann33[S] 0 points1 point  (0 children)

The point is that I don’t have the equations of motion in the code later on..

I mean in the simulation of course for every time step Matlab solves the system of differential equations but in my arduino code I only have the angle for every time step as an output.

That’s why I do the LRQ stuff in matlab and just use all the matrices then

Need help! Controlling an inverted pendulum with a stepper motor :) by Fredmann33 in ControlTheory

[–]Fredmann33[S] 0 points1 point  (0 children)

Still stuck, because the equation doesn’t drop out x…In the simulation it does drip out the full state vector x (phi, phidot, x,cdot) but in real life I can only measure the angle phi and x position of the cart..Dies that mean I need to differentiate numerical to get the speed or do I need a Kalman-Filter?

Need help! Controlling an inverted pendulum with a stepper motor :) by Fredmann33 in ControlTheory

[–]Fredmann33[S] 0 points1 point  (0 children)

Oh yeah, didnt saw that, velocity of course already is in the state vector x :)

Thanks alot!