## Implementation of a filters

The discrete-time transfer function is often obtained from its counterpart, the continuous-time transfer function via discretization. A discrete-time transfer function has the following form:

(1)

Herein, is the input and is the output of the system, and are the degree of the numerator and denominator, respectively. Where , meaning we are dealing with a proper transfer function. While (1) is valid for any order it is not recommended to directly use transfer functions of high order. These can namely introduce numerical problems very quickly. Rather factorize the numerator and denominator of (1) into a cascade of first and second order polynomials.

Now let us look at the simple discrete-time transfer function of order two:

This function is non-causal, because it depends on future inputs. Therefor, both the numerator and denominator are multiplied by reciprocal of the highest order of occuring in the denominator, in this case , to make the system causal. Hence, we obtain:

Followingly, using the linearity and time-shifting properties of the -transform, i.e., and , we obtain the difference equation. Remark that the shift operator is defined as , the forward shift operation and , the backward shift (delay) operator. As a result we obtain,

(2)

Rewriting (2) gives us:

This last equation is the difference equation which we can easily implement on our digital platform. Numerous methods exists on how to implement a filter. Four of these methods are closely related to each other. These are:

• Direct form I
• Direct form II
• Transposed direct form I
• Transposed direct form II

## Direct form I

The direct form I is an FIR filter followed by an IIR filter. That is to say, it implements followed by

(3)

In an algorithm you can implement it as:

yk = b0 * xn + b1 * x1 + b2 * x2 - a1 * y1 - a2 * y2x2 = x1x1 = xny2 = y1y1 = yn

Where, x1, y1, x2 and y2 are the four state variables.

## Direct form II

The direct form I is an IIR filter followed by an FIR filter. Which implements followed by .

(4)

In an algorithm you can implement it as:

s0 =      xn - a1 * s1 - a2 * s2yn = b0 * s0 + b1 * s1 + b2 * s2s2 =      s1s1 =      s0

Where, s0, s1, s2 are the three state variables.

## Direct form I transposed

Both direct forms can be converted to an equivalent transposed form via:

• Reverse direction of each interconnection
• Reverse direction of each multiplier
• Change junctions to adders and vice-versa
• Interchange the input and output signals

(5)

In an algorithm you can implement it as:

vn = xn + s2yn =      s4 + b0 * vns4 =      s3 + b1 * vns3 =           b2 * vns2 =      s1 - a1 * vns1 =         - a2 * vn

Note that this form is very inefficient. You can easily shift the delays to the center, obtaining the direct form II.

## Direct form II transposed

(6)

In an algorithm you can implement it as:

yn = s2 + b0 * xns2 = s1 + b1 * xn - a1 * yns1 =      b2 * xn - a2 * yn

## Symbol to represent Emergency Response Team (ERT) Bedrijfshulpverlening (BHV)

Emergency response officers (ERT), or in Dutch Bedrijfshulpverlening (BHV), within companies are trained in providing both first aid and limiting and combating (small) fires. All to limit the consequences of accidents. Various icons are used to resemble these organisations. One symbol which I have seen quiet often is the combination of first aid and a fire symbol.

However, since there was not yet a vector format available, I created one. Using the established first aid and fire sign from ISO 7010.

On the left the fire symbol with the red color. On the right half of the first aid cross with the green color. The red and green color form a gradient in the middle.

## Filters in Control Systems

In this blog I want to elaborate on the various types of filters that are being used in Control Systems. These filters are often used in combination with a PI, PD or PID controller to obtain a robust controller. The filters which we will discuss are:

• Low-Pass filter
• High-Pass filter
• Notch filter

Using these four filters we can create other filter types, such as a Band-Stop or Band-Pass filter. The behavior of each filter can be captured by a transfer function in the continuous-time using the Laplace domain of either first and/or second order. We use the transfer functions to describes the filter and as such the relation between the input and the output . Throughout this blog we will write the equations in the form of their angular frequency in [rad/s], also known as radian frequency. However, we will specify filters using their frequency in [Hz]. Using the radial frequency notation results in a more visual compact formula. Additionally, it is also possible to specify the filters in form of their time constant in [s]. The following relation holds between the angular frequency, frequency and time constant.

