Sync an external kicad project with a copy within a git repository

When I work on projects, I usually run into the following problem when working with PCB design and code together:

  • I set up a repository using git whose location is at X. This repository contains say, code.
  • I later use a separate design program such as Kicad and start a design project whose location in my computer is at Y.
  • I realize I would like to have my Kicad design files in the repository X for versioning purposes and to synchronize with my team members but I do not feel like changing the current location of my Kicad design directory from Y to X.


  • Change working directory to git repository
cd /path/to/git/repo
  • Make an empty bash script file in the current directory named
  • Open the file with your fave text editor. I use GNU nano text editor to edit the file

Once the file is open for editing use the

 #Include interpreter path if not in the PATH variable #!/bin/bash #sync any design files that are out of folder source_1="/path/to/external/kicad/folder/Y" dest_1="/path/to/destination/folder/within/this/git/repo/X" mkdir --parents --verbose "$dest_1" cp --recursive --update --interactive --verbose "$source_1"* "$dest_1"


  • #!/bin/bash

    Include the interpreter program if it has not been included in the PATH environment variable.

  • source_1="/path/to/external/kicad/folder/Y"

    Stores the kicad source folder path into variable source_1

  • dest_1="/path/to/destination/folder/within/this/git/repo/X"

    Stores the destination folder path into variable dest_1

  • mkdir --parents --verbose "$dest_1"

The line above creates the directories including the parents if they do not exist. Example: ./design/Kicad may be a non-existent directory in the git folder but the command creates the parent folder /design/ first if it doesnt exist, then creates the folder KIcad after that.

cp --recursive --update --interactive --verbose "$source_1"* "$dest_1"

copy from source_1 all files and folders recursively to dest_1 only if they are updated/new and query  interactively.

  • Save and close the bash script file.
  • Now anytime I would make changes to the PCB design and I would like to put those changes in the git project all I have to do is:

    The file in the git folder is now updated and I can now then continue with my normal git workflow. Remember to add the local kicad project folder to the staging area then commit.

Guide to choosing the right ingredients for an electronic product/device.

When making business decisions about what to have in a product, the decision factor is not binary whereby the decision is based on expensive/affordable among binary options but is a mix of various factors . The factors also depend on geographical location among other factors.

They include:

  • Access to manufacturers and vendors

    An electronic product hinges heavily on the ability to source the cheapest parts that deliver the expected performance for the expected lifetime of the product thus one needs to source and compare from various vendors. The Internet has been of great help to this.

  • Ability to access design and prototyping tools

    Design tools such as Electronic computer aided design(ECAD) and mechanical computer aided design(MCAD)  tools are the link between the designer and the vendors and manufacturers. Such tools output industry standard file outputs that can be understood by all parties allowing one to work with a manufacturer and send design files using the Internet. Point to note is that some of these tools are free while others are non free.

  • Tax complexity and nature of economy

    The tax complexity affects the selling price of goods and this determines the minimum price point you would theoretically be able to sell in order to break even. The problem is further aggravated in developing countries whereby the purchasing power of a people is low and you thus have an upper limit at which one can sell  each product. The nature of the economy(Manufacturing or service) determines the legislations that are passed that affect businesses as a nation wide legislation that positively affects service sectors doesn’t necessarily affect manufacturing sector positively. complexity-fs8

Fig: Simple illustration of cost-benefit variation vs products sold.

  • Device mobility

    Device mobility is very important especially in developing countries where the mobile sector is very vibrant. The smaller and more portable the device the more favorable is its use. According to a statistical report by Gallup group[1] “Nearly two-thirds (65%) of households in 23 countries in sub-Saharan Africa had at least one mobile phone in 2013, with median growth of 27% since 2008 and median annual growth of 5%.” To put it succinctly in my words- “In a mobile world, go mobile or die!”

  • Ready access to the needed, affordable skill set

    The ability to access local skills that one can use when developing a local/ international product. Such knowledge hinges heavily on the local quality of training in the country and the incentives given to the labor market to invest in their skills for this market.

  • Marketing and shifts in marketing practices

    Go mainstream marketing or go on-line marketing?That is a common question asked. It honestly depends on the market one wishes to serve and the ability to receive statistics that one can directly relate to internal business performance. On-line marketing offers this advantages apart from the normal “Daily reach number” quoted by mainstream marketing avenues.

  • References

  1. Africa Continues Going Mobile by Bob Tortora. Gallup group. May 1, 2014.

