Adding Custom Libraries in KiCad (English)

When designing a PCB Prototype, the components you want to use are often not found in your favorite CAD software’s library, which made you have to add the component on your own. This short article will discuss how to make a library with all those components. For example, I’m going to make a library to help designing my LoRa APRS project design which I am improving. I have a LoRa module named “HDP14A ver 1.2”, an unusual module compared to the popular ones such as HopeRF or Ai-Thinker. To create this module, I have to make my own library. I will show you have to make it in KiCad 5

img_20180819_211330

Picture 1. Physical Shape Of LoRa Module HPD14A ver 1.2

Create Project

Open KiCad and start by making a new Project using the ‘ctrl+N’ Shortcut. Give it a name and assign it to a folder of your choice. After opening that Project, click on ‘Symbol Library Editor’ as in Picture 2

Screenshot 2018-08-19 21.24.06
Picture 2. Symbol Library Editor Button

New Library

After opening the Symbol Library Editor, you can make a new library on your own. To make one, click on File > New Library. As an example, I will make a Library and named it with lora-aprs.lib. After clicking on Save, you can choose to save it as a library for this project only, or as a global library

 

Screenshot 2018-08-19 21.42.02
Picture 3. lora-aprs Library Project

Create a Component

After making a Library, the next process is to create the component. You can do that by clicking on ‘Create New Symbol’ button, or by going to Symbol > New Symbol. You will then be asked to choose what Library is going to be used to save this new component you will create. After selecting the appropriate Library, press the OK button

Screenshot 2018-08-19 22.29.13
Picture 4. Adding New Components For lora-aprs Library

Add Pins on Symbol

After creating the components and naming it (mine is HPD14A), the next process is to add pins on the symbol. You can do that by going to Place > Pin to add pins on a new component. Adding pins can be done as shown in Picture 5. You can add the pin orientation, number, and name of the said pin. In addition, you can also change the type of the pin connection if it is an Input, Output, Bidirectional, Power, etc. After successfully adding a pin, you can configure its position and add a square with Place > Rectangle to make it available to be used

Screenshot 2018-08-19 22.31.23
Picture 5. Adding Pins On A New Component

Picture 6 shows the completed result, a LoRa module symbol with 16 pins. The pins on the symbol are grouped according to each of its function. When you’re satisfied with the result, you can save it with Ctrl+S. This component will then be accessible for your project, so you can immediately use it for PCB design

Screenshot 2018-08-19 22.57.47
Picture 6. Example of LoRa Module HPD14A – 433 MHz

Have fun trying KiCad!

Adding GitHub Libraries in KiCad (English)

KiCad has an open source library, which is one of the advantage of it. Every week, KiCad’s library is updated through GitHub from KiCad. This article is dedicated to show how to install additional libraries for KiCad, and adding third-party libraries such as Digi-Key or Sparkfun Electronics for example. Digi-Key and Sparkfun’s libraries can be accessed through the links below:

  1. SparkFun Library: https://github.com/sparkfun/SparkFun-KiCad-Libraries
  2. Digi-Key Library: https://github.com/digikey/digikey-kicad-library

As an example, this article will show how to add Sparkfun library on KiCad 5.0.0 for Ubuntu 18.04

Cloning the Library via GitHub

Library can be accessed through Github, where almost everyone can share their library and contribute to the open source library in GitHub. If there are new additions in the library, the version renewal using Git will be much easier and won’t take much hard disk space, as only the additional files will be downloaded and not the entire files. to download Sparkfun library in GitHub, make sure you have the git package and execute the command below:

$ git clone https://github.com/sparkfun/SparkFun-KiCad-Libraries.git

After you finish the download, you can see several folders which contained Library and other supplementary folders, and also additional files. The result of downloading the library is as shown in Picture 1

Screenshot from 2018-08-13 21-56-02
Picture 1. Result of cloning KiCad’s library repository from Sparkfun

Adding the Library in KiCad

After downloading the library, the next thing is to open KiCad program to add the downloaded library. But before that, make a new Project by using File > New > New Project

Access “Environment Variable Configuration” in Preferences > Configure Paths. Add new Environment Variable using the “Add” button, then give the name “KICAD_SPARKFUN_SYMBOL” and show the folder location using the “Browse” button.

Screenshot from 2018-08-13 22-13-56
Picture 2. Adding Environment Variable

After adding Environment Variable, open Eeschema (Schematic Editor) and open Preferences > Manage Symbol Libraries. Press “Browse Libraries…” and select all desired library before pressing open

Screenshot from 2018-08-13 22-22-33
Picture 3. Adding Library Symbol to Create Schematics

Open Pcbnew (PCB Layout Editor) and open Preferences > Manage Footprint Libraries. Then, press “Browse Libraries…” and select all .pretty folders which you want to add before pressing “OK”

