Saturday, June 3, 2017

Library for interfacing AVR microcontrollers with ET16312N VFD (Vacuum Fluorescent Display) driver

I had a broken Philips DVP5960 DVD player and I thought it's a good idea to salvage and use the VFD display in some project. And so this code was born.




Vacuum Fluorescent Display (VFD) from a DVD Player controlled by AVR MCU
Vacuum Fluorescent Display (VFD) from a DVD Player controlled by AVR MCU

To know more about the communication protocol between the microcontroller and the VFD driver chip, visit this post Salvage a VFD from a broken DVD.

Sunday, February 19, 2017

Library for reading internal temperature sensor on AVR microcontrollers

A few AVR microcontrollers have internal on-chip temperature sensors. The sensor is a diode that produces a temperature dependent voltage. This voltage is measured with the ADC. According to Atmel the typical accuracy of temperature measurements over the full temperature range of the AVR is ±10°C but after calibration the accuracy can be ±1°C over 20°C to 55°C using one-point calibration.


Library for reading internal temperature sensor on AVR microcontrollers

The calibration can be done using one-point calibration and compensation or two-point calibration and compensation. One-point calibration is the easiest - subtract the ambient

Friday, February 10, 2017

DHT11 Library Temperature and Humidity Sensor

 Interfacing DHT11 sensor with an AVR Microcontroller


This post describes how to interface a DHT11 temperature and humidity sensor with an AVR microcontroller and how to read and display the data on an LCD using the DHT11 library.

DTH11 is a low cost hobby digital sensor used to measure temperature and relative humidity. Digital means that the sensor incorporates a 8 bit microcontroller inside that takes care of ADC measurements for you. With an analog sensor you would have to set up an ADC and measure the sensor resistance directly and interpret the data. The DHT11 sensor uses a proprietary 1-wire protocol which is described down bellow.
The DHT11 sensor comes in a single row 4-pin package, breadboard friendly, and operates from 3.5 to 5.5V. It can measure temperature from 0-50 °C with an accuracy of ±2°C and relative humidity ranging from 20-95% with an accuracy of  ±5%. During measurement it draws 0.3mA and in standby 60uA.
The sampling rate is 0.5 Hz in some datasheets and 1 Hz on others; this means it is not recommended to read the sensor more than once every second or every two seconds. The recommended sample rate is 5 seconds to prevent the display changing to often.

DHT11 pinout

DHT11 Pinout

Sunday, January 1, 2017

Programming low frequency microcontrollers in WinAVR

Fixing clock incompatibility between microcontroller and ISP programmer

I was working on a low power project using ATtiny13 so I have decided to use the 128kHz internal oscillator as a CPU clock to save power. All went well but when I tried to modify the code and upload again an error message appeared in WinAVR saying

avrdude: initialization failed, rc=-1

After some research I found out what was going on.

Clock too slow for ISP programmer

The ISP programmer must have a speed lower than the microcontroller. 4 times lower is recommended.
The solution is to lower the ISP clock speed by using -B bitclock option. -B250 worked fine.

Example in avrdude. I use USBTinyISP programmer:

avrdude -p attiny13 -P usb -c usbtiny -B250

Append arguments in WinAVR

Open the make file and fin these lines (starting from line ~ 300)

AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)

Then append the line

AVRDUDE_FLAGS += -B250

Tuesday, November 22, 2016

How to make a double sided printed circuit board (PCB) at home

Homemade PCB - not as hard as you might think. Ordering the PCB from a manufacturer might be easier but the disadvantage is the long waiting time, and in case you made a mistake in board design you need to repeat the process again.

For prototyping or for a one board spin, it is more practical and economical to make the boards at home. Following this tutorial you will be able to make a nice board in just a few minutes. The tutorial looks long because of the explanations, but once you get experience it's an easy task.

STEP 1: Printing circuit diagram

You will need a laser printer for this. The toner in the laser printer has plastic particles that will melt and stick to the copper clad. The sole purpose of the toner is to protect the copper below it from the ferric chloride. I use Brother HL-1210WE laser printer.


Printed electrical circuit diagram



The circuit diagram is created using DipTrace. I find it much easier to use than Eagle. You can print directly from DipTrace but i prefer exporting top, bottom and silk layers to .png files with 600 dpi density, and then arrange them on a A4 project to be printed on a single A4 paper. For this you need an image editor like Gimp, Inkscape, etc. I use Inkscape and it's free. The project in the image editor must have the same DPI as the exported images from the PCB design software. Also the printer must be set to print with the same DPI and everything will have the correct scale.

For aligning the layers i print the board dimensions (see image above) and use the lines at the corners to align the two layers on the light projector.

Only the top layers must be mirrored. I do this in DipTrace when exporting the image but it can be done in the image editor to.