encoder scale calculation

More
30 May 2021 19:36 - 30 May 2021 21:05 #210726 by chris@cnc
I have an encoder with 5µ resolution. In the drive I have to set a very high gain so that the maxerror stays well below 100µ. The result is sporadic vibrations when standing.
My idea was to round the encoder to 10µ = 2 decimal places, which also works well. It would be even better to scale it to 20µ. Unfortunately, I have no idea how to calculate it. Does anyone have an idea there?
Thanks Chris

My calculation from 5µ to 10µ
component round " ";
pin in float in;
pin out float out;

function _;
license "GPL";
;;
FUNCTION(_) {	
   
			float i;			
		       		
				i = in + 0.005;	
// so that it rounds "correctly", with 3 decimal places 0.005
				i = (int) (i * 100); 
// here the float * 100 is calculated and set to int, so all further decimal places are omitted
				i =  i / 100;	
// and here again through 100 so that there are 2 decimal places
								     	
				out = i;   
}     
Last edit: 30 May 2021 21:05 by chris@cnc.

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

More
30 May 2021 21:03 - 30 May 2021 21:03 #210742 by andypugh
Replied by andypugh on topic encoder scale calucation
Have you tried using the pid "deadband" parameter, it is designed for this sort of thing?
Last edit: 30 May 2021 21:03 by andypugh.

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

More
30 May 2021 21:18 #210745 by chris@cnc
Replied by chris@cnc on topic encoder scale calucation
yes I have. Only then is the regulation imprecise. Example deadband is 0.005, the servo regulates within this tolerance and my ferror rises. Adjusting this doesn't work well. With this method it always regulates zero and cuts off the last 10 micro.

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

More
30 May 2021 21:34 #210747 by andypugh
Replied by andypugh on topic encoder scale calucation
This is a complicated subject.

1) Do you have any I-gain? I would normally expect to use that to pull in the last bit of error, using P-gain to optimise the dynamic response.
It might be that you can work with a little less P and rather more I.

2) I wrote the "lincurve" component specifically so that PID could have gains that vary with error, velocity or anything else.
In my day-job I tune the PID that controls the idle governor of diesel engines. In that case there is a separate set of gains for each gear, and for clutch-in and clutch-out neutral. Each of P, I and D comes out of a 3D map that depends on engine temoperature and the idle speed error.
LinuxCNC has a small sub-set of that, but you can at least vary the gains with the error using lincurve. (And could select gains by gear for a spindle using mux)

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

More
31 May 2021 19:26 #210822 by chris@cnc
Replied by chris@cnc on topic encoder scale calculation
Yes, I currently have the P on 80 and I 0.005 D0.025.
After a long search it was the best setup with the smallest ferror.
Unfortunately, these china drives are very difficult. This is not a problem with the Delta Servo. The best will be to have a fixed value when the pid is set to 0. I found the section / * apply the deadband * / in pid.c, but I don't understand the value of deadband. If I enter 0.005 in INI, the variable * (pid-> deadband) = 0.000005.
I just wanted to say if pid-error < deadband set pid-output to zero. But it's not so easy as expected. The pid-error is sometimes positive sometimes negative depending on the direction. Probably a good solution would be and deadband with a direct readable effect.

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

More
03 Jun 2021 15:30 #211092 by chris@cnc
Replied by chris@cnc on topic encoder scale calculation
Hi Andy,
i change in pid.c the /* apply the deadband */ section an vibrations not occur.
Deadband now means if pid.error < deadband -> set pid.output to zero. So we avoid last pid vibrations if axis in toleranz.
I set now deadband to 0.005 and if now axis error < 0.005mm pid output is zero. For my understand looks good. What do think about this?
Old:
/* apply the deadband */
    if (tmp1 > *(pid->deadband)) {
	tmp1 -= *(pid->deadband);
    } else if (tmp1 < -*(pid->deadband)) {
	tmp1 += *(pid->deadband);
    } else {
	tmp1 = 0;
    }

New:
/* apply the deadband  */
/*check if pid.error positiv and < deadband*/
    if (*(pid->error) >= 0 && *(pid->error) < *(pid->deadband)) {
	tmp1 = 0;
/*check if pid.error negativ and < deadband*/
    } else if (*(pid->error) <=0 && -*(pid->error) <= *(pid->deadband)) {
	tmp1 = 0;
    } 

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

More
07 Jun 2021 23:32 #211458 by andypugh
Replied by andypugh on topic encoder scale calculation
I think that the existing version is trying to avoid a step change in response at the deadband limit. Which does seem wise.

You could try using a "lincurve" to set the P-gain to zero when the error is small, and ramping up symmetrically. for larger errors.

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

Time to create page: 0.746 seconds
Powered by Kunena Forum