Many forms are used within literature, one book will use angular frequencies, the other will use time-constants. Finally, for second order filters, the only filter with possibly complex poles or zeros, can be written in various ways. We will specify second order filters in terms of the damping of the corresponding frequency. It is also possible to describe these formulas using the Quality factor . Whereas describes how oscillations decay in a system after a disturbance,  describes how underdamped the system is. The following relation holds between and

## Low-pass filter

A low-pass filter is used to pass signals with a frequency lower than a certain cut-off frequency . Below the formulas for both the first- and second-order low-pass filter is given.

Herein, denotes the gain, denotes the low-pass cut-off frequency and denotes the damping. Whereas the first-order supresses with 20 [dB/dec], the second-order supresses with 40 [dB/dec]. Low frequent the filter gain is .

## High-pass filter

The complement of a low-pass filter is a high-pass filter. This filter is used to pass signals with a frequency higher than a certain cut-off frequency . Below the formulas for both the first- and second-order high-pass filter is given.

Herein, denotes the gain, denotes the high-pass cut-off frequency and denotes the damping. Likewise as the low-pass filter the first-order supresses frequencies with 20 [dB/dec] and the second-order with 40 [dB/dec].

A lead-lag filter, also known as a lead-lag compensator, is often mainly used for phase compensation rather then magnitude. Below the formula for a lead or lag filter is shown.

Herein, and denote the frequency of the pole and zero, respectively. The filter functions as a lead filter if   and otherwise as a lag filter. The filter has its maximum or minimum phase at . Finally, at the filter has a gain of or in case of a lead or lag filter, respectively. Naturally, the filter can be cascaded with itself by which a the filter can be a lead and lag filter simultaneously.

## Notch filter

A notch filter is often used to filter undesired resonance peaks. Below the formula for a notch filter is shown.

Herein, and denote the frequency of the pole and zero, respectively. Likewise, and denote the damping of the pole and zero and is as usual the gain. When the notch will target one specific frequency. The gain at that frequency is given by . When the notch filter is also referred as a skewed notch and the difference between gain at low and high frequencies is given by .

## Getting things done

A while ago I read the book Getting Things Done (GTD) written by David Allan. In my own personal workflow I was already applying GTD. However, after reading the book I further refined my personal workflow. My fellow colleagues were interested and also in need of GTD. Therefore, I made a short presentation about my own personal workflow, with tips & tricks. Feel free to use the presentation for your own benefits.

## Your own Happy Salmon game

Recently we had a game night with some friends of mine. At the start of the night we played the game “Happy Salmon“. It is a very simple game but really energetic. Every player gets a set of cards. Each card resembles an action. The goal is to get rid of your cards as fast as possible.  You will have to find another player with the same action and perform it. To find another player you simply shout your action out loud in the open. The actions are either:

1. High five, players high five each other
2. Pound it, players fist bumb each other
3. Switcheroo, players switch places
4. Happy Salmon, players flip there hands against each other very fast, like two fish splashing.

The following video describes the chaos in my living room when we played the game.

As you can see the game is very energetic. However since we simply threw our cards in the air these would most likely do not hold that long. Therefor, I created my own “Happy Salmon” such that I could simply print out, cut it in pieces, and would not have to worry about cards being destroyed. In the process of creating these cards I also added some more actions. These new actions will make the game more challenging when playing with a large crowd.

The cards background are transparent, meaning that if you simply use colored paper you will nice colored cards. Most pictures are self explaining but nevertheless, the following new actions are defined:

1. Bro Bump, more or less the same as pound it but only with the knuckles and on shoulder height as in the picture.
2. Bro Shake, handshake in the air
3. Pinky Swear, pinky swear with one another
4. Hug, bit more intimate but should be fun nonetheless
5. Handshake, seems obvious
6. Teamspirit, for this action you need three people instead of two. You put each other hands on each other and cheer afterwards, something like, https://www.youtube.com/watch?v=jGmp3zdRLyY
7. Teamwork, for this action you will need four people instead of the regular two. Simply hold each others arms as shown on the picture.

The cards are simply created in office. Below you can either download the source file or download the original card set or the card set with the new actions. Both files are for one player.

Have fun and good luck!