Screenshot from 2018-08-13 22-38-44
Picture 4. Adding Library Footprint to create PCB Layout

That’s all about adding libraries to KiCad. Next time, I’ll talk about creating a simple PCB design using KiCad. Have fun trying KiCad!

Installing KiCad: Open Source PCB Designer Suite (English)

KiCad is an open-source software to create schematics, PCB layouts, and Gerber. KiCad can be used in Windows, Linux, and macOS, and licensed under GNU GPL v3. KiCad is made by Jean Pierre Charras, a professor in Grenoble University. KiCad is also sponsored by CERN and had several KiCad developments done under CERN employees. If you’re interested to develop KiCad, you can do it through CERN

I’m interested to try this application to do simple projects as a hobby. KiCad became the optimal choice because it is open source, which allows anyone to use it. Aside from that, KiCad also has a library which is updated weekly, accessible via GitHub. Adafruit which produces many modules and even development boards also used KiCad to create their products

Ubuntu Installation

I tried to install it using Ubuntu 18.04 this time, you can see the installation manual from this link: KiCad Ubuntu

I’ll explain how to install KiCad PCB v5 in Ubuntu 18.04. First, you need to add this ppa:

# add-apt-repository -y ppa:js-reynaud/kicad-5

(Ubuntu 16.04) If you’re using Ubuntu 16.04, use apt-get update before installing KiCad:

# apt-get update
# apt-get install kicad

You will download around 391MB using that command, and installing KiCad will take around 4,970MB disk space. After that’s done, you can open KiCad through a terminal or a launcher

Screenshot from 2018-08-09 19-56-37
Picture 1. The terminal after installing KiCad and its application display

I plan to start a series of articles using KiCad. I’ll talk about adding library through KiCad GitHub after this. Have fun trying KiCad!

Spreading Factor, Bandwidth, Coding Rate and Bit Rate in LoRa (English)

In the previous article, I discussed about several basic Spread Spectrum concepts while specifically talking about LoRa modulation and touching the topic regarding several parameters in LoRa. Those parameters in question are Spreading Factor, Bandwidth, and Coding Rate. The three parameters will determine how sensitive the LoRa receiver will perform and how fast the data transmission speed will be. I will shortly discuss them in this article, hoping that the readers will be able to understand the concept and implement it in a LoRa-based system

DecodingLora_Project.jpg
Figure 1. LoRa Signal Spectrogram  through SDR reading (source: DecodingLora)

Symbol

As discussed before, LoRa is a chirp spread spectrum modulation. The transmitted data, which is a symbol, will be represented by a chirp signal with a frequency range from f_{min} to f_{max}, which is shown in Figure 1. In LoRa modulation, we can configure the symbol by changing the Spreading Factor and Bandwidth parameters. According to Application Note Semtech AN1200.22, one symbol will take T_S of second to transmit, which is a function of Bandwidth and Spreading Factor can be shown with the equation below:

\displaystyle T_S = \frac{2^{SF}}{BW}

Bandwidth

Bandwidth is the frequency range of the chirp signal used to carry the baseband data. In Figure 1, the Bandwidth can be seen from the width of frequency used between f_{min} to f_{max} . Aside from that, Bandwidth can also represent chip rate from LoRa signal modulation

R_C = BW

Spreading Factor

The value of Spreading Factor (SF) determines how many chips used to represent a symbol. The higher the SF value is, the more chips used to represent a symbol, which means there will be more processing gain from the receiver side. This will allow receiver to accept data signals with negative SNR value

\displaystyle R_S = \frac{BW}{2^{SF}}

Spreading Factor shows how many chips used to represent a symbol, with an exponential factor of 2. 1 symbol may consist of N chip where N = 2^{SF} . A cyclic shift can be done to represent a bit and sent symbol. If there is N amount of chips, then the resulting symbol value may range from 0 to N-1, or that 1 symbol may represent SF bits

\displaystyle R_b = SF * \frac{BW}{2^{SF}}

Coding Rate

LoRa modulation also adds a forward error correction (FEC) in every data transmission. This implementation is done by encoding 4-bit data with redundancies into 5-bit, 6-bit, 7-bit, or even 8-bit. Using this redundancy will allow the LoRa signal to endure short interferences. The Coding Rate (CR) value need to be adjusted according to conditions of the channel used for data transmission. If there are too many interference in the channel, then it’s recommended to increase the value of CR. However, the rise in CR value will also increase the duration for the transmission

\displaystyle R_b = SF \frac{\big[\frac{4}{4+CR}\big]}{\big[\frac{2^{SF}}{BW}\big]}

Automatic Position Reporting System (English)

