Posts

USB with STM32

Image
  USB - basic description: USB is probably the most common interface nowadays. Possibly due to the versatile protocol which can handle many different peripherals: flash drives, printers or keyboards... Also, it is self-configuring (no data format or speed needs to be selected), reliable (no data lost during transfer), and pretty fast. Since this protocol is so versatile software is not simple and it's not trivial to implement it on your own. Fortunately, this is also a reason why there are ready-to-go libraries for this protocol which takes care of all complicated and specific aspects of implementation. In this post, I want to show how to use the STM library for USB and how to modify it to use more than just one class - create a simple "composite" device. How to get STM32 Library: For USB there is always one host and one or more devices connected to it. STM can be programmed as both but for now, we will discuss only the device option. Because the USB standar

ESC protocols overview with implementation on STM32

Image
 What is ESC protocol? When our flight controller calculates new values for each of the motors they need to be sent to ESC microcontroller which can then process these values and control MOSFETs. How exactly signals are received and then send to motors is ESC's software secret, which is another really interesting and complicated topic. For now, let's know that we can not control the motors or even MOSFETs from our FC, we need to send new values between two microcontrollers. And here is our topic: how to exchange this information efficiently and correctly?   Analog way The oldest and probably the most recognizable protocol is PWM signal, taken from servo controlling. All the analog protocols are based on this signal. Period and duty cycle changes, but the idea remains the same: the FC sends a signal, and the ESC measures the time of the high and low signal, and this measured value is treated as a new set for the motor. The main features of this approach are: simplicity of imp

Filters - Theory

Image
 Filters  In this post, I want to present the theory needed for digital filter design. Firstly, a quick description of mainly used filters in the continuous domain - I want to give you some intuition in interpreting the transform functions. Next, I will present practical discretization from the '$s$' domain into the '$z$' (discrete time). Finally, a difference equation will be provided which can be directly programmed on any microprocessor. In a future post, I will show the possible implementation of described filters. In essence, the filter should block undesirable frequencies and let others pass through without distortion. For our applications, we can divide filters into 4 main categories: Low-pass filters High-pass filters Band-pass filters Notch filters Low-pass filter As the name suggests this filter allows low frequencies to pass and suppress high ones. The simplest LPF is a system with one pole: \begin{gather}H(s)=\frac{\omega_{0}}{s+\omega_{0}}\end{gather} A typ