CD4017 and NE555 Light Chaser Circuit

 Author:   Posted on:   Comments
This is the classic circuit that uses NE555 timer and CD4017 counter to generate a sequence of pulses. If these pulses drive LEDs, a chaser can be built (also known as water flowing light). It can be used for entertainment purposes or for various light signaling. The following circuit uses 10 LEDs that turn on in a regular sequence. This is the maximum number of outputs. If you need less than 10 output channels, CD4017 features a reset pin that is connected to ground. The following output pin after the last used pin can be rewired to reset (after disconnecting it from ground). Thus, once the pulses sequence reaches the reset pin, CD4017 will start over again, limiting the number of output channels.

NE555 is configured as an astable multivibrator. Oscillation frequency is rather low for this application. It is determined by R1, R2+RV1 and C2. With the values used for this circuit, it can be adjusted between 10 and 65 Hz. The duty cycle is close to 50%. If you want to calculate it yourself, use this tool.
CD4017 and NE555 Light Chaser Circuit

Improved Arduino Code for Unipolar Stepper Motors

 Author:   Posted on:   Comments
A stepper motor is a brushless electric motor that rotates in small equal steps, as opposed to the continuous rotation of regular motors. It has the ability to rotate a predefined number of steps, being made of multiple coils that are energized in regular sequences by trains of digital pulses. Unipolar motors use two coils, each of them having a center tap. The center taps from both coils connect to a power line and the remaining four coil terminals are powered sequentially (5 wires).

A simple transistor driver, motor connections and driving methods were discussed in the previous post: Unipolar Stepper Motors: Arduino Code and Driver. Some basic C functions were provided there. But, those functions are too basic for most usage scenarios. The motor can be driven only in 4-step increments and you can't change rotation direction. In this post, I will explain further the driving methods and I will generate driving pulses programmatically, with the ability to move in 1-step increments and change the rotation direction.

Set up STM32 "blue pill" for Arduino IDE

 Author:   Posted on:   Comments
The "blue pill" is an STM32F103 based development board. Although it is less popular, the board is cheaper than an Arduino Nano. More than that, STM32F103 is a device with Cortex-M3 ARM CPU that runs at 72 MHz, 20 kB of RAM and 64 or 128 kB of flash memory. The microcontroller (MCU) has USB port, two serial ports, 16 bit PWM pins and 12 bit ADC pins. It runs at 3.3V, but some of its pins are 5V tolerant.

Programming the board can be simplified using the popular Arduino IDE. But before this, an Arduino-like bootloader must be flashed to the board. This can be done via serial port or using the debug interface of the MCU with ST-Link tool. There are also some small hardware issues with Chinese boards that need to be fixed. This post will show a straightforward guide for setting up this board to work with Arduino IDE on Linux and Windows. The instructions below are based on STM32duino wiki documentation.
Set up STM32 "blue pill" for Arduino IDE

Unipolar Stepper Motors: Arduino Code and Driver

 Author:   Posted on:   Comments
A stepper motor is a brushless electric motor that rotates in small equal steps, as opposed to the continuous rotation of regular motors. It has the ability to rotate a predefined number of steps, which makes it useful for precision mechanical devices. To do this, it uses multiple coils that are energized in regular sequences by trains of digital pulses. The speed of these pulses determines also the speed of the motor. The pulse sequence determines the rotation direction.

There are two main types of stepper motors. There are bipolar motors which contain two coils (4 wires). To drive these kind of motors, coils are energized one after another, then polarity is changed and the coils are energized again. Tow H-bridge circuits are required in this case. Unipolar motors use two coils, each of them having a center tap. The center taps from both coils connect to a power line and the remaining four coil terminals are powered sequentially (5 wires). This simplifies a bit the driving circuit. Some manufacturers offer steppers that can be used either as unipolar or as bipolar. These kind of motors have the center taps not connected together (6 wires motor) and if the center taps are not used, the motor is bipolar.
Unipolar Stepper Motors: Arduino Code and Driver

Receive DRM Radio on Linux with Gqrx and Dream

 Author:   Posted on:   Comments
DRM (Digital Radio Mondiale) is the universal, openly standardised digital broadcasting system for all broadcasting frequencies, including the AM bands, as well as VHF Bands. The great flexibility of DRM supports all types of coverage needs – from local, regional, nation-wide to international. If you want to listen to DRM broadcasts, you need a dedicated receiver or a software radio. This post will focus on the cheaper method, the software defined radio (SDR).