Automatic Position Reporting System or APRS is a digital communication protocol between a large number of amateur radio stations that covers a wide area. APRS can be used to send several tactical information, such as weather, location, messages, and several special events or emergencies in real time. APRS system is made by Bob Bruniga (WB4APR) from over 25 years ago, but this system is still actively used by many amateur radio stations

Like other amateur radio stations which still exists until now, APRS is already integrated through the internet. You can oversee many kinds of tactical information through APRS. One example of a website which shows APRS data is APRS.fi. In Picture 1, you’ll see many weather stations located in Tucson, Arizona, USA. One of the traditions for amateur radio stations in the United States is to provide public services, one of which is weather observation. Amateur radio station operators who owned weather stations use APRS to distribute the collected data

Although it’s called Position Reporting System, APRS itself isn’t intended as a GPS Tracker system. The development of APRS is triggered by GPS development back then, but APRS is actually a two-way communication system for real-time tactical communication

Screenshot 2018-08-03 18.24.54

Picture 1. Screenshot of Amateur Radio Stations’ activities in Tucson, Arizona, USA

APRS Radio Network

After knowing about APRS systems and one of its applications, let’s talk about the components of an APRS system. In APRS systems, you may hear several terminologies such as:

  1. Terminal Node Controller
  2. Digipeater
  3. APRS-IS iGate

Terminal Node Controller is the digital radio modem used in APRS. It’s usually based on Bell 202 Modem or Audio Frequency Shift Keying modem with baudrate of 1200 baud.

Digipeater is a digital repeater capable of resending data package which then allows many other stations could receive the information. Digipeater normally has a high power and placed on tall buildings to have a wide coverage area

APRS-IS iGate is an APRS connected to the internet so it can relay messages received through RF waveforms and entered them into APRS-IS server. From APRS-IS server, you can see the packages through several APRS websites or software

To enter the world of APRS, you have to own an amateur radio callsign. In Indonesia, you can register through “SDPPI Postel Kemkominfo”. You will have to enter a national exam for Amateur Radio (Ujian Nasional Amatir Radio) and if you passed, you will receive a certificate for that. Then, make sure you have the Permit to own an Amateur Radio Station (Izin Penguasaan Perangkat Radio Amatir). If you don’t want to do any transmission, tapping into APRS transmissions is allowed by anyone who has TNC and HT Radio

And that’s a small piece of information regarding APRS. I’ll add in more details on a different occasion

Sources:

  1. http://www.aprs.org/
  2. http://www.aprs.fi/

LoRa Modulation Basics (English)

LoRa is a spread spectrum modulation technology patented by Semtech. LoRa is a derivative of Chirp Spread Spectrum (CSS) which lowers data rate to improve sensitivity. If you want to place LoRa in the OSI Layer, implementation of LoRa modulation exists on the physical layer and can’t be bound to other layers above it. This allows LoRa to adapt with several robust connections. This article is made to discuss several LoRa basic concepts as a reference to develop LoRa-based systems

Spread Spectrum Technology

For someone well-versed in Telecommunication, the Shannon-Hartley Theorem is no longer something foreign. This theorem explains about the canal capacity of a communication link using specific bandwidth with noise in the canal. I won’t write in the full theorem and details, but from the derivation of the mathematical formula, we can find that by increasing bandwidth, the performance between link communication with Noise-to-Signal ratio level will improve. In Spread Spectrum technology, you’ll usually hear that Noise-to-Signal ratio compared to Signal-to-Noise ratio because the power of a signal is usually below the noise floor

Just like the Shannon-Hartley theorem, bigger bandwidth can compensate for SNR degradation in the radio canal. In a Spread Spectrum system, the sent data is multiplied with Spreading Code, also known as Chip Sequence. Chip Sequence usually has a frequency far higher than the information frequency which resulted in a wider bandwidth when both signals are multiplied. On the receiver side, the received signal will be multiplied with the same chip sequence signal to obtain the original data

psd
Picture 1. Spread Spectrum Illustration

LoRa Spread Spectrum

LoRa modulation provides alternatives for Spread Spectrum communication which are low power and low cost compared to the conventional Spread Spectrum technique. LoRa modulation uses chirp signal, which is a signal with a frequency which varies over time. By using this method, the complexity for the receiver side will be reduced. The output signal from this modulation matches the bandwidth used by the chirp signal

In LoRa modulation, the data with a certain bit rate that we want to transmit will be multiplied with a chirp signal with a certain Chip Rate. The Chip Rate is far larger than the data signal we want to send, which then became the Bandwidth from modulated LoRa signal

Aside from Bandwidth, there is also Spreading Factor. If Bandwidth shows chip rate, Spreading Factor shows how much chip is used to represent a symbol. Other than that, Spreading Factor also shows how many bits contained in a symbol

