Sunday, November 30, 2008

4x4 Matrix Key-board Interfacing with ATmega32

Hi guys,
Here is a project for beginners to interface a 16-key (4x4) keypad with ATmega32 using 8-pins i.e. one port of the microcontroller. This is useful particularly where we need more keys but don't want to spend more uC pins for interfacing.
The 4x4 keypad is a standard one available in the market. I've used here one from my earlier project. The LED shown in the schematic is just extra, which can be used anyway you like.
Here, the mega32 reads the code of key pressed and sends relevant character to display on LCD 2nd line. The first line displays 'WELCOME' all the time.

The figure below shows ISIS Proteus Simulation of this code:

Source Code (AVR-GCC, winAVR, AVRStudio format)
Proteus Simulation model
Source Code (CodeVision AVR format)
Source Code with 4-bit LCD Implementation (ICCAVR)
Source Code (ICCAVR) with Schematic on Google Docs


Sunday, November 23, 2008

Simple PWM DC motor control using MOSFET H-Bridge with AVR ATmega8

Hi friends,
here is a very simple project of controlling a small DC-motor (taken from an old personal cassette player) with ATmega8. The ATmega8 is having three PWM channels, out of which two are used here. PWM waveforms are fed to MOSFET (RFD3055) H-bridge.
Here, direction is controlled using a two-position toggle switch and speed of the motor is controlled by two push-buttons, one for increasing the speed and other for reducing.
The schematic is geiven here (click on the image to enlarge):

When switch SW1 is closed, OC1A channel is active which will feed the PWM signal to Q1 & Q4 MOSFETs. The OC1B pin will remain low keeping the Q3 & Q2 in OFF condition. When SW1 is toggled to open position, OC1A pin will become low, making Q1 & Q4 OFF and OC1B will feed the PWM signal to Q3 & Q2, resulting in the change in the direction of current flow hrough motor. Hence, motor rotation direction will change.
The speed is controlled by Push-buttons S2 & S3. Pressing S2 will increase the speed in fixed steps. Similarly, pressing S3 will reduce the speed in fixed steps.

The closer look to the motor and the circuit:

Here on the bread-board, I've used two push-buttons but the direction control switch is replaced by a small wire which was connected to ground or kept open for changing the direction (since I was not having the toggle switch in stock at the moment). The bread-board also includes 6-pin In-System Programming connector which is not shown in the schematic.

(The InSystemProgramming (ISP) connector is shown in my earlier posts, hence omitted here!! But, if you are new to ISP, refer to my post DIY AVR Programmers to make one yourself!!)

The schematic and code for this PWM motor control can be downloaded from here:

Schematic & Code on Google Docs
Source code in CodeVision format (C file)

Download datasheet: RFD3055