In August I went on holiday to Sri Lanka. During this trip I wanted to do some landscape and long exposure photographing. A tripod is really necessary for the latter. Furthermore, it was also a good excuse to myself to justify the reason to buy a tripod. However, as with any product, there are various on the market and sometimes it is difficult to find the best buy. Each one of them have different features and specifications, such as, expensive versus cheap, light versus heavy, small versus big, et cetera. As with most of the products which I buy I tried to minimize the price but maximize the features. The two most important requirements which I wanted to optimize, besides the cost, were

1. Minimize the weight of the tripod but ensuring the stability and endurance of the tripod
2. Maximize the unfolded height of the tripod but minimize the folded height

Based on those criteria you are quickly directed to the tripods which are branded in the market as travel tripods. Below a table with the tripods which I took into consideration.

Manfrotto
BeFree
travel
Sirui
T-025X
Oben
CT-3535
Minimal height [cm] 34 0 10.5 21.8
Maximal height [cm] 144 162.5 147.5 131
Folded height [cm] 40 39 31 30.5
Weight [kg] 1.4 1.6 0.9 1.1
Maximum load [kg] 4 8 6 4
Material Aluminium Aluminium Carbon Carbon
Head mount? Y Y Y Y
Quick release? Y Y Y Y
Monopod? N Y N N

After balancing the advantages and disadvantages I decided to go for the MeFoto Roadtrip. For several reasons:

1. For one it had good reviews on the internet, one particular which I liked was the review by Jason in the YouTube video below, which I also recommend too you to watch.
2. The tripod was not too expensive compared to other tripods.
3. It had the highest unfolded height
4. Of all the tripods in the table above it is the heaviest, however, I considered 1.6 [kg] still as lightweight.
5. Because I wasn’t planning to use the tripod on a daily bases I decided that an tripod of aluminium, instead of a carbon fiber one, would be durable enough
6. The bar to which the camera is attached has a hook on the bottom to which extra weight can be added to increase the stability of the tripod. Along with the feature that the bar could be mounted upside down, which added to possibility to take photo’s directly at ground level. Were two features which I particularly liked.

Apart from the reasons above the MeFoto Roadtrip had also most of the features which other tripods featured, therefor the decision was made.

If you are ever looking for a reason to buy a tripod consider the following reasons:

1. a tripod helps when using long exposures, for instance, you will need this when doing astrophotography.
2. taking time lapses, panoramas, panning and videos become a lot easier since you have great support for your camera.
3. when using a tripod you actually think a lot more about the framing of your shot, this is because everything takes a bit longer, setting up the tripod, adjusting, et cetera.
4. self portraits are of a higher quality then when using a selfie stick.

## Digital Control Systems 1.02

In the previous blog we introduced the various types of signals present in a digital control system and highlighted the pros and cons. In this blog we take a a closer look at the digital control system.

A digital control system, can only cope with digital signals. That is because it is inherently discrete in time and space. This is caused by the processors clock rate and due to the finite word length of a digital system. For instance, a 32 [bit] computer which runs at 4 [GHz] has a time resolution of 0.25 [ns] and the value of an unsigned integer can only range from 0 to 232 − 1.

Figure 1 shows the digital control system in its most elementary form. Herein $\mathcal{S}$ is the sampler. The sampler converts the analog output signal of the plant $y(t)$ at time $t \in \mathbb{R}$ to a digital measurement signal $y[k]$ at discrete-time $k \in \mathbb{N}$. As mentioned in the previous blog, the digital signal is obtained by sampling and quantization of the analog signal. In final, $\mathcal{H}$ denotes the recronstructor, also known as a digital-analog convertor (DAC), it converts the digital control signal $u[k]$ provided by the controller to an analog control signal $u(t)$.

# Sampler

Figure 2 shows that the sampler exists out of two devices namely; i) a sample and hold (SH) device and ii) a analog-digtal convertor (ADC).

The SH device knows two different states. The first state is called the track state at which the analog input signal is tracked by the SH device. The track state is also refereed to as sample state. However because of the ambiguous meaning of the word sample we will use the track, which is also commonly used in literature. The second state is called the hold state at which the analog input signal is being kept constant for a short period of time. The hold state is activated when the hold command is given. During the hold state the ADC is able to process and digitize the signal. The hold command can be triggered by any logic device. While there are many more aspects and subtleties to be considered with a SH device this gives a summarized overview of its functionality.