SDR performs demodulation in software. The RF signal is sampled by a high speed ADC (analog-digital converter) and sent to a computer which does the filtering, amplification, demodulation and decoding of the signal. The cheapest hardware for SDR is the popular RTL2832U based DVB-T stick.

Most DRM broadcast can be found in SW bands. Here comes an important issue. The tuner from the DVB-T stick can't receive this band. One of the solution is to add a frequency downconverter. Or you can simply disable the tuner and feed RF straight to the ADC. I wrote about RTL2832U direct sampling in this post. This method has some limitations, but nevertheless it should provide satisfactory results.

Dream decoding a DRM broadcast
Dream decoding a DRM broadcast

Script to compile and install PulseView on Ubuntu

 Author:   Posted on:   Comments
PulseView is an opensource GUI for sigrok. It displays recorded waveforms from logic analyzers and oscilloscopes and it can perform various signal measurements and digital protocol decoding. Being opensource and Qt based, it is also cross platform. You can find it in the Ubuntu repositories, but the version is rather old and you'll be missing some new features and protocol decoders.

You will find in this post a script based on building instructions from official sigrok/PulseView wiki that automatically downloads, builds and installs all required dependencies and PulseView itself. The script has been written and tested on Ubuntu 17.10 but it should work on other apt based distros.

Script to compile and install PulseView on Ubuntu

Light or dark activated switch using Arduino

 Author:   Posted on:   Comments
Light or dark activated relays are useful devices when you need to automatically turn on lights or activate some other electric device when lighting decreases or increases above a threshold. Usually, to build such a device, you would use a LDR (photoresistor), some resistors to make voltage dividers, an opamp as comparator, a transistor and a relay that will be driven by the transistor.

Using a microcontroller we can design a smarter device. One that does not activate the relay at every instant change of light (flash). The same device can turn from a dark activated relay into a light activated relay at a push of a button.

The following project uses an ATmega328 board with some modules which are part of a popular Arduino sensor kit. Don't worry if you don't have that modules. They are simple circuits for which I provided schematic.
Light or dark activated switch using Arduino

Homemade PCB with toner transfer method

 Author:   Posted on:   Comments
The toner transfer method is a cheap and easy way to make your own printed circuit boards (PCBs) at home. A laser printer is used to print the design on paper. Not all paper types are suitable for this kind of usage. The paper is placed with the printed side over the copper side of the circuit board and then the whole thing is heated. Most people use with good results a common iron, but if you have a laminator, use it instead of the iron. When heated, toner melts and sticks to the surfaces. The idea is to make it stick to the copper layer. After heating, cold water is used to soften the paper which should be easily peeled off from the circuit board. A good transfer means no toner remains on the paper. Once this is done, the board can be etched using whatever method you want (ferric chloride for example).

This method is widespread among hobbyists because is cheap and easy. However, for some, the results are unsatisfactory and variable. I will share some of my experiences with this method.
Homemade PCB with toner transfer method incl. silkscreen
Homemade PCB with silkscreen

Virtual Audio Cable in Linux Ubuntu

 Author:   Posted on:   Comments
If you ever wanted to pipe an audio stream from an application to another, you probably know that there are some virtual sound card drivers available for Windows. But what about Linux? Well, there are a lot of options, some being more complicated than others.

You probably need to do audio piping to record an audio output or to use SDR tools which only support audio input. You don't have to use a real cable to wire the sound card output into line in. The software approach is better. There is more than one way to do this in Linux. We'll look into Pulseaudio and ALSA, the sound servers used by Ubuntu. Depending on what application you use, you may need to configure the virtual connection on one or the other server.
Virtual Audio Cable in Linux Ubuntu

PonyProg release 3.0 comes with modern UI

 Author:   Posted on:   Comments
PonyProg is a software application that can read, write and program various memory chips and microcontrollers using the simplest possible interface: a serial port adapter. This adapter consist of only some resistors and some voltage limiting zener diodes. However, this approach has a big downside nowadays. It doesn't work with USB to serial converters. And computers with a real serial port are becoming very rare.

If you still have an older computer with a motherboard serial port, you may take into consideration building the serial adapter used by PonyProg, because it is easy to build and probably the cheapest programmer possible. The schematic of the interface can be found at the author's page (SI-Prog by Claudio Lanconelli).

