Hi guys I was reading this note about tuning PID, there is this term "error squared = error * weight" I have no idea what it means, and when I google, I got "mean error squared", but I need to understand what is "error squared" first. And also, I don't know what is "weight" referring to neight. Could someone explain it the term "error squared" and "weight" please, thanks

You aren't giving us enough context to really interpret much of what you've said. Many systems use "mean squared error" as a metric for how close the system is performing compared to where it should be ideally. The main reason it is squared is to that any error is seen as an error, instead of a large negative error cancelling out a large positive error. You could use the absolute value, but squaring it has advantages from a mathematical standpoint. Also, it makes the system much more sensitive to large errors and less so to small errors, which often results in "better" performance. The weight is actually a conversion factor, usually converting from the units associated with the error to units associated with the command signal.

When you measure the error, the value can be either positive or negative. If you want to calculate the total error you cannot simply add the errors. If you add a number of error readings then the result would tend to zero because of cancellation. So you would think of adding the absolute values. Summing the square of the error gives a greater weighting to larger errors. This leads to the significance of RMS = root mean square.

Ok, I understand the squared part, but I am still not sure what the "weight" means here. the formula in my note say: error squared = error * weight, why not error squared = error^2?

You title says error square. That is a different thing from the square of the error (or the error squared). If you plot two lines or curves on a graph they will, in general, be subject to slight uncertainty or error. So although the ideal crossing of the two curves is a clearly defined point in theory, in practice it lies within a small region around this point called the error square or error box. I have tried to illustrate this in the attachment. However I think you mean error squared as already responded to. When you make a series of measurements, each measurement will be subject to random errors. As already noted if you square each individual error (the true value minus the measured one)^2, and add them all up and then divide by the number of measurements you obtain a quantity called the "mean square error" (MSE). As it stands this is unweighted ie no weights are applied. This is the simple version. This assumes that every every measurement is equally difficult. This may not actually be true. You may be (should be) more certain of a measurement near full scale than near the zero for instance. So you might wish to give more credence to some measurements. In order to do this we introduce weights. These are multipliers to increase or reduce the squared errors added into the MSE total as descibed above. there are systematic rules for doing this, depending upon circumstances.

The weight is some factor of proportionality multiplied by the error. So... Weight x error = function of proportionality x square of the error.

Frankly, I think you need to throw that book away -- well, maybe that's a bit too harsh, but they are dancing all around the right concepts but clearly do not grasp the math they are babbling about. When they say that, "the weight is proportional to the magnitude of the deviation", then technically they are saying W = weight = k*|error| So, for them, error-squared = error * k * |error| = k*sign(error)*(error^2) Basically, they are wanting to give precedence to large error, but need to keep the sign intact because that determines the polarity of the resulting command signals. That last part is why they can't just use the square of the error directly. The 'k', which is the driving force behind calling it a 'weight', stems from the fact that you measurement of error is not in the same units as the commands you will process to drive the system. Consider this -- you have a motor that has an unloaded speed of 500rpm/V, so to turn at 5000rpm it needs 10V. Now you have a tachometer that produces 1V/1000rpm. If you are using just a proportional controller, then you have to have some error in the system in order to have a drive signal. Let's say that you want the motor to run only 100rpm slow if you command it to run at 5000rpm. So your command voltage will be 9.8V. Your reference signal is in terms of the tach voltage you want to see and at at 5000rpm that would be 5V. At 4900rpm the tach will be putting out 4.9V so you will have an error voltage of 0.1V. You need to convert this to 9.8V so you apply a gain (a weight) of 98Vmotor/Verror. If you changed the tach, then you would change the gain so that you get the same response.

Sorry I should not have replaced "factor" with "function". Doing it on my android phone rather than my PC.

lol, I would say throw away the tutor who gave me these notes, but anyway, not all the people likes their jobs and passionate about it. I can understand some people just want to do just enough and not get fired