Getting started with STM32 ARM microcontrollers


  1. Those moving from the arduino and would like to experiment with other micro controllers.
  2. Hobbyists new to the field

32 bit micro controllers are different beast from the lowly 8 bit micro controllers. The 8 bit micro controllers include the PIC 8 bit series, AVR series from microchip, the notable 8051 among others. A very notable use of the 8 bit microcontrollers among hobbyists is the arduino.

To have a feel of the arduino capabilities without saying much, here are a few videos of projects completed by other people using arduino.


A good comparison and summary of the 8 bit vs 32 bit battle, which to choose? can be found in this hackaday article. I would suggest reading that article first. Now comes the big question:

If the arduino works so well then why move on to a more complex platform?

  • Control-“With great power comes great responsibility”

There is a direct linear relationship between device complexity and degree of control.

This means that complexity increases with the number of items one has to handle. The STM32 among other 32 bit arm platforms allows you to have full control of your system which may be more beneficial in a professional setting as opposed to  a hobby one though it increases complexity. In the STM32, the most notable of this is setting the clocks on the device.

Prior to using a device peripheral, say an on chip LCD TFT controller, one has to set up its clock (Normally given in Megahertz) prior to using the device among other settings. This helps in controlling the power consumption of the device as the power consumed . A good reference of the power dissipation in CMOS circuits can be found in this Texas Instruments article


Fig: Current draw from the power rail against frequency for AHC (Advanced high speed CMOS). From Texas instruments.

Here is a sample image of the clock distribution settings one can control in the STM32.


  • Abundance of peripherals and capability

Peripherals are the items that give the microcontroller its ability to control the outside world among other functions. This is the first thing to consider when choosing a microcontroller for system design.I shall make a direct comparison of the peripherals available on the STM32 and arduino. In this case I shall use the STM32 Nucleo F446RE vs Arduino Mega.

STM32 nucleo


  • Core: ARM® 32-bit Cortex®-M4 CPU with FPU, Adaptive real-time accelerator (ART Accelerator™) allowing 0-wait state execution from Fl ash memory, frequency up to 180 MHz, MPU, 225 DMIPS/1.25 DMIPS/MHz (Dhrystone 2.1), and DSP instructions
  • Memories
    • 512 kB of Flash memory
    • 128 KB of SRAM
    • Flexible external memory controller with up to 16-bit data bus: SRAM,PSRAM,SDRAM/LPSDR SDRAM, Flash NOR/NAND memories
    • Dual mode Quad SPI interface
  • LCD parallel interface, 8080/6800 modes
  • Clock, reset and supply management
    • 1.7 V to 3.6 V application supply and I/Os
    • POR, PDR, PVD and BOR
    • 4-to-26 MHz crystal oscillator
    • Internal 16 MHz factory-trimmed RC (1% accuracy)
    • 32 kHz oscillator for RTC with calibration
    • Internal 32 kHz RC with calibration
  • Low power
    • Sleep, Stop and Standby modes
    • VBAT supply for RTC, 20×32 bit backup registers + optional 4 KB backup SRAM
  • 3×12-bit, 2.4 MSPS ADC: up to 24 channels and 7.2 MSPS in triple interleaved mode
  • 2×12-bit D/A converters
  • General-purpose DMA: 16-stream DMA controller with FIFOs and burst support
  • Up to 17 timers: 2x watchdog, 1x SysTick timer and up to twelve 16-bit and two 32-bit timers up to 180 MHz, each with up to 4 IC/OC/PWM or pulse counter
  • Debug mode
    • SWD & JTAG interfaces
    • Cortex®-M4 Trace Macrocell™
  • Up to 114 I/O ports with interrupt capability
    • Up to 111 fast I/Os up to 90 MHz
    • Up to 112 5 V-tolerant I/Os
  • Up to 20 communication interfaces
    • SPDIF-Rx
    • Up to 4 × I2 C interfaces (SMBus/PMBus)
    • Up to 4 USARTs/2 UARTs (11.25 Mbit/s, ISO7816 interface, LIN, IrDA, modem control)
    • Up to 4 SPIs (45 Mbits/s), 3 with muxed I2 S for audio class accuracy via internal audio PLL or external clock
    • 2 x SAI (serial audio interface)
    • 2 × CAN (2.0B Active)
    • SDIO interface
    • Consumer electronics control (CEC) I/F
  • Advanced connectivity
    • USB 2.0 full-speed device/host/OTG controller with on-chip PHY
    • USB 2.0 high-speed/full-speed device/host/OTG controller with dedicated DMA, on-chip full-speed PHY and ULPI
    • Dedicated USB power rail enabling on-chip PHYs operation throughout the entire MCU power supply range
  • 8- to 14-bit parallel camera interface up to 54 Mbytes/s
  • CRC calculation unit
  • RTC: subsecond accuracy, hardware calendar
  • 96-bit unique ID

