PID Trainer, issue on setup

geniusintraining

Lifetime Supporting Member + Moderator
Join Date
Jun 2005
Location
SC
Posts
8,278
I built a new style PID trainer, trying to make it more affordable then our current model, this one seams simple but I can get it... before I build them I need to make sure they function correctly and they will work mechanically.

Simple ball on a piece of angle with a motor for the up and down on one end but regardless on the PID setup I cant get it, I have changed every setting that I know and I thought I was decent at setting them up

https://www.youtube.com/watch?v=WbB1Lq27Pvg

Is it possible that there is such a thing as not able to set a PID? maybe my motor is to slow/fast?

I was going to have a fan oscillate to give another dimension but I cant get this one let alone introducing more variables
 
The servo appears plenty fast enough, so I don't think that's your issue. Is the sensor that tracks the ball's location fast enough?
Perhaps on your next iteration of "PID trainer", have a ball on a flat surface (or even slightly convex surface) and the PID keeps the ball centered on the surface.
 
Just one question:
Do you know where the ball is located at any time ??

Yes, I have 1 input to the PLC, on the left side there is a sensor that is looking at the location of the ball, when the ball is close to the sensor the input is 4mA and when the ball is at the other end of the angle the input is 20mA, the output of the PLC is also 4-20mA and raises or lowers the other end of the angle

Its getting a little better... I am using the min/max of the PID output and its helping the overshoot

busarider29 said:
The servo appears plenty fast enough, so I don't think that's your issue. Is the sensor that tracks the ball's location fast enough?
Perhaps on your next iteration of "PID trainer", have a ball on a flat surface (or even slightly convex surface) and the PID keeps the ball centered on the surface.

Thank you for your response, it looks like the sensor feedback is real time (close) I dont see a delay, I thought the same when I was making it but, I thought the PID would be able to react fast enough not to overshoot, there is a feedforward setting that I will try next to see if that has any reaction
 
Have you modeled the system? Note that

  • the system is inherently unstable i.e. the ball will be stable anywhere when the channel is level, and the ball will always end up at a stop when the channel is not level;
  • by controlling the attitude of the angle channel, the PID is controlling the force (of gravity) on (≡ acceleration of) of the ball, i.e. not the velocity, so it is similar to a joystick on a jet fighter;
  • the acceleration or force is proportional to the sine of the channel angle with respect to level i.e. the system gain is near-linear with the servo position; [updated this line and the next; it's sine not cosine)]
  • there is a fair bit of inertia when the ball is moving, both translational and rotational, and that inertia has a high ratio relative to the controlled acceleration (sine of the angle) when the channel is near level.
It might be easier to mung the position into a velocity, and try to drive (control) that derived velocity to zero with the acceleration (≡ force ~ angle).
 
Last edited:
@Genius.
I remember long time ago ( I am retired now) when I was working with RS500 that the PID instruction has a timer or something similar, have you experimented trying to change that value. ?
I also remind of something called STI that I used to use when I needed a faster response, I am not sure if that is suitable in this case.
 
I built a new style PID trainer, trying to make it more affordable then our current model, this one seams simple but I can get it... before I build them I need to make sure they function correctly and they will work mechanically.
Your first problem is that this is not an easy system to control, duh.

Simple ball on a piece of angle with a motor for the up and down on one end but regardless on the PID setup I cant get it, I have changed every setting that I know and I thought I was decent at setting them up
The second problem is that it is not an easy system to control. it can be controlled with a PID but it is not easy because is not linear.

Is it possible that there is such a thing as not able to set a PID? maybe my motor is to slow/fast?
I doubt it is a motor problem
This is not an easy system to control.
Get the hint?

I was going to have a fan oscillate to give another dimension but I cant get this one let alone introducing more variables
Now you want to make a system that is not easy to control even harder. Good luck.

Find something easier to control like Ron Beaufort's hot rod temperature control systems he used for training. This was discussed back in 2005.

We have a system like that some where around Delta Motion.
I think it morphed into a 6DOF system were we rolled ball through a maze for a trade show.

Originally the simpler system back and forth balancing system was used for a project by the local university for a senior project. They flailed and failed for a few weeks. They were clueless as to why they couldn't get it to work ( our new university system ). They didn't try to model the system. They were trying to use trial and error. One time I just happened to be walking by ( I am retired and not normally at the office ) and I saw what they were attempting to do. I told them they were doing it all wrong.

The system they built was similar to GITs, and were trying to balance a 1 inch steel ball. That was a mistake. Too much mass, too much energy. I told them to replace the steel ball with a ping pong ball. That helped a lot. The trick is how do you remove the energy?

I modeled the system using Mathcad. I got it done but they were able to get the TT ball to balance by moving the ball slowly.

drbitboy said:
Have you modeled the system?
Modeling the system helps in understanding the system. The problem is that one must keep track of the energy that the ball has. One is starts moving it has a lot of kinetic energy, both translational and rotational. The kinetic energy must be reduced to 0 to stop the ball and this can't be done if the ball is rolling too fast. If the ball is rolling too fast you can't stop it by tilting the system enough before the ball rolls off the edge. Energy is added by tilting. Then the ball has potential energy and will start to roll down hill trading off potential energy for kinetic energy. If the ball gets too close to the pivot before it is slowed down, it is too late. The angle of the tilt requires a trig function.

I worked out the math for the students but it was over their heads. Only one student even knew about solving non-linear differential equations using Runge-Kutta. The system isn't linear and it requires some trig in the transfer function.
This is a good example of why real control experts use systems of differential equations.

I can show you the math but I don't know what good it will do. Your tilt system is too complicated for beginners. Did I mention this is not an easy system to control?
 

Correct but thats why I thought it would be a good trainer, yes the ball should be stable when the angle is flat but I should also be able to put the set point anywhere along the angle, so if I set it to 50 should ride in the middle if I set it to 85 it should ride close to the end and if I have a fan (oscillating) blowing the ball it should give a hole new dimension and have a different PID


widelto said:
remind of something called STI that I used to use when I needed a faster response

Yes your memory is correct and I am using STI

MaxK said:
Can you publish system transfer function?

Sorry but I have no idea what that is... I know just enough to be dangerous :)


