Navigation

Saturday 3 September 2016

Working with an Incremental Rotary Encoder

A rotary encoder is used to measure rotational speed, angle and acceleration of an object. It is used to precisely measure rotation of a joint or motor. Rotary encoders are used to provide direct physical feedback of motor position, joint position, and speed of rotation. Unlike potentiometers, it can turn infinitely with no end stop. Rotary encoders come in various kinds of resolutions. The number of pulses or steps generated per complete turn varies from 16 - 1024 pulses/revolution.

Connecting a switch to a microcontroller

The most common way of connecting a switch to a microcontroller is via a pull-up resistor to 5v as shown below


When the switch is open, a logic 1 (5v) is connected to the microcontroller. When the switch is closed, a logic 0 (0v) is connected to the micro, This type of resistor shown above is called a pull up resistor. A pull-up resistor is a resistor connected between the microcontroller and a positive power supply voltage.

Delay timing with a microcontroller

The instructions we program into a microcontroller work by moving and manipulating data in memory locations known as user files and registers.

Some micros such as PIC16 and ATMega328 microcontrollers are 8 bit microcontrollers, which mean that the memory locations, user files and registers are made up of 8 binary digits shown below. Bit 0 is the Least Significant Bit (LSB) and Bit 7 is the Most Significant Bit (MSB).

Wind Power Generator Kit

The Eco Biker wind power generator kit is designed to teach about green energy. It creates great fun to learn about how to convert wind energy into a useful form of energy such as using wind turbines to make LED light up. The stronger the wind is made, the faster the biker rides as well as the brighter the LED is lit.

The kit is a great way for teaching children how to assembly parts and they also get to learn about electricity generation

Parts include generator with LED, gears, round shaft, tapping screw, rubber pad, cable ties, assembly parts and instruction booklet for building the kit shown in the pictures below.

Tesla coil Wireless Power Transmission: Slayer Exciter Circuit

Tesla coil is an electrical resonant transformer circuit invented by Nikola Tesla. It is a form of induction coil for producing high voltage, high-frequency alternating currents. Nikola Tesla in 1891 demonstrated wireless power transmission by lighting light bulbs from across a stage. A Tesla coil can be in the form of a Switched or Solid State Tesla Coil (SSTC). In this mode, a transistor is used to switch pulses of current from a DC power supply through the primary coil.

The circuit developed in this tutorial is called slayer exciter. A slayer exciter is a small SSTC coil. A Slayer Exciter is an air-cored transformer that steps up a very low DC voltage to a very high AC voltage. This creates an electromagnetic field around the coil that is capable of lighting up fluorescent and neon light bulbs.

Using MPLAB software for programming a PIC microcontroller – Part 2

In this tutorial, procedures on how to simulate a PIC18F1320 microcontroller using the HEX code generated by the MPLAB software will be explained. Also, programming the physical chip using PICKit3 will be shown.

Below is a circuit in Proteus ISIS that blinks an LED every 500ms explained in the previous post. The LED is connected as a pull up resistor to pin RB2 of the PIC. Not that in the software, it is also pin RB2 that is being turned ON and OFF. The circuit also shows connection of the PIC to the PICKit programmer.


After drawing the circuit, Right click on the PIC18F1320, Choose Edit Properties. The following screen will appear.

Using MPLAB software for programming a PIC microcontroller – Part 1

I would be using the MPLAB 8.89 and CCS C Compiler
Step 1: Go to Project -> Project Wizard
Step 2: Choose the PIC18F1320 microcontroller

Using Load cell with the Arduino

A load cell is a force sensing module having a metal structure, with strain gauges mounted in precise locations on the structure. It is easy to use with voltage rating of 5-10V. The force applied to the load cell changes in the output voltage signal directly. Load cells are designed to measure force in one direction. They will often measure force in other directions, but the sensor sensitivity will be different.


Load cells are used in weight, jewellery and kitchen scales. It is usually mounted by bolting down through the screw hole or gluing the end of the load cell where the wires are attached, and applying force on the other end, that is, where the direction of the arrow is. This end is left in floating state.

Pseudocode for using push button tactile switches as toggle switch

Normally, a toggle switch is used to turn on or off an output connected to a microcontroller such as LEDs or othe output sensor. What if you have a push button switch and you want to turn off and on an LED without having to keep holding down the switch? In this tutorial, the pseudocode and Arduino code to do such will be provided

The desired input/output behaviour is as follows: The first time the push button switch is pressed the LED should be ON, the second time it is pressed it should be OFF, the third time the switch is pressed, the LED should come ON again, and the fourth time turn off the LED. This on/off pattern should repeat each time the switch is pressed.

MAX7219 LED Dot Matrix and Serial Peripheral Interface

The MAX7219 LED Dot Matrix is an inexpensive kit that contain a MAX7219 and an LED matrix. It’s a simple and inexpensive method of controlling 64 LEDs in either matrix or numeric display form. The MAX7219 is an integrated serial input/output common cathode display driver. It uses a four wire serial interface to connect to microcontrollers. The MAX7219 LED Dot Matrix connects to the Arduino as indicated below:

LED Matrix        Arduino    
VCC                        5V                  
GND                       GND              
DIN                         D12                
CS                          D10                
CLK                        D11

The LED Dot Matrix has output and input,  more than 1 MAX7219 display is connected in series driven by 1 Arduino. This is done by connecting the Vcc, GND, DOUT, CS and CLK pins from the first MAX7219 to the Vcc, GND, DIN, CS and CLK pins of the second and subsequent MAX7219.

Electroluminescence Wire Display


EL (Electroluminescent) wires are composed of a copper core coated with a phosphor layer, a twisted copper wire that wraps around the phosphor layer, an inner and outer PVC plastic sleeve and an AC power source. The phosphor layer is what makes the EL wire light up.

Cheap Home Security Solution using Arduino


The Arduino SD card shield can be used to log data from sensors to be analysed later. In this project, the Arduino Datalogger was used to log readings from a PIR sensor anytime movement is detected. A PIR sensor is used to sense motion of human beings. This setup worked reliably well. It can be used in situations of tracking movements in a room. The code logs in the time (year, month, day, hour, minute, second) when the motion is detected. The SD card can simply be removed and the txt file opened to view the logged data. This is a great home monitoring/security solution, a casing in form of a box can be used to shield the Arduino and logger so it is not noticeable. Here is an excerpt of the Arduino code.