Posts

A brief overview of drones flight control software

Image
A couple of days ago I have written a blog post for embeddedrelated.com with a brief overview of drone flight controllers. If you are interested in BetaFlight, PX4, Ardupilot, Paparazzi, CleanFlight, etc,  go and check this post: https://www.embeddedrelated.com/showarticle/1260.php

3 print screens explain how setup Eclipse with ST-LINK v2

Image
This setup is for STM32F103. Choose your STM32 in target link.

CMSIS Biquad Cascade IIR Filter + Iowa Hills IIR Filter Design

Image
You are looking at CMSIS IIR Filters ( https://www.keil.com/pack/doc/CMSIS/DSP/html/group__BiquadCascadeDF1.html ), and don't know how to use it? Don't worry, this example will clearly help you. The first thing that you need to know is that Biquad Cascade DF1 use this transfer function to do filtering. y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] - a1 * y[n-1] - a2 * y[n-2] It is hard to understand how this does filtering, especially if you looking at it in the time domain. In short this transfer function use current input(x[n]), and two last input(x[n-1], x[n-2]) and output (y[n-1], y[n-2]). Each new input function calculates new output and stores all the values. That is all that this filter does. The hardest part is to calculate coefficients b0, b1, b2, a1, a2, that is where Iowa Hills IIR  Filter Design jumps in. In this example, I'll do the band-pass filter for 1 Hz. In the image below you can see, what I selected at Iowa Hills IIR  Filter Design. N...

Pixracer (STM32F427) CoreMark Score

The score is 275.34 at 168 MHz clock speed. CoreMark Size    : 666 Total ticks      : 21786 Total time (secs): 21.786989 Iterations/Sec   : 275.393585 Iterations       : 536999700 Compiler version : GCC7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204] Compiler flags   :  Memory location  : STACK seedcrc          : 0xe9f5 [536999700]crclist       : 0xe714 [536999700]crcmatrix     : 0x1fd7 [536999700]crcstate      : 0x8e3a [536999700]crcfinal      : 0xa14c CoreMark 1.0 :  275.393585  / GCC7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204] / STACK STM32F427            = 275.393585/168[MHz] = 1.63 TM4C123GH6PM   = 101.1378/80[MHz] = 1.26 It looks like it is not pure MHz what matter in MCU speed.

Tiva TM4C123GH6PM scores 101 points on CoreMark

Image
Lately, on STM page I have found out they put Coremark scores on brochures for the microcontrollers.  I was wondering what competitors scores, so I couldn't find anything for Texas Instrument. On https://www.eembc.org/ I have found out there is a source code of Caremark which can be ported on any platform, so I decided to port it on Tiva TM4C123GH6PM and test it. Here are the results: 2K performance run parameters for coremark. CoreMark Size    : 666 Total ticks      : 19775 Total time (secs): 19.774999 Iterations/Sec   : 101.1378 Iterations       : 2000 Compiler version : GCC7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204] Compiler flags   : Memory location  : STACK seedcrc          : 0xe9f5 [0]crclist       : 0xe714 [0]crcmatrix     : 0x1fd7 [0]crcstate      : 0x8e3a [0]cr...

ARM sinus lookup tables 5x faster than math.h - TM4C123GXL Cortex M4F

Image
Lately, I was working with IIR filter so in CMSIS repo I saw look-up table with sinus value. I was wondering how much faster it works then math.h sinus function. The name of the function which uses a lookup table is arm_sin_f32() which is part of  arm_math.h Lets first compare results calculated with the lookup table and math.h sin function. Result2 are from the lookup table (arm_sin_f32() -> arm_math.h) and result1 are from sinus function (sin() -> math.h). From results is seen that after decimal point 4-5 digits are similar so take care with that.  I have done an iteration of 100 000 calculation and I was measuring the time needed for math.h sin and got 9726 [ms], and for arm_math.h 2006 [ms] which is almost 5x time faster.  In the photo below I added sinus wave for both calculations. Blue is result1 and red is result2. You can see they overlap.  You can check the code on the link . 

Patch PCB antenna 7 dBi WiFi

Image
Recently I was looking for a small lightweight, at least 6 dBi gain antenna. At mouser web page I have found 25x25x4 mm patch ABRACON APAKN2504-S2448-T antenna for PCB with 7 dBi gain. I was surprised by this very nice antenna design. So I order two of them. When they arrived I was not sure how to connect to WiFi device so I started googling. There was no any special explanation how to connect it on the 50 Ohm cable, only how to connect it with 50 Ohm impedance PCB link. So I decide to connect it this way with 50 Ohms pigtails. After I connected it, I have tested it with a WiFi router, and they work very well. Figure 1 - Soldered antennas Figure 2 - Front side of antennas Figure 3 - Testing antenna with WiFi router  I will use the antenna with the u.fl connector together with CC3220SF-LAUNCHXL :)