Peter Nachtwey said:
Your first problem is that...

Yes I have LOTs of problems, I was hoping you would chime in and you saying its not an easy project give me hope its not just me :)

So my normal solution is to through a bunch of **** at the wall and see what sticks, below is the setup that worked, not perfect yet but getting there, it will hold the ball at a given set point after 2-3 passes (over/under) setpoint


Peter said:
Find something easier to control like Ron Beaufort's hot rod temperature control systems he used for training. This was discussed back in 2005

I have another PID trainer that I sell that works great but the parts are getting harder to get and I dont want to price myself out of the market, I think this one will be a fraction of the price and it will be a great tool once I finish it.

Here are the settings that are working, note the Ti setting is really high... since you know just about all, what does the Feed Forward Bias do in RSLogix 500? I did not find anything in the manuals

Thanks to all!

20230307_112216.jpg
 
It might be easier to mung the position into a velocity, and try to drive (control) that derived velocity to zero with the acceleration (≡ force ~ angle).
On further consideration, I think this is right. Consider an analogy to tank level control; assume CV is controlling inflow, outflow (load) varies over time (t); tank system gain is the reciprocal of cross-sectional area (CSA):

  • PV
    • Tank level is a proxy for fluid volume
      • Fluid volume = Volume|level=0 + (level * CSA)
    • Ball velocity (Vball) is a proxy for momentum, Mball
      • Mball = mball * Vball
        • mball is the mass of the ball
        • :wave-hands: angular momentum also is linear with Vball, but since this analysis is symbolic, it is not shown here, so mball is not mass per se, but includes rotational inertial as well
  • PV(t) = ∫(F(CV(t)) - K(t)) * gain dt
    • Level(t) ∝ FluidVolume(t) / CSA = ∫(InletFlow(CV(t)) - OutletFlow(t)) / CSA dt
    • Vball(t) * mball = Mball(t) = ∫(Force(CV(t)) - 0) * gain dt
      • Because change in momentum is linear with the product of force and time (check the units).
      • K(t) is 0, because there is no load to balance like there is in the level example.
I haven't figured out the rest yet. Peter and I are saying the same thing; I think momentum is a better metric than energy for the analysis, because it will be linear with the product of force and time, whereas energy will be linear with the product force and distance i.e. linear with the product of force, velocity, and time, and so will make the analysis more complex. Also, momentum is a vector (like velocity; 1-D in this case), so the sign takes care of itself, and energy is a scalar, so the sign has to be managed separately. But their magnitudes' relationship is monotonic, so thinking in terms of energy vs. momentum should not make much difference.

Here is a video of someone who solved this problem.