Various different strategies exists at what time instance $t_k$ the hold command is triggered. These are called sampling strategies.

1. Periodic sampling; the sampling instances $t_k$ are equally spaced, that is to say $t_k = kh$ with $k \in \mathbb{N}$ and $h$, given in [s], being the sampling period. See also Figure 2(a). The sampling period $h$ is often also denoted as the sampling rate or sampling frequency $f_s$, given in [Hz]. It is related to the sampling period by $h = \frac{1}{f_s}$.
2. Multi-order sampling; a pattern of sampling instances $\{t_k\}$ are repeated periodically, as a result $t_{k+r} = t_k$. See Figure 2(b).
3. Event-based sampling; the sampling instances $t_k$ are generated based on a event in the system. For instance, when a certain measurement threshold has been crossed. See Figure 2(c) in which the signal is sampled at every $\pm0.4x \pm 0.2$ value.
4. Random sampling; the sampling time instances $t_k$ are chosen at random, see Figure 2(d).

Periodic sampling is the most common in industry. That is because of several reason; i) most deterministic behavior, ii) extensively been researched, iii) easiest to model and iv) easiest to obtain key performance indicators, for instance, in time- and frequency domain. Finally, proofing stability for the other sampling strategies is much harder then for periodic sampling.

## Digital Control Systems 1.01

Digital control systems never did get enough attention during my Master System & Control in my opinion. In the various courses which I was taught, continuous-time control systems were always examined, but almost never digital control systems. For most courses this is also perfectly fine. However, you would expect that there would be also a more in-depth course about digital control systems into the curriculum. Especially, since almost all control systems are a digital control system.

I remember a course in which each group had to program a robot to convey pizza’s from one cabinet to another. A group mentioned, during their presentation, that they used a PID controller to control the various axis of the robot. I knew all the groups had designed their control algorithms in the continuous-time domain, therefore I asked; i) what discretization method(s) they had used, ii) if they had check the stability and iii) if they had checked the robustness (phase, gain and modulus margin) of their digital control system with respect to the continuous-time domain controller. Unfortunately none of my questions were answered. This disappointed me and was an acknowledgement of my opinion that not enough attention was given to digital control systems. Since this was one of the last courses given before one started their internship and graduation.

For the above reason, I will do a couple of blogs about digital control systems. I will try to focus on a single topic each blog and keep it clear and easy to understand; “If you can’t explain it simply, you don’t understand it well enough.”. In this first blog I will briefly go into the pros and cons of digital control systems and its analog counterpart. Followed by the introduction of the various type of signals that are present in a digital control system.

# Pros and cons of digital control systems

Below is a list of pros and cons for both digital as well as analog control systems. Remark that there might be many more and that some pros or cons are subject to opinion, experience or interpretation.

Analog control Digital control
Pros
• Robust; do not (often) break down
• Continuous processing; no inherent bandwidth limits
• Hard to modify; time-consuming, hardware needs to be rebuilt
• Flexible; ability to create complicated controllers, easy to modify and fast to develop, less susceptible to aging and environmental variations
• Robust; performance or safety can be monitored, errors can be dealt with appropriately
• Diagnostics; on-the-fly testing, parameters can be adjusted, measurement signals can be stored
• Low cost
Cons
• Slow development; difficult to develop accurate designs due to tolerances in components
• Complex: difficult to create complicated controllers, also hard to modify, testing alternatives is difficult, hard to build in intelligence, difficult to do multi-input-multi-output control
• Disruptive noise
• High cost
• Discrete; signal might be inaccurate due to finite word length, time delays in control loop, discrete controller, stability might be an issue
• Complex; complicated controllers, difficult to obtain a high bandwidth

While analog control systems have considerable disadvantages the flexibility of digital control systems stands-out. The latter made sure that companies adopted digital over their counterpart because it opened multiply doors. For instance, the rapid development of a complex controllers which incorporated optimization algorithms to maximize performance and profit. All created at the tenth of the costs for the same analog control system.

# Types of signals in a digital control systems