LoRa also has a mechanism called Forward Error Correction (FEC). FEC configuration can be done using the Coding Rate parameter. Just like a normal radio communication, noise can affect the performance of a system. By adding redundancy using FEC, the LoRa-based system designer can decrease the bit rate to increase the system’s reliability

To design a LoRa-based system, you have to pay attention to these three parameters to get an appropriate bit rate, decent enough range, and a nice reliability

Edit Aug 05/2018: The terminology in Spread Spectrum parameter had been corrected to make it more accurate

Bluetooth HC-05 AT Commands (English)

Bluetooth is one of the simplest communication modules which can be bought at a relatively cheap price. HC-05 Bluetooth Module can be easily found in many online shop websites around fifty thousand rupiahs. Before we further out discussion, I’ll talk about several Bluetooth basic concepts

Introduction

Bluetooth is a wireless technology standard for short-distance communication. Bluetooth uses 2.4 GHz frequency, which is a free-to-use frequency channel, with a low power limitation. Bluetooth standard encompasses quite a lot of protocols, one of which is RFCOMM Protocol. The Bluetooth Module which we usually find normally uses this protocol. RFCOMM Protocol is pretty popular because there is a lot of APIs available using this protocol. In addition, this protocol, commonly called as Emulation Port, can be integrated to many applications using RS-232 as its communication interface

Generic Bluetooth RFCOMM Modules

After knowing several of Bluetooth basic concepts, it’s time to see how Bluetooth works directly. For this demonstration, I’ll try using Bluetooth Module: Tokopedia (Disclaimer: No intention of promoting).

Bluetooth
Picture  1. Bluetooth HC 05 Module

The Bluetooth Module as depicted in Picture 1 is a Module based on Bluetooth Chip BC417. This module has several output pins such as STATE, RX, TX, GND, +5V, and EN. To use this module, it’s enough to connect the RX, TX, GND, and +5V pins.

The 5V pin, or VCC Pin, in this module is actually connected to the LDO Voltage Regulator in this Bluetooth Module Board. I tried to see what kind of Regulator is being used, but it’s pretty hard to find a datasheet for this SMD component. Before I talked about how AT programming commands are, I’ll test the serial port using this Bluetooth Module first

Connect the Bluetooth TX pin with RX Raspberry Pi, RX Bluetooth with TX Raspberry Pi, VCC with +5V Raspberry Pi and GND with GND Raspberry Pi. I’ll turn on the minicom to open the serial port (/dev/ttyS0) using baudrate 9600. The test display result should be as shown in Picture 2

Capture
Picture 2. Serial Port Receive Outcome via Bluetooth

AT Commands Bluetooth

After finished testing the Serial communication, the next thing to try is the AT Commands. Several configurations such as Bluetooth name and PIN and also baud rate could be done through AT Commands. To do that, I made a short script in Python to execute this function. Before trying this script, make sure Raspberry Pi had been installed with Python and PySerial package (python-serial)

# apt-get install python-serial

Before I give the source code from AT Command Configuration, it’s important to know that entering AT commands can be done in three ways. The first is to give 3.3 Volt input to the 34th pin in the Bluetooth Module. This will make the module enter a Full AT Commands mode, where all AT Commands can be accessed and baudrate from the module is 38400. The second method is by pressing a button before the module turned on and make sure the button is still pressed as the configuration process continues (this is effectively similar to the first method), which makes the module enter a Full AT Commands mode. The third method is that after the module is turned on, press a button on the module and keep it pressed when doing the configuration. The module will then enter a Semi AT Command mode where the baudrate is still the normal serial communication baudrate (9600 baud default). If you forgot what baudrate you had set for your serial communication baudrate, it’s better to program your Bluetooth in Full AT Command mode

# attest.py
# Sending AT commands to Bluetooth HC-05

import serial
import time

bluetooth = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=5)

bluetooth.write('AT+NAME=JosefMTD\r\n')
result = bluetooth.read(100)
print result

bluetooth.write('AT+UART=38400,0,0\r\n')
result = bluetooth.read(100)
print result

To use the program above, change “/dev/ttyS0” into “/dev/ttyACM0” if using PL011 Hardware UART from Raspberry Pi. Only use “/dev/ttyS0” if you’re using mini UART. Set baudrate according to the module’s baudrate or put in 38400 if you want to enter Full AT Command mode

To change the name and baudrate, Bluetooth module can be configured in a Semi AT Command mode, which is why my set of processes are to press a button, run attest.py script, and let go of the button when it finished

Capture1.PNG
Picture 3. Output from program attest.py

That’s all from me this time, leave a comment if you have a problem in setting up the Bluetooth