Eclipse + Black Magic Probe + Embsysregview

Image
Is there a chance to use the Black Magic Probe with Eclipse and see the peripheral registers. Short answer: Yes it is. For peripheral registers, you will need the Embsysregview Eclipse plugin. If you have a problem to install it check my last blog post .  How setup BMP? Go to: Run -> Debug configurations -> GDB Hardware Debugging and select New Launch configuration on the top left corner. Select everything as it is on images (my example is for miniblink, you do it for your). Image 1 - Main

Embsysregview - Eclipse plugin and how to install it

Image
In the last couple of days, I was trying to install Embsysregview for my Pixracer (STM32F427VI) to do debugging with Black Magic Probe, but it wasn't possible to install it because there is a problem inside download links when you trying to do it over Eclipse marketplace. Image 1 - Error when you try to install Embsysregview from Eclipse market

Cortex-debug powerful extension for VSCode

Image
In the process of working on a new example (timer), I had some difficulty to make it work. I've found out it that my current setup for Black Magic Probe doesn't work with interrupts. Luckily, in the process of debugging I have found a very useful tool for debugging Cortex MCUs which supports Black Magic Probe debugger and with it, everything works much better because it has preloaded setup for BMP. The name of the extension is  Cortex-debug . In the time of writing this text version, 0.1.21 doesn't support powering board over BMP (monitor twpr enable) so I modified the source of the extension to enable it. Link to the modified extension is here . If you are Linux user you need to unpack this zip in to /home/your_user_name/.vscode/extensions/ and restart VSCode. Now your Pixracer (or other board) will be power up before you start debugging it. Another useful thing you can do is to add a static name to your black magic probe instead check i...

Example - miniblink on Pixracer

Image
I have created my new repo pixracer-examples in the hope I'll find a time to create as much as possible examples for Pixracer. For now, I've created miniblink. Link to repo: https://github.com/Igor-Misic/Pixracer-examples Editor: Visual Studio Code (include building and debugging config) Debugger: Black Magic Probe

Config for VS Code debugger and Black Magic Probe + Pixracer

Image
Maybe you like VSC but you don't know how to config. I have tried many different configs and find out this work best for me. I have tested it with miniblink from libopencm3 . Configuration: { "version" :  "0.2.0" , "configurations" : [ { "name" :  "(gdb) Launch" , "type" :  "cppdbg" , "request" :  "launch" , "miDebuggerPath" :  "arm-none-eabi-gdb" , "targetArchitecture" :  "arm" , "program" :  "${workspaceFolder}/miniblink.elf" , "args" : [], "stopAtEntry" :  false , "cwd" :  "${workspaceRoot}" , "environment" : [], "externalConsole" :  true , "MIMode" :  "gdb" , "setupCommands" : [ {  "text"  :  "target extended-remote /dev/ttyACM0" }, {  "text"  :  "monitor tpwr ...

Pairing TM4C123GXL with VL53L1X and VL53L0X

Image
Here is the git repo where I paired two Time of Flight (ToF) sensors VL53L1X and VL53L0X to the TM4C123GXL development board.

How connect Pixracer with Black Magic Probe

Image
Here is how to connect your Pixracer with Black Magic Probe. You can see images with proper wiring.

Why invest in Croatia

Image
 There is a lot of money fluctuating around, looking for good investment opportunity. But a good percentage of them finish nowhere? In last year I explored a little bit Croatian embedded situation and people inside that field. I discovered one precious information. You can buy all Croatian embedded people very cheap! If you have a good idea and the extra money you can easily open company in Croatia, set salary price over average Croatian salary in this filed and you will have all those people in your company. And what is the best part? you will pay that the half price than in the US or in western Europe! The only thing you need to have is money, a good idea and good knowledge of creating a Business and you are ready to create a large technology company. The average salary in Croatia for the embedded software developer is under  32480 € gross with all expenditures to the state. And believe me, Croatian developers are good developers. As example you can see c...

EK-TM4C123GXL - Configure the I2C Module to Transmit a Single Byte as a Master

Image
Name of this blog post is the name of chapter 16.4.1 from ARM Cortex M4 TM4C123GH6PM  microcontroller datasheet (MCU on EK-TM4C123GXL board). It will be showed how to setup I2C1 from scratch. There is a way to do this with functions for set registers parameters but in this blog post, it will be done by writing directly into the register address. It is decided that way because it is the way how drivers are done.   The EK-TM4C123GXL has support for 4 I2C serial computer buses. First, we need to unlock GPIO_PORTA register and I2C1 register. To do that we need to do that over System Control Register addresses.   Image 1 - System Control Register Map 1. Enable the I2C clock using the RCGCI2C register

