PID in position mode.

More
27 May 2013 23:13 #34761 by casetero
Hello,

Maybe it is a silly question, but i dont understand why does my PDI system works with the stepgen set in velocity mode and works totally inestable in position mode.

Another question i have, if i am working with MESA cards, can i link the pid.x.pid-do-calcs to a faster thread than servo-thread? For example to a thread with 50.000 ns. Will it work better??

Thank you and regards.

Please Log in or Create an account to join the conversation.

More
28 May 2013 08:05 #34804 by andypugh
Replied by andypugh on topic PID in position mode.

Maybe it is a silly question, but i dont understand why does my PDI system works with the stepgen set in velocity mode and works totally inestable in position mode.

It is rather in the nature of controllers. I think a position-to-positon controller could work, but you would need a P gain very much less than 1. There normally has to be a difference in the nature of controller and controlled. (If there is no difference in nature, then you don't really need a controller).

Another question i have, if i am working with MESA cards, can i link the pid.x.pid-do-calcs to a faster thread than servo-thread? For example to a thread with 50.000 ns. Will it work better??

As the outputs to the controller update at the servo thread rate, there is no point in running the calcs any faster.

However, you do want to add the various functions to the threads in the right order. Read the data, do the calcs, write to output. This typically means hm2_read forst, then PID calcs, then hm2_write.
There may be an advantage in putting non-time-critical stuff first, to get the hm2 read, motion, pid calcs and hm2_write as close together as possible in time.

Please Log in or Create an account to join the conversation.

More
28 May 2013 21:38 #34849 by casetero
Replied by casetero on topic PID in position mode.
Hello,

I´ve been trying putting in every functions ( hm2_read, hm2_write, motion_controller and pid-calcs) added to a fast thread and it seems to work similiar, so i will work just with servo-thread.

I´ve been trying to make the PID in postion mode too, it makes a strange thing, i request linuxcnc to move 1 mm, it starts to move, but it just moves a half of milimeter, then it stops. Reading pins with hal meter i see than pid.x.output is giving 0.5 mm it has to move to hm2_5i25.0.stepgen.01.position-cmd and indeed this pin has the 0.5 value too, but the motor doesnt move. Do you know what can be happening?

Thank you and regards.

Please Log in or Create an account to join the conversation.

More
28 May 2013 22:07 #34850 by casetero
Replied by casetero on topic PID in position mode.
Sorry Andy,

I have understood now your message, so the nature of the control and the controlled must be different. So if i read position from the encoder i have to command with velocity the stepgen.

Thank you.

Please Log in or Create an account to join the conversation.

More
28 May 2013 22:20 #34851 by PCW
Replied by PCW on topic PID in position mode.
First, I dont believe the position mode stepgen can be made to work
very well under external closed loop control.
(certainly never as well as velocity mode).

This is because the stepgen position mode uses lots of clever code
to end up at the right endpoint of each segment. I suspect these will introduce
nonlinearities that will make PID control difficult.

Much better to use the simple, linear velocity command,
where FF1 does almost all the work and just a tiny bit of P is needed
to correct for time base differences, direction change pauses etc.

That said, you can probably do better by adding some integral term to a position loop.
With only P, (and P will need to be small or you will wildly overshoot your target),
you will alway have a fixed error thats inversely dependent on your P term.

If you consider a velocity mode loop, integration is built-in with just a P term.
that is, with _any_ position error, the velocity will be set such that the position
error is reduced over time.

Please Log in or Create an account to join the conversation.

More
28 May 2013 23:50 #34855 by casetero
Replied by casetero on topic PID in position mode.
Ok, my pdi command and read are in mm ( position) and the output is in mm/s (velocity).

What i dont know if i have nice coded is the scale for the stepgen, i fix it in 1400. 1400 are the pulses that my motor needs to move one milimeter.

It is well fixed the scale of the stepgen??

So what are the intervals than axis.x.motor-pos-cmd normally works, i mean when i push the botton of jog-moving for 1 mm, really the axis.n.motor-pos-cmd in wich mm intervals does that total movement of one milimeter?? I dont know if this is important, but when i make the operation P = (Commanded - Measured) * Pgain , i should know more or less with what error i am working for seting a good value of Pgain, shouldn´t I??

Thank you.

Please Log in or Create an account to join the conversation.

More
29 May 2013 00:57 #34859 by PCW
Replied by PCW on topic PID in position mode.
That looks like the correct scale. I would set a small P gain and tune FF1 first (it should be very close to one). Too much FF1 will make the position lead the command, and too little will make the position lag the command.

Yes, for a perfect velocity mode control you can preset the P gain to what is required to fix the error in one servo period (P=1000 at a 1 KHz servo thread). Unfortunately this will likely be unstable for a couple of reasons, one being the delay caused by zero order hold (the result of the last cycles PID error being applied for the entire next cycle). Practical gains will also be lower because servo thread jitter will introduce large noise in the velocity command.

Remember however that the hardware velocity generator is almost perfect so most of the control can be done via FF1, with only enough P term to correct for the (very small)
contributions of time base errors and direction change pauses at reversals.

Please Log in or Create an account to join the conversation.

More
29 May 2013 01:03 #34860 by casetero
Replied by casetero on topic PID in position mode.
I have set Pgain in 8 and FF1 in 0.8.

It works very very fine, i will continue tomorrow but now i´m in the correct way.

Thank you very much.

Please Log in or Create an account to join the conversation.

Time to create page: 0.143 seconds
Powered by Kunena Forum