Monday, September 29, 2014

Working with BMP file C++ convert image in to an array

I described insides of the BMP file Here.

I needed a program which converts bmp image in a 2 dimensional array of 0 and 1. So i could display the image on the LCD display from Nokia 5110.

Here I have the source code, written in C++, now i will explain how it works.

int main(int argc, char *argv[])

How the BMP (bitmap) image looks from the inside, in binary

I needed to create a mitmap image in to code converter for Nokia 5110 display. So i decided to use .bmp images, just because they are simple.

If you want to look inside image file (binary code) you can use any "hex editor", if you open any file, programm will display to you hexadecimal codes from which this file consist of. I use "Hex Editor XVI32"

Sunday, September 28, 2014

nokia 5110 LCD display AVR


Now i will write about nokia 5110 display.

Saturday, September 27, 2014

Working with LCD display on HD44780 AVR

If you need only ready to use library, you can get it here.

Datasheet


I ordered display from ebay, 2 lines by 16 symbols.


How to work with AVR MC pins and their additional functions

I will write an overview about different AVR ATmega8 pins and show some coe examples for working with tem.


Friday, September 26, 2014

PC games I've made with SDL and C++

Long time ago i decided to teach myself how to make computer games. So here i will show what games i created.
All games written on c++ with SDL library, some of them have source code, too bad I don't have source code for all of them.

Horizontal shooter


The first semi-game i have ever made, i wanted everything in it, so it was never finished, moreover when it was working CPU usage was 100% and RAM was fille with garbage.

Media Tech MT1501 gamepad wireless driver

Gamepad driver, I am afraid to lose the disc. So i will keep it here.

Media Tech MT1501 gamepad wireless driver
https://drive.google.com/file/d/0B57Rnj-YfbQFanVmaGhLYnllbEU/edit?usp=sharing

Tuesday, August 19, 2014

What is a servo motor (servo)

Servo motor is a motor, which we control by telling it at what angle it should be rotated and servo is trying to maintain that position.



How to work with it

Servo has 3 outputs: Power, Ground and Data.
On Data wire we apply PWM signal with different duty cycle, to control our motor.

     

Generally PWM frequency is 50 Hz (period = 20 ms), minimum impulse width is 1 ms (0°) and maximum is 2 ms (180°).
There are a variety of different servos, so you still need to read datasheet, but this information will help you to start.

Now i will write about their structure, you don't need to know what is inside of them to use them.

How to work with Sharp Infrared sensor

I already wrote how to work with ADC In this article.



( In the simplest case ) Infrared Proximity Sensor - Sharp has 3 output pins: Vcc - Power, GND - Ground and Vo - Data. Depending on the distance varies the voltage at the output Vo, all that left is transform that data to digital information.




AVR Tutorial - ADC (Analog to Digital Converter)

ADC as you can guess converts analog voltage to digital number, so we could work with it in microcontroller. We can build simple ADC with comparator, it's a device which compares 2 signals (1 of them is some constant reference voltage) gives one otput if 1 signal is bigger and other if smaller.

ADC accuracy depends on it's resolution. e.g. if we have reference voltage = 5 V and our ADC is 10-bit, then on every bit we have 5 / ( 2^10 - 1 ) = 0.00489 or 5 mV, so we can't measure changes less than 5 mV.

Monday, August 18, 2014

Playing music on AVR with PWM

At first I tried to write code myself, but I failed many times.
So i searched for a working project and found it, AVR is using PWM and simple Piezo Buzzer.

Code taken from aquaticus.info
Sources on Github

Introduction to Pulse Width Modulation (PWM)

PWM — Pulse Width Modulation
In general it's a method of controlling analog voltage by changing digital impulses width. In other words we can change analog signal with digitall signals.


If we need to change LED brightness, we will connect it to the
variable resistor. If we need constant brightness we will compute our resistor, but still some of the power will be converted to heat on the resistor, well, it's not very efficient.

In addition we have to manually change resistance and sometimes that is impossible (RC cars).






Sunday, August 17, 2014

AVR Tutorial - PWM Signal Generation using Timers


In AVR microcontrollers PWM is implemented in hardware, all that left is configure it, by setting required bits in timer registers.

Saturday, August 16, 2014

How to calculate simple transistor switch. How to light LED in the dark

I needed to make LED light in the dark, so I found this video, where Ben Krasnow explains how to make a simple transistor switch.




AVR Tutorial - Introduction to Timers

Avr microcontrollers have several timers (counters). They can be 8 bit (max == 2^8 = 256), or 16 bit (max == 2^16 = 65536).


  • Timers can count with different speeds and compute ticks
  • Count from external oscillators
  • With them we can compute time and time intervals (accuracy more than 0.5%)
  • Generate ADC signals.
  • Generate interrupts.

Friday, August 15, 2014

Servomotors practise, Servo Motor Control using AVR ATmega8

I had bought some chinese servomotors and decided to make a laser toy for my cat.



AVR library for HD44780


Creator's site
Library itself.
I will show some code explaining how to work with this library.

LED driver.

Driver is a thing which gives constant current regardless of what you will connect to it.

LED's work on current. They consume needed voltage without noticing it. If we connect LED to 12 volt DC, he consume needed (for example) 2 volts and spare voltage will go further. (if there is nothing else all 12 volts will be on LED and it will most likely burn).

LED matrix

I decided to play a little bit with LED matrix, so i will write what i found out.

Thursday, August 14, 2014

LED hearth

A long time ago i have spotted LED hearth circuit on radio-hobby.org. It was so simple, but effect was really interesting, so i decided to make it. On the Valentine's day i made my PCB and placed everything inside a clock enclosure. And used adhesive tape to keep it in place. It was my first project.

Saturday, July 26, 2014

AVR Tutorial - Fuses

Fuses are bits which you can programm to change some settings of your microcontroller, like frequency, start up time etc.

It's better to always check datasheet before changing them, they can differ from MC to MC.

Atmel uses this notation: 0 = ON, 1 = OFF, that's the way the write their datasheets, also different programms for loading .hex in MC use different notation.

Saturday, July 19, 2014

How to program the AVR microcontroller with USBASP

I will write how to programm ATmega32 with "Khazama AVR Programmer" and "USBASP"
USBASP - it's a programmer which you can build yourself or buy (3$ on ebay).
Drivers and additional information available on the creator site


Khazama AVR Programmer - it's a programm which uploads .hex file in microcontroller.

Tuesday, July 1, 2014

Dremel

Finnaly i have bought drilling machine. Which consist of

Dremel worsktation --------- 57 €
Dremel 200 ------------------- 40 €

I used drill before that, well it was just horrible :DD