Inside Turnigy AE-65A

Image
If you are trying to flash your Turnigy AE-65A ESC but you are not sure what MCU is inside, here is the answer. Inside is Silicon Labs C8051F310 MCU, the same one as inside Turnigy AE-45A. So that means you can flash it with BLHeli firmware for 45A version? I'm pretty sure the answer is yes but I didn't test it yet. If I do that I will post it here. Here are some pictures from inside. I have checked pinouts and they are same as those on AE-45A. Image 1 - C8051F310 with pinouts for C2 interface Link to datasheet: https://www.silabs.com/documents/public/data-sheets/C8051F31x.pdf   Image 2 - C8051F310 Pinout Diagram Image 3 - before disassembling Image 4 - the bottom side of the upper part after disassembling 

List of all embedded systems companies in Croatia (2017)

Image
If you are an Embedded system developer and you are looking for a job in Croatia. Here is the list of all companies which works with Embedded systems.  I hope this will help you to make your decision.

AUTOSAR and CRC calculation

Image
If you find yourself reading AUTOSAR document Specification of CRC Routines you are probably looking for a solution on how to implement it in your code. This is short instruction without explaining how CRC works. It includes working CRC code with examples from the mentioned documentation. Explanation of CRC8 CRC 8 it means, the polynomial of CRC is 8 bit long.  Explaining chapter 7.2.1: CRC result width - it is the return value, it says it is 8 bits long Polynomial - this value is used to calculate CRC. In this case, it is 0x1D Initial value - CRC calculation start with this value. It is usually all F's or zeros.  Input data reflection - it says if the data which you want to do CRC need to be reflected or not. Example of data reflection: hex: 0x73 or binary: 1110011, reflected value is: 1100111 or hex 0x67 Result data reflected - same as input data, but the only result is reflected XOR value - result value need to be XOR-ed with this value before...

Running Nuttx RTOS on EK-TM4C123GXL

Image
This is the short tutorial on how to build and flash Nuttx, the real-time operating system on TM4C123G LaunchPad on fresh installed Ubuntu 16.04 LTS. More about Nuttx for TM4C123G LaunchPad: https://bitbucket.org/nuttx/nuttx/src/42a0796615909b301273ee30fd5af907f4253347/configs/tm4c123g-launchpad/?at=master Building Nuttx In terminal run this commands: mkdir nuttxdir cd nuttxdir git clone https://bitbucket.org/nuttx/nuttx git clone https://bitbucket.org/nuttx/apps git clone https://bitbucket.org/nuttx/tools sudo apt-get install gperf flex bison libncurses5-dev cd tools/kconfig-frontends/ ./configure --enable-mconf make sudo make install sudo ldconfig cd ../.. Without libncurses5-dev you will have the problem with kconfig-mconf, so don't miss to install it.  cd nuttx/tools ./configure.sh tm4c123g-launchpad/nsh cd .. make menuconfig Inside menu config, you need select System Type -> Toolchain Selection -> Generic GNU EAB...

Debugging EK-TM4C123GXL with Visual Studio Code on Linux

Image
If you have TM4C123G LaunchPad Evaluation Kit and you like Visual Studio Code here is how to setup debugging on this board. This is the tutorial how to do that on clean Ubuntu 16.04 LTS. ARM GCC Compiler Setup Download the latest GCC cross compiler for the ARM from here:  https://launchpad.net/gcc-arm-embedded/+download In the time of writing this text, the last one is    gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 Run this commands in Linux console. wget https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q3-update/+download/gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 tar -jxf gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 rm gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 exportline="export PATH=$HOME/gcc-arm-none-eabi-5_4-2016q3/bin:\$PATH" echo $exportline >> ~/.profile source ~/.profile sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install libc6:i386 lib32ncurses5 Without i386 architecture ...

APM2 power supply and burned Pixracer

Image
This took me some time to fix it so I decided to write a short blog post about it. The story goes in this way. Because I found out it could also work for Pixracer I bought the power supply for APM2 on eBay.  After I received it, I connected it to the battery and after to Pixracer. At first, everything seemed fine for the first 3 sec. Soon, I start smelling smoke. I unplugged the battery and find out that one small piece is burned out. You can see this part in the image below. I had trouble to find out what is the name of the part because it was burned out. Then I opened the schema and used some debugging technics on board and I found out it is the AP7365-33WG-7 linear regulator. From schema, I realized it supply power for ESP. Even with a burned regulator,  the Pixracer was still working but without ESP. The easiest way to figure out if this regulator is not working is to check ESP power led. If it is not turned on it means that the regulator is dead. With some hot...