Currently, PonyProg only support SI-Prog or other serial based programmers and some parallel port programmers. With serial port, it communicates by bit-banging various protocols to the signaling lines contained in the RS232 interface (RTS, CTR and DTR). It would be nice if a future version would support the modern USB based programmers (like the CH341A MiniProgrammer) which lack a good software.

PonyProg release 3.0 comes with modern UI
PonyProg 3.0 main window after reading an I2C EEPROM

CH341A I2C Programming (Windows API)

 Author:   Posted on:   Comments
CH341A is an USB interface chip that can emulate UART communication, standard parallel port interface, parallel communication and synchronous serial (I2C, SPI). The chip is manufactured by Chinese company Jiangsu QinHeng Ltd.

CH341A is used by some cheap memory programmers. The IC is somehow limited in this configuration, because the programmer makes use only of the SPI and I2C interface. A popular device is the so-called "CH341A MiniProgrammer" that you can buy for 2 to 5 USD. And this is probably the cheapest device using CH341A.

If you got a "MiniProgrammer", you may want to use for more than memory chips programming. The device can actually be used as USB to I2C converter (not only I2C, but this article will focus only on I2C function). Let's see how to use the included library and header to communicate with I2C devices.
CH341A I2C Programming

FM Radio Player for RTL2832U sticks

 Author:   Posted on:   Comments
USB TV sticks using RTL2832U chip are well known for their ability to send raw samples to USB host. This makes it possible to process various signals in software (SDR). There are many software tools for this purpose and most of them can demodulate also FM radio, with stereo and RDS support.

The problem is that these applications have full featured SDR abilities, with spectrum analysis and waterfall display. This makes them not at all lightweight. I've been looking quite hard for a simple FM radio player for my RTL-SDR dongle.

Some of the RTL2832U dongles come with FM capable player on the CD. Unfortunately not all. After some searching I was able to find a simple tool that demodulates FM stereo signal and displays RDS data. The application was most probably a test tool designed by Realtek to illustrate features of RTL2832U.
FM Radio Player for RL2832U sticks

CH341A Mini Programmer Schematic and Drivers

 Author:   Posted on:   Comments
CH341A is an USB interface chip that can emulate UART communication, standard parallel port interface, parallel communication and synchronous serial (I2C, SPI). The chip is manufactured by Chinese company Jiangsu QinHeng Ltd.

CH341A is used by some cheap memory programmers. The IC is somehow limited in this configuration, because the programmer makes use only of the SPI and I2C interface. A popular device is the so-called "CH341A MiniProgrammer" that you can buy for 2 to 5 USD.

The problem is that this device comes as-is, without any documentation or software. Drivers are available from manufacturer's website (but the site is written in Chinese). Also, some source codes are available from manufacturer. But, first of all, let's have a look at the hardware.

CH341A Mini Programmer Schematic

Heatsink for RTL-SDR dongle

 Author:   Posted on:   Comments
Some of the popular RTL2832U based DVB-T dongles that can be used as SDR tend to heat too much. As temperature increases, frequency drifts and sensitivity drops. Some dongles, especially those using R820T may stop working at all at high temperatures.

Marko Cebokli (S57UUU) used a thermal camera to measure the temperature of the dongle. He measured up to 85°C at the tuner chip (R820T). His images prove also that the dongle PCB doesn't do a good job at dissipating heat.

Although I'm using a R820T2 dongle (which is said to heat less than the predecessor R820T), I was surprised to see that after only 10-15 minutes the dongle was hot. Opening it up, I discovered that all ICs were hot (the tuner R820T2, the RTL2832U, the 1117 regulator, even the EEPROM was heated inside the closed case of the dongle).

Heatsink for RTL-SDR dongle

15-Segment FV865ND VFD controlled by HT16515

 Author:   Posted on:   Comments
FV865ND is a VFD panel manufactured by Futaba Corporation. It is designed to be used in DVD players or set-top-boxes. It can display 8 characters and it has a lot of symbols. I found it in a DVB-S2 receiver (Comag SL100HD) where it was controlled by HT16515 IC. Fortunately, the front panel of this receiver contains everything needed to power the VFD (the power is supplied via a 5V line and it is converted to filament and VFD voltage by a small transformer).

I couldn't find any software for HT16515 but its datasheet is available. The IC is 3.3V and 5V compatible and the nice thing is that the panel connector has different pins for IC supply and VFD transformer. The IC supports key scan too and the front panel makes use of only 7 keys (maximum 32). Data is sent/received via serial interface, SPI like.

