0
$\begingroup$

In many real-time PID control loop application I have seen that the control loop is triggered exactly as the ADC interrupts arrives in order to achieve maximum synchronization between feedback conversion and control loop execution.

I am in a situation where it would be better to have the control loop triggered by a timer interrupt so that it can be indipendent from how the feedback is acquired, for example:

  1. Capacitive encoder read through ADC -> interrupts;
  2. Hall absolute encoder read through I2C -> no interrupts;

In the first case I have a sample available each 4ms. How fast the control loop should be triggered? What are the drawbacks of this implementation? Is it possible to take this issue into account when modeling the digital control system?

Thank you for your time.

Edit 1:

Yes I am controlling a motor that can use different kind of encoders (one at time). Each encoder implements the same software interface so that I can keep motor logic indipendent from encoder internals.

Edit 2:

Sampled feedback

The rising edges in the image are the instants the feedback is sampled and thus made available by ADC interrupts. The sampling period is 4ms. Assuming the control loop executes its calculation in the same time as the sampling period, what happens if the control loop interrupt is triggered late in respect to the ADC interrupt?

$\endgroup$
  • 1
    $\begingroup$ What are you controlling ? I would assume its some kind of a motor. Is there an inertia of the system after changing the control variable. What you need to think of is how long does it take for system to stabilise after changing the output of the controller. That is basically your max PID sequence. That should be less or equal to your sensor sampling rate. It is a good practice to have timer interrupt to align the read and set of the variables. Interrupt could be good to collect the data which is then used in moving average filter and then use that data in the control loop on timer interrupt. $\endgroup$ – Gossamer Jun 10 '19 at 21:35
  • $\begingroup$ Are you saying you have a capacitive encoder and a Hall encoder, or that you might use one or the other? If both, why two? Please edit your question rather than replying in the comments. $\endgroup$ – TimWescott Jun 11 '19 at 0:14
1
$\begingroup$

This kind of control situation in general Nyquist method is used, In your first if your sampling period is 4 ms, your sampling frequency is 250 Hz, so you can control event maximum 125 Hz or another saying 8 ms of sampling period. But it is only for starting, if your sensor values very volatile you would make your period much longer. But I can say 8 ms is the minimum.

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ Hi Ufuk, thank you for your answer. Could you give me some textbook reference? Are you talking about Nyquist stability criterion or sampling theorem? $\endgroup$ – Roberto Maisto Jun 10 '19 at 14:59
0
$\begingroup$

The answer is highly depends on your application. If your application is a simply trajectory tracking PID control of a mobile robot. Such a timing would be not critical.

However, if your application is a safety critical haptic device for human robot interaction with multi-DOF actuators, then you need to seriously care about all the timing issues. Based on my experience, the control input needs to be generated just after the most critical sensor information.

However, a more important part than sequence is the short loop time for most of control algorithms. In you example, if the control loop is running at 125Hz, the order between control input and ADC would be probably not very critical. Since most of control algorithms would be finished within 1ms which is much shorter than one loop time.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.