# Continuous or Discrete

I am new to robotics and control and I have been thinking about how to deal with problems in real life. I have passed a course in control, but I do not have any idea about control for discrete/digital systems.
There are a lot of robots and in general dynamic systems which are controlled by microcontrollers or computers with some software, i.e. simulink. Usually there are sensors which send feedback to the microcontroller or the computer and the controller sends a signal w.r.t the input signal from sensors. I was wondering how we decide if the system is discrete or continuous? How one can decide if he should use discrete or continuous blocks in simulink to control a dynamic system. Does it really matter which one we use?
After all computers are digital and I think it is easier to work with digital signals and also do we really have continuous signal? I have not passed any signals course, so my questions might be really easy. I did not find any other place for my question.

• At some level or the other, everything that goes through a computer/microcontroller is discrete. Even the seemingly continuous signals are sampled after a discrete, finite time interval to produce digital signals, which may be represented as continuous signals by some software (Simulink etc.). Dec 15, 2013 at 17:24
• @metsburg Yes, you are right. But how should one decide to model and control the system as a discrete system or continuous system. Because everything will be different, after making this decision. Dec 16, 2013 at 18:19
• for most of the blocks in the simulink you can start with them as continuous blocks. And most of the time if you go in the properties of that block you will find 'sample time' property which is set to be continuous and you can change it to something else. So usually for modeling and analyzing or design the system we start with continuous stuff. After debugging the system, we can move to discrete systems easily. Although converting to discrete has its own difficulties.
– NKN
Feb 18, 2014 at 14:16

Complex systems of differential equations governing a physical phenomenon under study are solved by means of a computer always in a discrete way, meaning that the differential equations are integrated step-wise with the integration steps decided according to some smart set of rules. This does happen therefore also within Simulink and even when you select continuous mode from the Solver panel.

What does really matter when you switch to discrete mode is that you plug in the simulation the fact that you use a real-time device (e.g. typically a controller) to deal with your task.

In simulation (e.g. in Simulink) you can even disregard the fact that you have such devices and focus on how the physical phenomena take place and evolve over time. However, whenever you have to implement the simulated controller you came up with into a real embedded system working under real-time constraints (e.g. the C++ code running on the Linux aboard your quadcopter), then you have to carry out the discretization stage.

A discretized system is not an exact copy of its continuous ancestor of course, depending the differences on the transformation you applied (e.g. Tustin, forward Euler formulas). Roughly speaking, the continuous mode gives us a more informative perspective on a system than its discrete counterpart, since it embeds all the behaviors the system can expose in the limit of the sample time approaching zero. Nevertheless, a code written for a machine cannot handle explicitly the notion of such a limit and will certainly make some approximations which may or may not be valid for your problem. Thus, always remember: never be happy about your results! Even if you enable continuous mode, the outcome might turn to be a too coarse estimation of what is going on in reality.

Simulink and other modern environments allow users to:

1. focus on the physics and controller design (continuous mode);
2. focus on the design of controllers to be deployed in real embedded devices (discrete mode);
3. evaluate the overall performance of the controller along with the plant (hybrid mode), where the controller is discrete and the plant is meant to run at much faster frequency (practically continuous).

As result, a typical work flow could be the following:

1. Continuous mode: simulate the plant given the set of its differential equations.
2. Continuous mode: design a controller for such a plant by optimizing some merit costs.
3. Discrete mode: discretize the controller and validate the final performance.
4. Discrete mode: deploy the controller's law in the embedded unit.

If you are not interested in code deployment or in assessing the effects of discretization, but you'd like rather to simulate the physics, you could stay "continuous". Conversely, if you deal with systems that are intrinsically discrete, the suggestion is of course to start already in discrete mode.

Philosophically speaking, continuous vs. discrete can represent a sort of dualism in engineering like the much more famous wave vs. particle dualism in nature: a continuous signal must be sampled to be handled by a digital machine, but a discrete signal remains physically continuous because sharp transitions link the digital levels. Even a switching state can be seen as a very quick voltage transition. It depends on the level of details we are interested in.