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.