lets get educated

microconHolic

control servo (PWM) with atmega8535

My friend ask me to help in her final project which need a motor with a very slow velocity (1cm/hour) . Can you imagine that ?

As far as I know, the best solution is Servo. We can control the speed with PWM (Pulse Width Modulation), and of course as my favourite microcotroller ATMega8535 will do that control.  it`s only need two line addprogram in codevision AVR.

and it`s really work.

I love it…I love it…..I love it

this is the program

/*****************************************************
#include <mega8535.h>
#include <delay.h>

void main(void)
{
// Port A initialization
DDRA=0xFF;

// Port B initialization
DDRB=0xFF;

// Port D initialization
DDRD=0×20;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 1500.000 kHz
// Mode: Ph. & fr. cor. PWM top=ICR1
// OC1A output: Non-Inv.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0×80;
TCCR1B=0×12;
TCNT1H=0×00;
TCNT1L=0×00;
ICR1H=0x3A;
ICR1L=0×98;
OCR1A=1000;
OCR1BH=0×00;
OCR1BL=0×00;
while (1)
{
for(OCR1A=600;OCR1A!=1500;OCR1A++){
delay_ms(7100);}
};
}

This program will control the servo in speed 1cm/hour
It`s WORKS! try this one(its fun, u need to wait 2hours to make sure the distance..ha…ha..)

March 8, 2009 - Posted by | ATmega8535 project

8 Comments »

  1. my first time visit your blog, very educative. good. two thumbs for you. and also i wanna say thank you for your help, that servo was usefully.

    Comment by indah | April 14, 2009 | Reply

  2. really nice posting bro..
    but can you help to spell your program clearly??
    what’s the meaning of :
    TCCR1A=0×80;
    TCCR1B=0×12;
    TCNT1H=0×00;
    TCNT1L=0×00;
    ICR1H=0×3A;
    ICR1L=0×98;
    OCR1A=1000;
    OCR1BH=0×00;
    OCR1BL=0×00;

    please,thanxz

    Comment by abi | January 26, 2010 | Reply

    • For more explanation you can read the datasheet. I used Timer 1, so you can check more deeply in Timer 1 and all the register in there. TCCR1A and TCCR1B stand for initialization timer 1 as a PWM mode with the Phase and Frequency correct. TCNT and ICR1 stand for the limit counting number for the timer. OCR1A because i used PIN OC1A (PD5) as the output not OC1B. i will make another post about this, to make it more clear for u and other, maybe next week will be done…i really busy this week :)

      Comment by devinurtsyani | February 8, 2010 | Reply

  3. makasih atas tutorialnya.membantu banget.

    klo boleh saya mau tanya,
    1-bisa gak menjalankan servonya di PORTA.kan keluaran PWMnya di PORTD ya klo gak salah.
    2-klo servonya 5 bagaimana memberikan pulsanya keservo..

    terima kasih sebelumnya.
    mohon penjelasannya. ^_^

    Comment by eas | June 29, 2010 | Reply

    • ga bisa di port A, maximal hanya 2 servo.

      kecuali klo mau manual bikin programnya beda lagi

      Comment by devinurtsyani | July 5, 2010 | Reply

  4. Dear..

    Mau tanya BU??

    apakah dalam micro atMega8535 dapat diberi tambahan tombol perubah IP Micro tersebut??

    dan juga memory yang masih bisa memungkinkan untuk penambahan IP Micro trsebut??

    MOHON bantuan.

    terima kasih Bu…

    Comment by Woro | September 28, 2010 | Reply

    • wah saya kurang begitu mengerti pertanyaannya IP disini IP address..bukan yaa ;p
      maksudna tambahan tombol perubah tuh yang seperti apa ya, (contohnya mau dijadikan apa ),
      Apa maksudna mau buat tombol sebagai input di mikro itu bisa, jenis tombol banyak , mau yg seperti apa?

      Comment by devinurtsyani | October 6, 2010 | Reply

    • bisa

      Comment by microcon | November 16, 2010 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.