15-Segment FV865ND VFD controlled by HT16515

SC75823 13-Segment LCD Display

 Author:   Posted on:   Comments
SC75823 is an LCD controller IC that is able to drive up to 156 segments. It is a 5V device that gets display data via serial bus. I found it in an auto CD player's front panel with 8 x 13 segment character LCD. I couldn't find an Arduino compatible library for it so I wrote one.

The controller only supports writing data to it. There is no key input support like other front panel ICs that can control a display and read pressed keys. The panel I'm using had each key connected in series with a different resistor and the main processor read pressed key by analog read value. Since some keys didn't work anymore, I cut the PCB and removed extra parts, keeping only the LCD panel, its backlight and the controller.

The communication protocol is probably Sanyo CCB (computer control bus), somewhat similar to SPI (it uses clock, data and chip enable signals). The controller has a pin INH that when LOW turns off the display. The library supports turning display off via this pin if connected or using software command.
Arduino SC75823 13-Segment LCD Display

A different TM1628 7-segment display

 Author:   Posted on:   Comments
TM1628 is an LED controller IC that's used mostly at DVD players front panels. The IC can control up to 7 sets of segments (separate digits) and can also process input from up to 16 individual keys. It is controlled via SPI compatible serial interface.

The only Arduino compatible library I was able to find for TM1628 is developed by Vasyl Yudin and is available on GitHub. But, I couldn't get any readable output on display. That happened because my front panel had a different segment assignment to the controller than what I found on YouTube (the display with disc icon on it).

My front panel came from TeleSystem TS5.9RX DVD Recorder and it has 7 digits and some other indicator LEDs. The PCB also contains 5 keys - but I can expand it by adding more buttons. Below is a sketch example for this front panel. It is 5V compatible so it can be connected directly to 5V levels development boards like Arduino and compatible.
A different TM1628 7-segment display

Using Magix USB-Videowandler 2 on Linux

 Author:   Posted on:   Comments
Videowandler 2 is an USB analog video capture card. There is no official driver support for Linux and the device does not work when you plug it in. According to lsusb, the device is Afatech, which is totally wrong. The kernel only loads modules for USB audio - and this is the only thing that works (the audio input appears as a separate sound card).

Videowandler 2 is based on eMPIA 2861 USB chip. Video conversion is done by SAA7113 and audio conversion by EMP202. The IDs of the device are 1B80:E349. When opening the case, you may find printed on the board UB317 Ver:A or UB315 Ver:C. The latter my be identical to Kworld UB315 but I’m not sure.

Magix USB-Videowandler 2 board. Photo by Christian Enders.

Turn RTL-SDR dongle into RTL2832U universal board

 Author:   Posted on:   Comments

The most popular RLT2832U dongles are the ones with E4000 and R820 tuners. This is due to the high frequency range these tuners have. Elonics E4000 covers 52 to 2200 MHz with a gap at about 1100 MHz and Rafael Micro R820T covers 24 to 1766 MHz.

But there are also RTL2832U based dongles with other tuners. One example is FCI FC2580 tuner (found in Trust 16738 dongle) which is capable of receiving 146 - 308 MHz and 438 - 924 MHz, limiting its use to DVB-T only! It can't even receive FM radio 88 – 108 MHz.

If you’re having such a dongle don’t throw it away. There are situations when you don’t need a tuner at all (the direct sampling mode of RTL SDR that allows direct reception of signals on frequencies lower than 28 MHz). There is also the possibility of changing the existent tuner with, for example, a satellite receiver tuner that will receive 950 to 2150 MHz.

Configure WAN port on OpenWRT/LEDE

 Author:   Posted on:   Comments
OpenWRT/LEDE are Linux based, embedded operating systems for networking devices. Besides being open source, they are highly configurable and versatile. This post will show how to configure one of the LAN ports as WAN input for xDSL routers. The problem with xDSL routers (mainly based on Boadcom platform) is that there are no opensource DSL drivers, so this function does not work.

Anyway, many DSL routers are in fact better platforms, with improved hardware, than ordinary routers. If you want to connect the router to wired LAN internet this is what you should do. I've done this on a router with LEDE Snapshot installed (the difference is that snapshots do not come with web interface preinstalled). If you have a regulare release, you can skip LuCI installation, as you already have access to the web interface of the router.

