A Theory for Sparse Event-Based Closed Loop Control

Most dynamic systems are controlled by discrete time controllers. One of the main challenges faced during the design of a digital control law is the selection of the appropriate sampling time. A small sampling time will increase the accuracy of the controlled output at the expense of heavy computations. In contrast, a large sampling time will decrease the computational power needed to update the control law at the expense of a smaller stability region. In addition, once the setpoint is reached, the controlled input is still updated, making the overall controlled system not energetically efficient. To be more efficient, one can update the control law based on a significant fixed change of the controlled signal (send-on-delta or event-based controller). Like for time-based discretization, the amplitude of the significant change must be chosen carefully to avoid oscillations around the setpoint (e.g., if the setpoint is in between two samples) or an unnecessary increase of the samples number needed to reach the setpoint with a given accuracy. This paper proposes a novel non-linear event-based discretization method based on inter-events duration. We demonstrate that our new method reaches an arbitrary accuracy independently of the setpoint amplitude without increasing the network data transmission bandwidth. The method decreases the overall number of samples needed to estimate the states of a dynamical system and the update rate of an actuator, making it more energetically efficient.


INTRODUCTION
With ever faster and ever cheaper digital computers, the control of dynamic systems has shifted from analog to digital controllers. Critically, the majority of discrete-time control laws assume that the sampling rate of the discretization process is constant. There is currently a discrete-time equivalent for the vast majority of continuous-time control theory principles, from the continuous proportional-integral mechanical "governors" of Maxwell (1867) to the more recent optimal control theories based on Pontryagin's maximum principle (Pontryagin et al., 1962).
The selection of the appropriate sampling rate depends both on the open-loop system dynamics and on the desired dynamics of the controlled system. A system with fast dynamics needs a high sampling rate to ensure the stability of the controlled system at the expense of higher computational power. Moreover, the controlled input of a dynamical system is traditionally updated at each time step independently of the error amplitude. When a controlled system is in a stable configuration at the setpoint, there is obviously no need to sample the data, update the controller and the actuator. Indeed, doing so is not energetically efficient.
In the early 60's, this lack of efficiency combined with lower computational power spurred the development of adaptive discrete-time sampling methods (Dorf et al., 1962;Tomovic and Bekey, 1966). In these methods, an event is sent once the sampled signal increases or decreases by a certain delta (send-on-delta/event-triggered discretization schemes). When the signal doesn't change, there are intrinsically no more updates. More than three decades later, there was a resurgent gain of interest for these discretization methods with aperiodic sampling time leading to new control mechanisms (e.g., Arzén, 1999;Bernhardsson and Aström, 1999;Heemels et al., 2012) for sendon-delta, (Miskowicz, 2005(Miskowicz, , 2007 for area/integral thresholds, and their analyses, e.g., the effect of noise on the send-ondelta mechanism (Astrom and Bernhardsson, 2002;Cervin and Astrom, 2007). In Hetel et al. (2017), a survey on stability studies of aperiodic sampling systems is provided.
Event-based control mechanisms have also drawbacks. For example, to the best of our knowledge, all current event-based control schemes transmit the signal value within an event. This limits the system dynamic range (ratio between the largest and the smallest value that a signal within a control system can assume) because the data transfer must have the same representation as the system data. Therefore, if one wants to control a system with a high accuracy on a wide range of value, such a control system would need a high bandwidth network to transmit the values of the signal.
In this paper, we propose a new framework and theory for event-based control that are circumventing the problem mentioned above while preserving the benefit of the event-based approach. We formalize a generalized discretization method that stems from the principle of neuromorphic event-based cameras (Posch et al., 2008(Posch et al., , 2011 for analog signals. In contrast to traditional frame-based cameras where a clock synchronizes the acquisition of each pixel and the pixels' value is transmitted directly in an image, in event-based cameras each pixel is independent. When a pixel detects a light intensity change of a certain magnitude, it signals the change emitting an event. This event carries information about the time of the change, the position of the pixel and if the light intensity increased or decreased. The principal contribution of this work is to generalize the level-crossing sampling representation in the context of control. We focus on exploiting the benefit provided by a more efficient information coding to reduce computation resources through the use of the duration between two events rather than the value of a signal to update the control law. Therefore, an event can be represented with fewer bits than the input signal and this increases the dynamic range of the control system. First, we describe a general class of event-based discretization functions and the associated reconstruction process in section 2.1. Then, in section 2.2 we show how uncertainties on the event timing as well as on the initial value of the signal affect the accuracy of the reconstructed signal. In section 2.3, we use a logarithm as discretization function and we show how we tackle the issue of the Zeno phenomenon (Heymann et al., 2005;Lampersky and Ames, 2013). Section 3 presents control results based on the logarithmic discretization. Finally, section 4 concludes the paper. Figure 1 presents the general principle of a linear ( Figure 1A) and a non-linear ( Figure 1B) event discretization applied to an error signal ǫ(t). Using linear event-based discretization, if the setpoint lies between two intervals then no event will be generated (no event will be generated after t 4 as the system is stable between two samples). To overcome this problem, the simplest method is to compute the step size such that the setpoint is an integer multiple of the step size. It is worth noting that when the setpoint lies between two samples, it corresponds to a bias β in the linear function presented in Figure 1A. In the non-linear case presented in Figure 1B, the step size needed to generate events decreases as the controlled signal approaches the setpoint. Therefore, one can stop the event generation when the absolute error is smaller than a predefined threshold.

Event Generator Function
Given a generic finite dimension, non-linear continuous-time system S to control, we assume that a control law C has been designed to ensure that the output y of the system converge toward a setpoint r, stabilizing (at least locally) the controlled system. Both signals r and y can be multidimensional. Using this representation, the error signal ǫ is equal to the difference between the system output y and the setpoint r. Figure 2 is a schematic summarizing this control configuration.Then, B, a subset of R + computed from the control law C, can be defined as the basin of attraction around the equilibrium ǫ = 0 such that: Let h be the "event generator" continuous function that computes the time of the next event t i+1 from the value of ǫ at t i .
The key principle of our event-based discretization method is that the duration between two events generated by h must tend to zero when the error tends to zero. Mathematically, this can be written has a limit: Equation (4) can be equivalently rewritten into: Equation (6) is the first requirement that must be met by h if (4) is true.
FIGURE 1 | Comparison of linear (A1) vs. non-linear (B1) event-based discretization. (A2,B2) Represent the time course of the controlled system (black lines) and the setpoint (red lines) for the linear and the non-linear discretization. Gray lines represents the levels at which an event will be triggered. Starting from an initial condition ǫ(t 0 ) (step a), one can evaluate g(ǫ(t 0 )) (step b). Then remove 1 from the value (step c) to evaluate when the next event will be generated g(ǫ(t 1 )) = g(ǫ(t 0 )) − 1. Finally, compute the inverse of g for this value and extract the error ǫ(t 1 ) at the next event (steps d and e). These steps can be repeated to extract ǫ(t 2 ) from ǫ(t 1 ), ǫ(t 3 ) from ǫ(t 2 ) and so on. As clearly shown in the figure, the limit of this recursive process when the error approaches zero is zero in the non-linear discretization but not in the linear one (because of the bias β in the function).
FIGURE 2 | Generic closed loop control system. r represents the setpoint, y the system output, ǫ the error between the setpoint and the system output, C the controller, and S the controlled system.

Events Generation
As the class of functions that satisfy (4) is very broad, this section presents a method to build these functions. One can compute a time series {t i } using a monotonically increasing function g applied to ǫ(t) such that an event will be triggered when the difference of g between two events is equal to one: For the rest of the paper, we postulate that g is monotonically increasing. However, it must be noted that if g is monotonically decreasing, the same reasoning can be applied and the time series becomes: As g −1 exists (it is monotonically increasing), one can predict the value of the error at which the next event will be triggered: This discretization process is presented in Figure 1.
In addition, ǫ −1 exists by definition of Equation (9). Therefore, one can write the function h defined in (4) as: From this relationship, a supplementary condition on g can be extracted from (6): As g is a function of reals, only ±∞ is a solution of (12).

Signal Reconstruction
Using the proposed discretization, one can reconstruct the time course of the original error signal using the events: in which H(x) represents the Heaviside step function: As the series (13) converges toward 0, then:

Uncertainty Analysis
Up to now, our formulation of the events generation assumes that there is no measurement uncertainties on both the initial value of the error (ǫ(t 0 )) and on the time interval estimation (t i − t i−1 ). In this paragraph, the effect of uncertainties on these values is analyzed.

Uncertainty on the Initial Value
First, we will analyze how an uncertainty on the initial estimate of the error, ǫ(t 0 ), influences the estimate of ǫ(t N ) and thus affects the convergence of the series. We will postulate that we have an infinitely accurate measurement of the time interval between two events. Given an estimate of the initial error with ǫ(t 0 ) representing the true initial value, δ ǫ 0 representing an uncertainty on the true initial value, one can rewrite (13): The first terms of recursion (17) are: Because g is monotonically increasing, it follows that ǫ(t 1 ) <ǫ(t 0 ). This leads to and This result shows that, independently of the initial error on the measurement, the estimate of the error converges toward zero.

Uncertainties on Time Interval Measurement
In this section, we will analyze the effect of an uncertainty on the measurement of the time interval between two events. If one assumes that the uncertainty σ i on the time value t i is drawn from a uniform random distribution U ς −ς between −ς and ς, one can write Equation (13) as: Using (13) and (22), one can extract δ ǫ (t), using the rectangular function : From (24), one can evaluate the bounds of the error if one supposes that all the uncertainties are equal to either ς or −ς: If ǫ(t 0 ) = ǫ 0 , the limit of (25) representing the upper (lower) bound of δ ǫ (t) can be computed using (15): Similarly, the other bound is equal to ςǫ 0 . Equation (26) shows that the boundaries of the uncertainty on the error signal is only a function of the clock accuracy. Therefore, the proposed nonlinear discretization can be used to reach an arbitrary precision of the controlled state, provided that the user has access to an infinitely accurate clock.

Logarithmic Event-Based Discretization
As the goal of the paper is to demonstrate the usefulness of the discretization method to control a system, we postulate in the following sections of the paper that the user has designed a control law such that the controlled system is globally asymptotically stable.
In the rest of the paper, we use a logarithmic function as event discretization function g(ǫ). We demonstrated in section 2.1 that a candidate discretization function g must fulfill three conditions: 2. g must be continuous and strictly monotonic on R +, * (and thus invertible) Selecting a logarithmic function with a base b of ǫ(t) for g such that: it is straightforward to demonstrate that the logarithm satisfies the three conditions on g on R + . The effect of the base of the logarithm on events generation will be presented in section 3 Using (27), one can compute a time series {t i }: A polarity information, p i , is added to the time series (28) to express if ǫ(t) has increased or decreased between two samples of the series: For the sake of simplicity, we will use b > 1 in the rest of the paper. But the same relationships used to generate an events series for b > 1 can be derived if 0 < b < 1: Finally, as ǫ(t) can change sign between two events, we added a third piece of information to each event representing a change of sign between the current event and the prior one: s i . Therefore, an event e i is defined as a triplet (t i , p i , s i ) in which t i represents the event time, p i represents its polarity (either 1 or -1, could be represented by a single bit) and a Boolean s i (0/1) representing the fact that the sign of the signal changed between the e i−1 and e i .
Using these notations, one can construct the time course of the original signal ǫ(t) using 1 : in which H(x) represents the Heaviside step function:

Arbitrary Accuracy
The goal of this section is to demonstrate that the proposed logarithmic discretization can be used to reach a stable point with an arbitrary accuracy. Using (29), the value of the error signal at time t i can be written using a geometric recursion: From (35), it is clear that from any finite value ǫ(t 0 ): Equation (36) shows that one can reach an arbitrary precision using the logarithmic discretization proposed in this section.
The arbitrary precision at which the error is considered null (therefore at which the system has reached the setpoint) is a design parameter of the control law.

Refractory Period
Theoretically when ǫ reaches zero, the number of events goes to infinity and the duration between two events reaches zero. In addition, even if the accuracy of the clock is very high, practically the computations needed to evaluate the ratios (29) and (30) can take some time. Therefore, for practical implementations, we define the refractory period as the minimum time between two events that the system can generate. These limitations put some constraints on the overall system as the ratio between the past error and the current one could be crossed multiple times during the refractory period. To counter this issue, we added a last parameter to the event representing the number of times the threshold has been crossed between two events r n : Equation (33) can be written to include r n : The presented discretization method allows us to benefit from the event-based representation in the control context. In the experiments section, we present its application to the control of a second order dynamical system.

EXPERIMENTS
The proposed event-based non-linear discretization and the resulting control laws are tested on two systems different systems. The first one is a classical second order dynamical system while in the second example we stabilize an inverted pendulum on a cart.

Control of a Second Order Dynamical System
This section presents the control of a second order dynamical system with 0.1 and 0.01 s as time constants. The secondorder system is controlled by a proportional-integral-derivative controller (see Appendix in Supplementary Material, section 3) with a proportional gain equal to 1, an integral gain equal to 5, and a derivative gain equal to zero. This example is used as an academic demonstrator of the new event-based discretization method. Therefore, this second-order model doesn't describe a particular system and the units of the controlled signals, the setpoint, the output or of any of the system internal signals are arbitrary. Figure 3A presents the results of the simulation when a unitary step (the setpoint of the system goes from zero to one) is applied to the controlled system 100 ms after the beginning of the simulation. The base of the logarithmic discretization function was set to 1.05 and the refractory period was set to 1 millisecond. The upper row represents the time course of the setpoint and the output of the system. The second row represents the frequency of the events generated. Positive (negative) frequencies correspond to positive (negative) polarity events. The events frequency was computed using the convolution of a 2.5 ms normal distribution with the time of the events as it used in neuroscience to compute the discharge frequency of neuronal activities (MacPherson and Aldridge, 1979;Richmond et al., 1987). The last row represents the control sent to the system to reach the setpoint. Importantly, the control is updated only when an event is generated. Figure 3A shows that the output of the system reaches the setpoint. In addition, when the system output reaches the target (around 2 s, final error = 6.48e-4), no event is generated and the control remains constant. 142 events were generated during this simulation.
To test how a choice of base for the logarithmic discretization function affects the control quality, we ran a series of simulations for setpoint amplitude ranging from 1 to 1,000. Upper row in Figure 3B shows the evolution of the mean squared error during the last 250 ms as a function of the setpoint amplitude for three different bases (1.01: black lines, 1.05: red lines, 1.1: blue lines). The average mean squared error is statistically independent of the setpoint amplitude (mean ± standard error of the mean squared error. 1.01: 6.64e-5 ± 5.16e-6, 1.05: 6.56e-5 ± 8.92e-6, 1.1: 6.41e-5 ± 1.52e-5). Lower row in Figure 3B shows that the number of events generated during a simulation for the This first set of simulations demonstrated that the absolute error remained constant over a wide range of setpoint amplitudes (from 1 to 1,000) without changing either the discretization or the PID parameters. As the absolute error at the end of the simulation remained mostly constant with increasing amplitude, the relative error is decreasing.

Stabilization of an Inverted Pendulum
We have implemented a numerical simulation of an inverted pendulum put on a cart. When a perturbation (in the form of an external force T) is applied to the cart, the pendulum is moved out of its equilibrium position. An event-based proportionalintegral-derivative (PID) controller stabilizes the pendulum in an inverted position through a control force F applied to the cart. The model of this dynamical system is presented in the Appendix in Supplementary Material.
In the first two simulations, we measure the angular orientation of the pendulum. In the last two simulations, we used two sensors to measure the cart position and the angular orientation of the pendulum. In all the simulations, we control the force applied to the cart to stabilize the pendulum in upright position. In each of the following simulations, the pendulum started in the upright inverted position and we injected a fifty milliseconds perturbation one hundred milliseconds after the beginning of the simulation.

Proportional-Integral-Derivative Control Law
In this section, the pendulum angle was controlled by a proportional-integral-derivative (PID) controller with a proportional gain of 100, an integration gain of 2 and a derivative gain of 10. We compared a traditional discrete PID controller with an event-based version of the PID controller. The base of the logarithmic discretization function was set to 1.05 for the eventbased control law simulations and the refractory period of the sensor was set to 1 ms. Figure 4 compares the two control laws when the control sampling rate of the discrete controller was set to 1 kHz. For the event-based control law, the control was updated each time an event arrives. Figure 4A shows the results of the simulation with the event-based control law. Figure 4B represents the results of the simulation with the discrete PID. The last row in Figures 4A,B represents the angular error of the pendulum. In both control law conditions, the pendulum is stabilized by the control law. The maximum error is smaller in the case of the discrete PID controller. However, with the discrete PID, there are peaks of desired force above 500 N. In addition, the discrete version of the control law updated the force applied to the cart 2,500 times while the event-based version updated that force only 199 times, so the system is updated roughly 12.5 times less often using the event-based control.
This simulation shows that the frequency of events generation is sensitive to the amplitude of the error (the smaller the error, the higher the number of events) and to the amplitude of the time derivative of the error (the larger the amplitude of the time derivative of the error, the higher the events frequency). In Figure 4, the frequency of positive events increases during the first part of the error increase (when the time derivative of the error is important). Then, as the amplitude of the error time derivative decreases and the amplitude of the error increases, the frequency of events generation decreases as well. Afterwards, there is a small plateau during which no positive nor negative events are generated (corresponding to the peak of the error signal, when there is no modification of the error amplitude large enough to trigger an event). Finally, there is an increase of the frequency of negative events as the error decreases due to feedback control of the PID. It can be seen that, as the rate of change of the error during the decrease of the error is smaller, the overall frequency of the events is smaller. However, even if the time derivative of the error decreases, the events generation frequency increases toward the end of the stabilization period as the error reaches zero. These observations show the sensitivity of the events generation frequency to both the rate of change of the error and the amplitude of the error. Figure 5 compares a discrete PID control law and an eventbased control law when the discrete controller and the eventbased controller are set to update the control output at 20 Hz. This experiment presents how the event-based controller can be used to update regularly a control output. Therefore, contrarily to all the other experiments, in this case, while the estimate of the error and the integral of the error are updated each time an event is generated, the control is updated every 50 ms. The striking point in Figure 5 is that the event-based controller stabilizes the  pendulum (the effect of the external force is negated and the pendulum remains in an upright position) while the system is unstable with the discrete controller. More events are generated in this condition compared to the condition in Figure 4A (432 events here vs. 199 events in Figure 4A).
In this set of simulations, we showed that the system could reject a perturbation applied to the cart and keep the pendulum stable while decreasing the number of times the controlled input is updated by a factor 12 compared to an equivalent time-discrete PID with a 1 ms sample time. We also showed that we can keep the pendulum stable with the same controller parameters while updating the force applied to the cart every 50 ms instead of each time an event is received, reducing drastically the burden put on the actuator.

State-Space Feedback Control Law
After the controllers reject the perturbation and stabilize the pendulum angle, the third row in Figures 4, 5 shows that the cart keeps moving. This displacement is generated because the stabilized angle is not the upright position. It is not possible to build an observer of the cart position based on pendulum angle measurements as the observability matrix in this condition is not full-rank. Therefore, it is not possible to stabilize both the pendulum angle and the cart position using a single PID with a single sensor on the pendulum angle. In this section, we present a state-space feedback control law that stabilizes both the pendulum angle and the cart position. To that goal, we used two sensors, one on the cart position and one on the pendulum angle. The optimal gain K of the state-space feedback law was computed using the linear-quadratic regulator 2 updated each time an event is emitted by one of the sensors. We used the estimate of the cart position, the derivative of the estimate of the cart position, the estimate of the angular error and the derivative of the estimate of the angular error as states for the feedback. The estimate of the derivatives was built like the derivative component in the PID controller of the previous section. Figure 6A shows the results of the simulation when the force applied to the cart is updated every time one of the sensors emits an event. Figure 6B shows the results of the simulation when the force applied to the cart is updated only every 50 ms. The simulations show that the designed state-space feedback control law rejects the perturbation and that both the cart position and the pendulum angle are stable by the end of the simulations. A total of 1049 events (451 position events, 598 angular events) were generated during the simulation presented in Figure 6A, while a total of 1,679 events (1,113 position events, 566 angular events) were generated during the simulation in Figure 6B.
In this final set of simulations, we stabilized both the inverted pendulum angle and the cart position. The designed system rejected the perturbation and stabilized both the pendulum angle and the cart position. As for the PID simulations, the force applied to cart was updated every 50 ms and we showed that we could keep the system stable.

DISCUSSION
This work proposes a new non-linear event-based discretization method and the associated proportional-integral-derivative and state-space feedback control laws. The key novelty of the new event generator function lies in the principle that the time between two events must decrease when the discretized signal (e.g., an error signal) tends to zero. Contrary to current event-based discretization/control schemes (e.g., Arzén, 1999;Bernhardsson and Aström, 1999;Miskowicz, 2005Miskowicz, , 2007Tabuada, 2007;Lunze and Lehmann, 2010;Donkers and Heemels, 2012;Heemels et al., 2012), the generated events do not contain the value of the signal. Instead, a transmitted event contains four parts: the time of the change, a polarity (did the signal increased or decreased), a sign changed bit (did the signal's sign changed) and a refractory gain (the number of times the threshold set in the level-sampling mechanism has been crossed during a refractory period) to account for multiple level crossings during the shortest measurable duration between two events.
Using the new event-triggering scheme, we showed that all the uncertainties on the signal approximation emerge from uncertainties on the measurement of the duration between two events. Also, because the inter-event duration is the key information to the signal reconstruction, the components of the system do not require synchronized clocks but all of them must measure a duration with the same accuracy.
In addition, the precision of the representation of the error signal stored in any active part of the control mechanism (e.g., 128 bits to represent the state of the system) can be much higher than the number of bits used to transmit an event (e.g., an 32 bits unsigned integer to represent milliseconds). As a result, the design of a control scheme based on the new method of this paper can increase the controlled signal dynamic range without increasing the network data bandwidth needed to transmit the information between the different components of the controlled system.
Our results demonstrate that the new method combines the advantages of analog continuous time systems • it can reach an arbitrary precision with a very high dynamic range • with the advantages of event-based control • no events are generated when the error is null.
In addition, the amount of data transmitted between active parts of the control system can be smaller than the memory needed to store the signals value. This makes the overall system more efficient energetically.

DATA AVAILABILITY
All datasets generated for this study are included in the manuscript and the Supplementary Files.