PID for controlling transmission rate

W

Thread Starter

WilliamKF

Hello,

I would like to create a PID controller to control the rate at which packets are transmitted. The objective is to reach the highest level of transmission that can be sustained without degraded performance. If transmission is too high, packets get dropped and you can end up going slower than if you transmitted at a lower rate. At different points in times, different transmission rates are sustainable depending upon other independent traffic that is sharing the network.

I have not written a PID before, but reading about it, I see that you have a control signal and an output signal, and the difference between these two is your error which is feed into the P/I/D parts to compute a new control setting.

Given this, I am a bit stumped. My control that I can vary is the rate of transmission, how many packets per unit of time. Getting a control rate matching the actual rate such that error approaches zero is not what I want to optimize, instead I wish to find the highest rate of transmission that can be sustained without a significant number of dropped packets (i.e. less than 2% are dropped.)

I'm not seeing how to adapt my goal to a PID loop and am hoping someone with more experience writing PID loops can point me in the right direction.

Thanks.

-William
 
Forget about a 'D' term, you won't need it. For the 'P' and 'I', the first thing you have to determine is a) what is your target value, and b) what is your current measured value? Then calculate the difference between the two (including the sign as well as the magnitude).

Next, take this calculated difference and multiply it by the proportional gain factor (the proportional gain) and then add it to the current output value. You have now added the 'P' term.

For an 'I' term, take the calculated difference and multiply it by the integral gain factor. Next, take this new value and add it to a variable which we will need to store. Then take this stored variable and add it to the (output + P) value. You have now added the 'I' term.

The variable used to accumulate the 'I' term has to be used on the next cycle as it needs to accumulate over time (it is 'integrating'). If the output reaches some set upper or lower limit however, then you need to freeze the integration to prevent it from "winding up" (accumulating a bigger and bigger value because the output can't change any more).

You can probably just use an 'I' term without 'P' if you are just making slow adjustments rather than rapid changes. Also note that the above doesn't discuss scaling the inputs and outputs so that they represent the same units. You will obviously need to handle this somehow. Also, while I have said that you multiply by a gain factor (e.g. a number between 0 and 1), this could just as easily be done by dividing and using a gain factor greater than 1.

So, this would look something like the following (for integral only):

x = (target value) - (measured value)
ival = (x * igain) + ival
output = output + ival

To stop the integral from accumulating, you would use a conditional statement to only accumulate "ival" if "output" is within the permitted range.
 
> ... the first thing you have to determine is what is your target value ... <

I want to maximize the transmission speed without lots of dropped packets. For example, less than 2% of packets being dropped. So I do not know what my target value is, and it will change over time. This is where I am stumped. What should my target be when I want to maximize the value without excessive lost packets?
 
Well, I don't know what your target value should be either. You haven't really told us anything about what you are trying to do and that general field is far too complex to cover thoroughly in a forum like this.

A PID algorithm is simply about how to calculate how much to adjust your set point to reach the target. Figuring out how to measure and change whatever you are controlling is a different matter altogether. I would suggest trying to find something comparable to what you are trying to do (whatever that is) and then adapting it to your needs (whatever they are).
 
I agree with the other replies.. It sounds like perhaps a PID controller is not really the right solution to your problem.
There are many things to consider in trying to implement an optimal flow control system, the speed of packet transmission being only a small aspect. There are several very well described and mature solutions to the problem, in particular I am thinking of the Sliding Window system used by TCP:

http://en.wikipedia.org/wiki/Sliding_Window_Protocol

If you have a way of detecting errors (and can therefore measure the error rate), and don't care about trying to retransmit data, or keep packets in order, and really want to try with a PI controller, then I would try the following:
SP (Setpoint) = Desired Error Rate (%)
PV (Process Variable) = Actual Error Rate (%)
MV (Manipulated Variable) = Transmission Speed (%)

This will change the transmission speed to vary in order to try and achieve a given error rate.
 
> If you have a way of detecting errors (and can therefore measure the error rate), and don't care about trying to retransmit data, or keep packets in order, and really want to try with a PI controller, then I would try the following: <

Excellent, that fits the bill, thanks!

>SP (Setpoint) = Desired Error Rate (%)
>PV (Process Variable) = Actual Error Rate (%)
>MV (Manipulated Variable) = Transmission Speed (%)

> This will change the transmission speed to vary in order to try and achieve a given error rate. <

Just to confirm, the D factor is not useful here, right? What makes a target value appropriate or not for the D factor? I'd like to understand why it is best to omit the D.

Thanks.
 
'D' (derivative) is generally considered to be for controlling overshoot when you have a system with a lot of physical inertia. There is nothing obviously resembling inertia here, so it it shouldn't be needed. 'D' can also be troublesome to tune correctly because it is sensitive to "noise" in the signal, so it is best to avoid using it if it isn't needed. Also, the more terms you have in the equation, the more factors there are to tune. However, I suppose it is possible that something in the measurement or control could give the same effect as inertia so take this as just an educated guess as I don't know the details of what you are doing.

'P' (proportional) is for speed of response. The output of the 'P' term is exactly proportional to the amount of the error. 'I' is for "zero error" - that is for getting exactly on to your set point ('P' will always leave a small difference). With 'I', even a small error will cause an ever increasing output so long as the error persists. That is why you have to limit the amount of 'I' that is allowed to accumulate (so that it doesn't "wind up" to some huge value that has to be unwound again) once your output has reached the maximum it can do.

I assume you will have some target "transmission speed" which you will originally apply. You will then measure the "error rate" and try to control that to some desired value adjusting the "transmission speed".

The thing you have to watch out for on this is that "transmission error" probably doesn't have a nice simple relationship to "transmission speed". When you don't have a nice simple relationship, then the classic PID algorithm may not work very well.
 
Top