Change default open with application in Ubuntu

 Posted by:   Posted on:    No comments

With the new Ubuntu 23.04 release I found myself struggling to find a valid answer to a very simple task. I own a 3D printer and I design stuff in FreeCAD, then export to STL and load this in Cura to slice it and produce gcode for printer. If in Windows 11 there is a 3D viewer application which opens STL files, Ubuntu doesn't come bundled with a similar app and I hate loading every STL file in Cura just to see the 3D model. However, there is fstl, which I found it to be exactly what I was looking for: it is lightweight and it opens STL files.

I installed it from default repositories with sudo apt install fstl. Although this is a GUI app, it can only be started from command line, having no desktop entry to open it from Apps. I didn't have a problem with this, since I knew I could select any executable to open a file with. However, this is is no longer true. The Open With dialog no longer allows users to choose something else besides installed applications.

Open With dialog in new Ubuntu versions
Open With dialog in new Ubuntu versions

Daisy chaining and bus sharing with shift registers

 Posted by:   Posted on:    No comments

A shift register is a digital circuit that is used to store and manipulate data in a sequential manner. It is composed of a series of flip-flops, which can be viewed as basic memory units able to store binary values. The outputs of each flip-flop are connected to the inputs of the next flip-flop in the sequence, such that the data is shifted from one flip-flop to the next with each clock pulse.

In this post I will use the 74HC595 serial-in-parallel-out shift register and its counterpart, 74HC165 parallel-in-serial-out shift register. Both are commonly employed when a microcontroller with limited available I/O pins has to control a large number of digital outputs or read a similar number of inputs (for example in home automation). What I want to show you in this post is how to daisy chain these ICs and how to make them share some control lines in order to keep the serial interface data lines to a minimum.

Shift registers circuit on breadboard
Shift registers circuit on breadboard

Drive 8-Channel Relay Module with Bus Expander

 Posted by:   Posted on:    No comments

In automation projects it is often needed to drive multiple outputs. Combine this with the reduced number of pins of a microcontroller, such as ESP8266, and you got a problem. In this post we'll explore the methods of converting the parallel inputs of a relay module to some kind of serial protocol, which allows connecting even more relays, without the need of additional control pins. I will use for exemplification an 8-channel relay module, however the methods I will show will allow you to connect more than 8 relays to the same bus.

To achieve this purpose, I have to use some kind of bus expander IC. There are a few available options here. However, as we will see, both communication protocol and output port capability are different. And even the common relay modules use a rather unusual method of turning on the relay driver transistor. I already discussed the difference between current sink and current source in the previous post. Let's use that knowledge.

8 Relay module with PCF8574 bus expander
8 Relay module with PCF8574 bus expander

I/O Interfacing with current source and sink pins

 Posted by:   Posted on:    3 comments

Current source and current sink are two commonly used terms that you will find in datasheets of microcontrollers and digital circuits. Even though most input pins of an IC nowadays are internally connected to the gate of MOSFET transistors which are voltage driven, there are situations when you have to take into account current capabilities (i.e. high speed switching or something else than a CMOS input is connected to an output pin). I'm thinking about LEDs and bipolar transistor driven devices, such as relay modules.

These inputs are current driven and need to source or sink currents to change state. Fortunately, most output pins of contemporary microcontrollers are push-pull type and can source and sink currents. This means you don't have to worry too much about the way you are connecting an LED to a digital output. But there are still in use circuits which can only sink or source currents. And if you're not paying attention to datasheet, you might very well fail to design a working circuit.

I/O Interfacing with current source and sink pins

Gas detector based on MQ-2 without microcontroller

 Posted by:   Posted on:    No comments

Nowadays people are using microcontrollers even for blinking an LED. And that is no problem, since they are cheap enough, have low power consumption and are easy to program. But there was a time when microcontrollers were expensive and hard to find. And even then, engineers were building working devices, just smart enough to do the job they were designed for. Let's try to build a "microcontroller-less" gas detector using one of the MQ sensors.

Gas sensors from MQ family are analog tin dioxide detectors which change their resistance in the presence of volatile compounds like gases or smoke. Except MQ-7 and MQ-9 which are designed for carbon monoxide detection and require alternating heater voltage, with analog output being read at the end of each heater voltage cycle, every other sensor may be used in the following circuit.

Built analog gas detector with 3D printed enclosure
Built analog gas detector with 3D printed enclosure

I/O voltage level shifting: passive down-converters

 Posted by:   Posted on:    No comments

When interfacing various devices to a microcontroller, some kind of voltage conversion is often needed. The most common voltage levels of development boards and modules are 3.3 V and 5 V, yet it is not out of the ordinary to find devices using 2.5 V or even 1.8 V I/O levels. This post will explore some of the available methods of converting I/O voltage levels to ensure compatibility between electronic modules and ICs. When I say compatibility I mean the devices connected together through a level shifter should work as expected and not cause damage to each other.

I began searching information about level shifting after a failed attempt to interface an ESP8266 board (3.3 V I/O) to an array of 74HC595-74HC165 shift registers which were required to be powered at 5 V (therefore they expect 5 V I/O). Without documenting too much, I considered 74HC would recognize high 3.3 V output from microcontroller. But that was not the case as I would soon discover. The next step was to add a MOSFET bidirectional level shifter (the ones which are commonly used for I2C), however strange behavior occurred.

I/O voltage level shifting: passive down-converters