Install OpenWRT/LEDE on P.RG AV4202N router

 Author:   Posted on:   Comments
AV4202N is an xDSL modem and WiFi router based on the BCM6368 SoC manufactured by Broadcom. The CPU has 2 cores running at 400 MHz, with 64 MB RAM and 16 MB flash memory. It also has 2 USB 2.0 ports and 2 WiFi internal antennas.

Currently, although the BCM63xx platform is supported by OpenWRT, there are no releases for this device. Neither LEDE Project has released a stable build for this device, but they are offering a development snapshot [3]. The problem with LEDE snapshots is that they don't work out of the box without additional software packages (you don’t get any web interface).

But, LEDE can’t be installed on the device due to the locked bootloader. This article will show you how to use JTAG to install a different bootloader that can be used to flash OpenWRT/LEDE firmware. Part 2 details LEDE configuration and internet connection.

Note! If the mentioned device was offered to you by an ISP for xDSL internet access, doing what is described next will void the warranty of the device and make it unusable. You should not attempt to change firmware in this situation. Third party firmware does not support xDSL!
Install OpenWRT/LEDE on P.RG AV4202N router

Generate good looking PCB artwork from KiCAD

 Author:   Posted on:   Comments

KiCAD is probably the most complete opensource EDA suite. It comes with a schematic editor, a PCB designer and a 3D viewer. PCB designs can be exported to multiple formats or printed directly from the software. Although the plotting (printing) options are quite advanced, there aren't options for overlaying different layers with different colors.

This tutorial will show you how to create PCB artwork that looks good on display or print and that is intended only as a guide to the reader, not as a source for manufacturing PCB. The result will be a greenish PCB (or any color you want) with silkscreen on top of it. This is probably something you already seen in electronics publications.

There are many ways of doing this. All you need to start are the PDF files plotted by KiCAD and some image editing software (I prefer opensource tools: GIMP or some ImageMagick scripting).

Generate good looking PCB artwork from KiCAD

How to compile librtlsdr on Windows

 Author:   Posted on:   Comments

Librtlsdr is the backend used by most SDR applications compatible with the well-known RTL2832U demodulator. Using librtlsdr, you can get raw I/Q samples from RTL2832U chip, thus turning a cheap TV stick into a software defined radio (SDR).

Librtlsdr source code can be found on GitHub. It compiles easily on Linux hosts using instructions from Osmocom project. Compiling librtsdr on Windows is not that easy, mostly because the only two required libraries (libusb and pthreads) cannot be located using the same methods as on Linux (pkgconfig).

Compile librtlsdr on Windows - cmd screenshot

Make a buffered JTAG adapter (Wiggler)

 Author:   Posted on:   Comments

JTAG is an in-circuit programming and debugging interface. It specifies the use of a dedicated debug port implementing a serial communications interface for low-overhead access without requiring direct external access to the system address and data buses. The interface connects to an on-chip test access port (TAP) that implements a stateful protocol to access a set of test registers that present chip logic levels and device capabilities of various parts.

JTAG interface is supported by many devices as a convenient way of rewriting firmware (specially boot loaders) when other methods fail. Using JTAG, the ROM memory can be directly written without desoldering it from PCB to program it using a specific programmer.

In most cases, you will need JTAG access to a device with a no longer working bootloader. Otherwise, if the bootloader runs, there should be easier ways of debricking the deice. Most of the times, a device with corrupt bootloader will not display any signs of working (i.e. no LEDs turned on in case of routers, no display on front panel of set-top-boxes). Nor any ports of the device will work (i.e. no serial port response, no network detected).

Buffered JTAG adapter (Wiggler)

QSS syntax highlight in Qt Creator

 Author:   Posted on:   Comments

Qt Creator is the IDE (integrated development environment) used by Qt SDK. It is a powerful piece of software that runs on Linux, Windows and macOS. Qt SDK is able to style built applications using QSS styles, something similar to CSS standard.

Qt Creator supports not only C/C++ syntax highlighting, but basically any language through Kate Editor Syntax Highlighting files. These are XML files that define lists of specific keywords. In this way, the Text Editor of Qt Creator is able to style these keywords using a color scheme.

Qt Creator doesn't have a default QSS syntax highlight configuration file. And neither Kate. But there are two ways to add QSS syntax highlighting to Qt Creator.

QSS syntax highlight in Qt Creator