Tuesday, November 9, 2021

Mains short circuit protection, current limiter using incandescent light bulb in series

Sometimes I fix things that are mains powered and I always flip the power switch with my eyes closed, not knowing if there's gonna be a bang or not. I prefer fireworks on holidays only. Also my soldering iron was making some weird noises and soldering with it near my head with a potential failure made me build this short circuit protection unit that can also be used to test transformers and light bulbs as a bonus. If a short circuit would to occur all that will happen would be to light up the incandescent light bulb thus protecting the equipment, you and household wiring.

Mains short circuit protection and current limiter using tungsten lamps in series

How to build a mains short circuit protection unit for testing and repairing electrical equipment and transformers

The working principle of this unit is very simple - an incandescent tungsten light bulb is placed in series with the load. If the current draw by the load is small comparative to the bulb's power, the light bulb will not glow and it's resistance will be low. In case of a short circuit the higher current draw will cause the light bulb to heat up and glow and that will increase the resistance of the tungsten filament therefore limiting the current.

When cold the incandescent tungsten filament has a low resistance (~25-50 ohms for a 75W bulb). When mains power is applied to it the filament will get glowing hot and the hotter a metal is the more agitated the electrons are, bouncing everywhere, and so creating the effect of a higher resistance when hot versus when cold.

Friday, October 22, 2021

DAC library for MCP4706, MCP4716, MCP4726 and AVR microcontrollers

This library is intended for the MCP47x6 series of DAC devices that includes MCP4706 (8-bit DAC), MCP4716 (10-bit DAC) and MCP4726 (12-bit DAC). With the included functions you can easily interface the DAC with an AVR microcontroller via I2C or TWI and write or read it's memory without the need to learn it's protocol. 

This library makes use of the I2C, TWI library that can be downloaded from down below. If you want to know more about it visit I2C and TWI library for AVR.

DAC library for MCP4706, MCP4716, MCP4726 and AVR microcontrollers

MCP47x6 DAC pinout

MCP47x6 DAC pinout

1 - VOUT: this is the DAC analog output voltage. In Normal mode, the DC impedance of the output pin is about 1Ω. In Power-Down mode, the output pin is internally connected to a known pull-down resistor of 1 kΩ, 125 kΩ, or 640 kΩ. The VOUT pin can drive up to 100 pF of capacitive load in parallel with a 5 kΩ resistive load. It is recommended to use a load with RL greater than 5 kΩ. Driving large capacitive loads can cause stability problems for voltage feedback op amps.

Tuesday, October 19, 2021

I2C and TWI (Two Wire Interface) library for AVR microcontrollers

In the last article I talked about How I2C and TWI protocol works and we saw that they are mostly the same so this library works for both I2C and TWI serial interfaces. You don't have to know every detail about how the I2C protocol works but I strongly recommend reading the article to have a general idea about it, and that way it will be easier to use this library.

At the moment only the Master mode is implemented.


Using the I2C, TWI library with an AVR microcontroller

Setting the library file

As always, first include the library file:

#include "twi.h"

Most AVR microcontrollers have two TWI modules TWI0 and TWI1 so to choose between the two there is the following line of code:

#define TWI_MODULE_NUMBER	0 // TWI module 0 or 1

The default module is TWI0.

Functions


void TWI_Init(void)

Used to initialize the TWI module. This will set the TWI bit rate at 400kHz and enable global  interrupts. 400kHz is the maximum TWI speed that regular AVR microcontrollers supports.


Saturday, October 16, 2021

How the I2C and TWI (Two Wire Interface) protocol works

I2C is a two-wire serial bus communication protocol invented by Phillips in 1982. TWI stands for Two Wire Interface and, for the most part, this bus is identical to I²C. The name TWI was introduced by Atmel and other companies to avoid conflicts with trademark issues related to I²C. Because these two protocols are almost the same I will refer to them interchangeably throughout the course of this article.

This protocol is very used nowadays by all sorts of devices such as DACs, LCDs, sensors, etc. so it's worth learning about it.

As a disclaimer I need to mention that most parts of this article contains fragments from the ATmega328, 324 datasheet and MCP4706 datasheet. I liked how they explained the I2C, TWI protocol  and since not many people read the datasheets I want to share this information with anyone interested in the TWI protocol.

If you're interested in a I2C, TWI library it can be found at this link I2C, TWI library.

Features

  • 7-bit Address Space Allows up to 128 Different Slave Addresses
  • Multi-master Arbitration Support
  • General call addressing

The I2C interface specifies different communication bit rates. These are referred to as Standard, Fast or HighSpeed modes.

  • Standard mode: bit rates up to 100 kbit/s
  • Fast mode: bit rates up to 400 kbit/s
  • High-Speed mode (HS mode): bit rates up to 3.4 Mbit/s

High-Speed mode is currently unsupported by the TWI.

Table of Contents

 

Two-Wire Serial Interface Bus

The TWI protocol is able to interconnect up to 128 different devices using only two bidirectional bus lines: one for clock (SCL) and one for data (SDA). The only external hardware needed to implement the bus is a single pull-up resistor for each of the TWI bus lines. All devices connected to the bus have individual addresses, and mechanisms for resolving bus contention are inherent in the TWI protocol.

TWI Bus Interconnection
TWI Bus Interconnection

The number of devices that can be connected to the bus is only limited by the bus capacitance limit of 400pF and the 7-bit slave address space. The SCL and SDA pins are open-drain configurations. For this reason these pins require a pull-up resistor.

Saturday, May 29, 2021

Bluetooth Stereo Audio Receiver JDY-62 module and the Bluetooth 4.0 CSR dongle transmitter

There are many solutions for streaming audio from your computer to Bluetooth devices. One affordable Bluetooth transmitter/receiver pair is presented here. With these two Bluetooth modules, streaming audio from PC is very easy.

JDY-62 is an affordable Bluetooth stereo audio receiver module with great sound qualities for the price provided the ground connection is properly made (more on this later). To send audio from PC to the JDY-62 module I have used the Bluetooth 4.0 CSR dongle transmitter that works well on Windows 10 and acts like a sound card that you can select in the media player.

Bluetooth Stereo Audio Receiver JDY-62 module and the Bluetooth 4.0 CSR dongle transmitter

JDY-62 module pinout

JDY-62 module pinout

Monday, May 10, 2021

Pinning files on LibreOffice taskbar and other apps in Windows 10 - an alternative to recent files

I was searching a way to show the recent files in LibreOffice by right clicking on the pinned app on the taskbar but it appears it can't be done in Windows 10. But, there is a better way - pinning the most used documents.

Pinning files on LibreOffice taskbar in Windows 10

To pin your favorite files on LibreOffice (or any other apps like folders in Explorer) first pin the application on the Windows taskbar by dragging the icon from the desktop to the taskbar.

Pinning files on LibreOffice taskbar in Windows 10 - 1
Click to enlarge

Then to pin a file, drag the file from Windows explorer to the desired app on the taskbar.

Pinning files on LibreOffice taskbar in Windows 10 - 2


From now on you can just right click on the taskbar app and select which file do you want to open.

Wednesday, April 21, 2021

Building a Digital Clock with RGB Lamp & Spherical Shelf DIY

Here is how to build a simple digital wall clock encased in a spherical shelf that could make a nice gift for someone.

The clock is based on an ATmega328PB microcontroller that is using a 32.768 kHz crystal for time keeping. It also has 6 RGB leds that act as a night lamp or simply for aesthetic purposes.

Digital Clock With RGB Lamp & Spherical Shelf DIY