Arduino Mega-R3




8-Bit Microcontroller
•Advanced RISC Architecture
– 135 Powerful Instructions – Most Single Clock Cycle Execution
– 32 × 8 General Purpose Working Registers
– Fully Static Operation
– Up to 16 MIPS Throughput at 16MHz
– On-Chip 2-cycle Multiplier
•High Endurance Non-volatile Memory Segments
– 64K/128K/256KBytes of In-System Self-Programmable Flash
– 4Kbytes EEPROM
– 8Kbytes Internal SRAM
– Write/Erase Cycles:10,000 Flash/100,000 EEPROM
– Optional Boot Code Section with Independent Lock Bits
• In-System Programming by On-chip Boot Program
• True Read-While-Write Operation
– Programming Lock for Software Security
• Endurance: Up to 64Kbytes Optional External Memory Space
JTAG (IEEE®std. 1149.1 compliant) Interface
– Boundary-scan Capabilities According to the JTAG Standard
– Extensive On-chip Debug Support
– Programming of Flash, EE
PROM, Fuses, and Lock Bits through the JTAG Interface
•Peripheral Features
– Two 8-bit Timer/Counters with Separate Prescaler and Compare Mode
– Four 16-bit Timer/Counter with Separate Prescaler,
Compare- and Capture Mode
– Real Time Counter with Separate Oscillator
– Four 8-bit PWM Channels
– Six/Twelve PWM Channels with Programmable Resolution from 2 to 16 Bits
(ATmega1281/2561, ATmega640/1280/2560)
– Output Compare Modulator
– 8/16-channel, 10-bit ADC (ATmeg
a1281/2561, ATmega640/1280/2560)
– Two/Four Programmable Serial USART (ATmega1281/256
1, ATmega640/1280/2560)
– Master/Slave SPI Serial Interface
– Byte Oriented 2-wire Serial Interface
– Programmable Watchdog Timer with
Separate On-chip Oscillator
– On-chip Analog Comparator
– Interrupt and Wake-up on Pin Change
•Special Microcontroller Features
– Power-on Reset and Programmable Brown-out Detection
– Internal Calibrated Oscillator
– External and Internal Interrupt Sources
– Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby,
and Extended Standby


As can be seen the STM32 has greater advanced peripherals out of the box such as USB, ethernet among others.

  • Greater computational capability per Watt


  • Availability of cheap debugging tools on the STM32 and other ARM platforms compared to the arduino.

This gives one the ability to see what the program is doing and instructions it is performing in real time. Even the 15 dollar Nucleo board above has an on board debugger.

  • Code portability across vendor devices

