seriously i can't get it to wirk :/
P, I and D are set to 0 and the rest to max,
like standart settings, i out a gyro and wire it up,
but the thrusters doesnt to anything, always off ? :V
what am i doing wrong ?
can anyone post working example ?
seriously i can't get it to wirk :/
P, I and D are set to 0 and the rest to max,
like standart settings, i out a gyro and wire it up,
but the thrusters doesnt to anything, always off ? :V
what am i doing wrong ?
can anyone post working example ?
When P I and D are 0, the result is always 0!
First leave them all 0, and try putting some numbers in D starting with 1 or less (or you can go from 100 and down). When the thing will be stable (It won't adjust to the needed position, but it just won't be wobbling around when droped in the air and such) adjust the P parameter. Now, P needs to start like from 0.1 and going up, if the thing gets all jiggy and wobly, try lowering the value. With P and D set, the device should now adjust itself to the needed position - but still, the numbers will be in predictable range, so say if I will put weight on one side, it will not be able to adjust, because it's max strength will be the same. Now you can add I parameter to the show. Start with number like 0.01 or even 0.001 and go up until the device can self adjust to the needed errors (weight) in desirable time and stable motions. The crazy thing about I param, is that if your error won't correct itself in some time, it will spaz out (for example if you keep the object frozen while testing your thrusters), so while you're playing with the numbers, I'd suggest you updating the PID chip each time you unfreeze your creation.
Hope that helps![]()
2d head with 3d brains
I've also written the PID expression gate, so that I could use it in ALL wire servers, instead of just ones who run wire extras.
Since it heavier than running lua code, try increasing the interval value since your contraption might not need such rapid update. Just keep it in reasonable rangeCode:N@PID expression I@CurPos EndPos P I D Dcut Ilim Omin Omax On Reset O@Out interval(50) first() -> Time = curtime(); first() -> It = 0; !clk() -> end; On -> Time = curtime() Error = EndPos - CurPos Pt = P * Error Dt = ($Time > 0 ? ($Error/$Time) : 0) * D abs(Dt) < Dcut -> It += I * Error; It > Ilim & Error > 0 -> It = Ilim; It < -Ilim & Error < 0 -> It = -Ilim; Out = Pt + It + Dt Out > Omax -> Out = Omax; Out < Omin -> Out = Omin; ; !On -> Out = 0 Time = curtime() ; Reset -> It = 0;(for thruster stabilisation interval(50) was more than enaugh for me
)
Dcut - Derivative cut
Ilim - Integral limit
Omin, Omax - Output min and max, so that it would only output numbers in range
Also I've added Reset input, so you could reset your PID chip without the need to update it or remake it
Hope this will be useful,
Cheers!![]()
2d head with 3d brains
I usually start by tuning P so that it just spazzes out, add in D until it doesn't, and increase I to eliminate any error that's left. If you set the I limit to a low enough value, freezing shouldn't cause too much of a problem. Updating the loop does reset the I term though.
I started with discrete gates, that was good for about three loops at a time. Expression gate was faster, but a seperate entity ended up being easier to use and the fastest. It is annoying though when you go to add a loop and the server doesn't have PID.
I get weird stuff using this PID. Whever I make one myself out of discrete gates, Zeigler Nicols tuning seems to work fine for pretty much everything, but when I try using it with this one, any integral term higher than about 0.01 causes it to spazz out horribly (growing oscillations etc). Anyone else getting something similar?
It strongly depends on the weight and strength of tools you're dealing with. Usualy in contraptions I don't need more than 0.05 on "I", sometimes even 0.001 ... It all depends on the specs - try increasing/decreasing thruster multiplier, playing with weight also helps![]()
2d head with 3d brains
It does seem odd to me though, as even using the exact same terms for the same system it is so different. I'll have to look through the LUA code to see how it differs from doing it at the gate level. May even try my hand at making an auto tuning routine for it, see how well those control modules I failed hold up.
Edit: Looking back over my notes, I think I am being a bit ambitions for my first LUA project, oh well, gonna give it a go anyway (Anyone know an easy way for computing a generic transfer function given a known input and a measured output? :P)
Last edited by MonkeyPilot; 08-24-2008 at 06:43 PM.
Bookmarks