The main disadvantage of digital control systems is found in the fact that one has to deal with discrete variables instead of continuous ones. Consequently, let us define the different types of signals. A Continuous-time signal is a signal for which every point in the time domain, this can be infinitely, an amplitude is defined. Similarly, a discrete-time signal is a signal for which only a sequence of points in time an amplitude is defined. Note that these points in time do necessarily have to be equidistant. In case it is, the signal has an associated periodic interval. Likewise to the domain, signals may also be continuous or discrete with respect to their range, i.e., amplitude.

Summarized; in general signals can either be continuous or discrete with respect to their domain or range. Herein, the domain is in general time, in case of control systems and the range can be anything; Voltage, Amperes, Newtons, meter per second, et cetera. Figure 1 shows the four possible combinations.

In Figure 1(a) an analog signal is displayed, which is both continuous in time and amplitude. Figure 1(b) shows a sampled signal; continuous in amplitude and discrete in time; Figure 1(c) the quantized signal, discrete in amplitude and continuous in time. Finally Figure 1(d), the digital signal. This signal is both discrete in time and amplitude. Remark: the exact definition of a quantized signal and sampled signal are often ambiguous. Often it is implicitly assumed that a quantized signal is also sampled, e.g., discrete in time. Likewise, the sampled signal is sometimes in explicitly assumed to be quantized as well. Lastly, the digital signal can be obtained by sampling and quantization of the analog signal.

We have read about the pros and con, and defined the different signal types present in a digital control system. Conclusively, I want you to point to the books in the references below, these are the best literature references in this field. I also use them as a reference for these blogs, and will try to point or refer to a chapter or section from the book when addressing a certain topic. In the next blog we will focus on the different system components of a digital control system.

###### References

[1] Levine, William S., ed. “The Control Handbook: Control System Fundamentals”. CRC press, 2010.
[2] Åström, Karl J., and Björn Wittenmark. “Computer-controlled systems: theory and design”. Courier Corporation, 2013.
[3] Franklin, Gene F., et al. “Feedback control of dynamic systems”. Vol. 3. Reading, MA: Addison-Wesley, 1994.
[4] Wittenmark, Björn, Karl Johan Åström, and Karl-Erik Årzén. “Computer control: An overview”. IFAC Professional Brief, 2002.
[5] Ogata, K. “Discrete-Time Control Systems”. Pearson Education, 1995.

## Maintaining an overview of your financial expenses

At some point one you will want to keep track of your expenses to gain insight where you can save money. There are many websites and programs which offer insight into your expenses, for instance, YouNeedABudget, MoneyDashboard, GNUCash. However, for following three main reasons I decided to simply create my own expenses spreadsheet using Microsoft Excel.

1. The programs often have a learning curve and you have to adapt to their way of working.
2. I wanted to use a tool of which I can be almost certain that it will still exist in +20 years.
3. Sometimes you will find yourself in the spot in which you want to have insight into some details. But, unfortunately these are not (directly) provided by the tool. Therefor I wanted to be able to program myself to gain insight. However, this still should be fairly simple to do.

Now let me tell you what my spreadsheet provides. Since I wanted to categorize my expenses I created one sheet with categories and subcategories. To keep track of all the transactions, a table was created in which all main transactions details are logged. The table has the following fields: bank account, type of account (saving or payment?), date, type  (income or expense?), amount, currency, kind (variabel or fixed?), category, subcategory and remarks. While there is a currency field, it is not used yet. The with main reason for this is because fortunately I do not have to deal with money different currency types. To gain insight into the data from the table, three pivot tables and charts were created. Using the pivot tables and charts, which are semi-interactive, one is able to, for instance, zoom-in in a particular category or time stamp. To finalize, I created a kind of dashboard in which all income and expenses data is summarized per month. First details are displayed about my balance of my payment and savings account. Followed by all the expenses details, sorted by category. Using the outline group functionality one is able to open the category and list the subcategories for that month. For each category and subcategory I show its portion (in percentage) with respect to all expenses, the median per month and the average per month. Using conditional formatting this data is also visualized to give a overview, such that you are able to identify the ratios and relationships quickly. sparklines are being used to show the trend of the expenses through out the year. Concluding, the dashboard sheet makes sure that all the data and details are visible at one glance but still manages to dive into details.

You can download an example with dummy data of the Excel sheet over here: Financien (example)