A simpler system to control would be to build a rotameter i.e. control the level of a a ping pong ball in a vertical tube with an internal diameter that increases gradually with height, and have the PID's CV control the airflow through the tube. That would be a stable system and control would be much easier.

A butterfly valve at the top could be used to change load.

Making such a tube out of clear material is non-trivial (e.g. take a lengthwise, very narrow, V-shaped dart out of a tube and glue the edges back together), so an alternative would be drilling small holes into the tube along its length as a proxy for the increasing diameter.
 
Last edited:
the ball should be stable when the angle is flat


I was not clear what I meant by stable:

  1. If the PID is put into manual and the output (angle) set to some value other than flat, the ball will continue to move in one direction** and will not find a stable (i.e. fixed) position at some offset from the center.
    1. * and for that matter, accelerate
    2. ** ad infinitum if the channel is long enough,
    3. This is why, as @Peter Nachtwey notes, controlling this system is not easy
  2. The position of the ball will not be stable: the position will continue to change with whatever velocity it has when the angle becomes flat (ignoring friction, of course, which is small).
 
Last edited:
Non-linearity is not going to be much of a problem: sin(θ) ∝ θ (actually sin(θ) ≈ θ, for θ in radians); any non-linearity could be attenuated via linkage design, or a simple cam between the PID CV and the servo position.
 
A simpler system to control would be to build a rotameter i.e. control the level of a a ping pong ball in a vertical tube with an internal diameter that increases gradually with height, and have the PID's CV control the airflow through the tube. That would be a stable system and control would be much easier.

A butterfly valve at the top could be used to change load.

Making such a tube out of clear material is non-trivial (e.g. take a lengthwise, very narrow, V-shaped dart out of a tube and glue the edges back together), so an alternative would be drilling small holes into the tube along its length as a proxy for the increasing diameter.

I already have one https://youtu.be/8Yv-aBEZFrc?t=56

Tim's video is better than mine (thanks Tim) but that trainer is overkill, the cost is not cheap, way to many parts and very time consuming to build, so this one should be a fraction of the cost easier to build and they should get the someone of the same benefit from using it
 
I found my mathcad pdf for the rolling TT ball
https://deltamotion.com/peter/Mathcad/Mathcad%20-%20RollingTTBall.pdf
The control only uses a PD controller.
The D(t,y) is the system of differential equations and the PD control
The rkfixed is the runge kutta that calculated the trajectory.
The angle goes negative, rotate clockwise, initially then goes a little to start slowing down the ball. Notice that the speed is very slow so the motion to move 0.1 meters takes a couple of seconds. Also notice that the title angle is very slight.


I could have added the model for the motor but the motor and control are very fast relative to how fast the TT ball is moving and how little the system needed to be tilted.
 
@Peter Nachtwey: noice!

It makes sense that the simulation does not need Integral action. As I was postulating earlier, the loop is mainly controlling velocity, specifically driving velocity to zero, and the Derivative action both calculates velocity and drives it to zero, so it takes care of that, and when it has i.e. when velocity is zero, the net derivative action will be zero, so if the ball reaches that zero velocity at an offset from the setpoint, then Proportional action will provide some offset tilt to move it toward the setpoint*.

* That description greatly oversimplifies the sequence as separate steps, in reality it will all happen simultaneously of course.

Note that, in the simulation, you can get away with PD only because the CV is perfect i.e. CV is θ, so a PID output CV (θ) of 0 is indeed a level channel, so it is ideal, and the output of the PD will be 0 when the ball has stopped (dE/dt = 0) at the setpoint (E = 0). In an actual system, to get an angle of 0, the PID output CV may not be 0, so either an offset bias, or its fraternal twin Integral action (accumulation), will be required.
 
Last edited:

Similar Topics

I have Real PLC but I dont have a real system to have PID Control- any recommendation how can I build such a system- there are some PID trainer...
Replies
6
Views
3,107
I've built a little trainer with a Automation Direct DL05, some pilot lights, switches, a ethernet card and some of the new PX remote I\O. The PX...
Replies
7
Views
4,231
Hi, I would like to assemble a simulator/practice booster pump system that uses PID to maintain steady water pressure under various outlet demands...
Replies
0
Views
86
Hello, I have a motor that we are sending a RPM Speed Output from 0-100% to the VFD. However, the Motor HP needs to be limited to 6000 HP and the...
Replies
3
Views
92
I have S7 1512C controler for controlling 48 PID temperature loop, the output is PWM. Please I need the best, most efficient way to write the...
Replies
13
Views
623
Back
Top Bottom