Because of (CMSIS)Cortex Micro controller Software Interface Standard. Code is more readily portable among devices belonging to different vendors. A good case for this is the recent semiconductor company mergers that have been shaking up the industry. In case you were to use an Atmel micro controller found in the arduino and Microchip acquired Atmel. If Microchip decided that it would EOL(End of life) a product line that is  in your 10 thousand products, that is a bite in your posterior! Ouch. Back to design! Of course this may not happen but it is good to be open to the possibility.

As opposed to this, the same arm core that is in the STM32 can be found readily available in other vendors products such as NXP, TI among others.

Final thoughts

The STM32 is a great device for moving onto more complex designs where the time and cost complexity of having an 8 bit solution is outweighed by the benefits of a 32 bit solution at the expense of greater complexity but more control.

Grab an STM32 Nucleo from mouser when you can.

Note: I am not affiliated to any of the aforementioned companies.










Record and share terminal sessions with asciinema

Asciinema is the perfect tool to share terminal sessions and it is one that we regularly use at Bitsoko to share a terminal workflow or record terminal behaviour.

You can find the asciinema website here.

Asciinema package is available in the Ubuntu repository in Ubuntu 16.04. It may not be bleeding edge as with any repository package but it works well out of the box.

To install asciinema on Ubuntu using the Ubuntu repos, run the following:

sudo apt update
sudo apt upgrade
 sudo apt install asciinema 

To start a record session:

asciinema rec

To exit from a record session:


A sample record session of mine can be found here.

Understanding digital delay measurement parameters

There are times when I would need to measure relative propagation delay characteristics of digital waveforms my scope. Usually i would resort to the use of manual cursors until I peeked at the  measurement delay menu and wondered the meaning of FFR, FRF, FFR among other parameters.

More so I did not find any articles on the subject so I decided to jot down what I had learnt as this can be a problem especially when the scope in reach does not readily describe the measurement parameters visually.



Each delay measurement is described by a 3 letter mnemonic ABC Examples include those in the scope screen shot above such as FRR, LFR, FFF and so on.

In the case of an arbitrary delay measurement ABC, this is what each letter means:

  • A-Refers to First(F) or last(L) edge of channel 2 in the oscilloscope view. It is closely related to C, the type of falling edge on channel 2.
  • B-Refers to Falling(F) or rising(R) edge of channel 1.
  • C-Refers to Falling(F) or rising(R) edge of channel 2.

Note: Every digital delay measurement is related to the first B edge of channel 1 so it is omitted in ABC.



This is what each of the 3 letters mean in 2 of the 8 cases:


  • F-Refers to First(F) edge of channel 2 in the oscilloscope view
  • R-rising(R) edge of channel 1.
  • R-Refers to rising(R) edge of channel 2.

This measurement measures time delay from the first rising edge on channel 1 to the first rising edge on channel 2 in the scope view .



  • L-Refers to Last(L) edge of channel 2 in the oscilloscope view
  • R-rising(R) edge of channel 1.
  • R-Refers to rising(R) edge of channel 2.

This measurement measures time delay from the first rising edge on channel 1 to the last rising edge on channel 2 in the scope view .



The rest should now be fairly easy to figure out.

Lossy image color space reduction with pngquant

As a website maintainer one usually needs to reduce the average image file size on a website in order to save bandwidth. A tool I just started using on linux is pngquant to reduce the size of my site’s PNG images prior to upload. This is based on a Nairobi linux users group thread.  Pngquant also is available for windows and mac on their website.

In the case of JPEGs I manually convert them to PNGs using gimp or use the convert tool in a one line command to automatically convert all JPEG images to PNGs in a given folder as in this post here.

 convert *.jpg *.png 

Install pngquant and via terminal. I use Ubuntu 16.04.

sudo apt install pngquant

I then use pngquant to reduce the all PNG file sizes in the folder as detailed here.

 pngquant --speed 1 --verbose *.png 


The input image file from a previous post is thus reduced from 47kB to 23kB. Here is a direct visual comparison below: