Shop OBEX P1 Docs P2 Docs Learn Events
Automatics Parking Gate — Parallax Forums

Automatics Parking Gate

kakatantkakatant Posts: 8
edited 2011-07-15 04:42 in General Discussion
Recently i doing my project Automatics Parking Gate which used Attiny2313 microcontroller control parallax standard servo motor.

Attiny2313 external clock 20MHZ used and below is the code. After program below code and the clock non-stop move the motor CW.. I need to have code can control 0 degree and 90 degree.

#include<avr/io.h>
#include<util/delay.h>
//Simple Wait Function
voidWait()
{
uint8_ti;
for(i=0;i<50;i++)
{
_delay_loop_2(0);
_delay_loop_2(0);
_delay_loop_2(0);
}
}
voidmain()
{
//Port D pins as input
DDRD=0x00;
//Enable internal pull ups
PORTD=0xFF;
//Set PORTB1 pin as output
DDRB=0xFF;
TCCR1A|=(0<<COM1A0)|(1<<COM1A1)|(0<<COM1B0)|(0<<CO M1B1)|(0<<FOC1A)|(0<<FOC1B)|(1<<WGM11)|(0<<WGM10);
TCCR1B|=(0<<ICNC1)|(0<<ICES1)|(1<<WGM13)|(1<<WGM12 )|(0<<CS12)|(1<<CS11)|(0<<CS10);
ICR1=18429;//fPWM=50Hz (Period = 20ms Standard).
DDRD|=(1<<PD4)|(1<<PD5);//PWM Pins as Out
while(1)
{
OCR1A=650;//0 degree
Wait();
OCR1A=750;//90 degree
Wait();
OCR1A=850;//135 degree
Wait();
OCR1A=650;//180 degree
Wait();
}
}
553 x 352 - 60K

Comments

  • kakatantkakatant Posts: 8
    edited 2011-07-11 17:39
    Anyone can give me advice?
  • kwinnkwinn Posts: 8,697
    edited 2011-07-11 17:46
    Your question is not very clear and this is not an Atmel forum so there may not be anyone here with the required expertise.
  • kakatantkakatant Posts: 8
    edited 2011-07-11 23:57
    I just want to know what the ms for move Parallax Standard Servo motor 0, 90, 180 degree so i can used for write my programming. Thanks.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2011-07-12 07:34
    These numbers are the same as Futaba servos. Parallax servos are Futaba servos that have been purchased OEM from Futaba.

    Center is 1.5 microseconds, One direction is 1.0 microseconds and the other direction is 2.0 microseconds. To hold position the pulse has to be repeated within 20 microseconds.

    But, if you want exact 90 degrees and 180 degrees, you will have to tweak your code as servos were never expected to be that precise. If you want precision, a stepper motor would be better.
  • kakatantkakatant Posts: 8
    edited 2011-07-12 17:58
    Actually i try to modify below web site (Futaba Servo Motor Control by Using AVR ATmege Microcontroller) to my project (Parallax Standard Servo Motor Control by Using AVR Attiny2313).
    I facing a problem when i used excaltly same code in below web. but i just aware i miss one item not know how to do.

    I have totally no idea how to program the code together set below setting? Anyone can advice?
    LOW Fuse = 0xFF and HIGH Fuse = 0xC9


    http://extremeelectronics.co.in/avr-tutorials/servo-motor-control-by-using-avr-atmega32-microcontroller/comment-page-1/#comment-25625
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2011-07-13 04:11
    AVR problems are not readily supported here. If the servo functions properly in an independent test, the problem is likely in your AVR code or C compilers.

    And, those FUSE setting are specific to certain processors. In some cases, you can actually do some damage if you don't under stand what the Fuse setting are doing.
  • kakatantkakatant Posts: 8
    edited 2011-07-13 18:55
    Actually i want to know how the Parallax Standard Servo Motor angel control.
    Base on datasheet, it only mentioned 1.5ms for stop, 1.3ms for CW and 1.7ms for CWW..
    So what actual timing for turning 0 degree, 90 degree and 180 degree. Anyone can advices?
  • kwinnkwinn Posts: 8,697
    edited 2011-07-13 19:48
    kakatant wrote: »
    Actually i want to know how the Parallax Standard Servo Motor angel control.
    Base on datasheet, it only mentioned 1.5ms for stop, 1.3ms for CW and 1.7ms for CWW..
    So what actual timing for turning 0 degree, 90 degree and 180 degree. Anyone can advices?

    Just what the data sheet says. 1.3ms - 0 degrees, 1.5ms - 90 degrees, 1.7ms - 180 degrees.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-07-13 19:54
    We can't give you timing information for specific servo positions. It varies from servo to servo. You'll have to do some experimenting. As Loopy Byteloose mentioned, center is 1.5ms. That would be roughly 90 degrees. One end of the range of movement is roughly 1ms and the other end is 2ms.
  • kakatantkakatant Posts: 8
    edited 2011-07-14 23:52
    Finally i did success turn the motor. After i setting 1ms, 1.5ms and 2ms. it only turn around range A (duno isnt 0 degree) degree-90degree.... if setting more than 2ms (2ms-20ms) and how to differential out wihch position is for stop, CW or CCW? Anyone can advices.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2011-07-15 04:42
    These servos were originally intended for radio-controlled airplanes and were never dependent on exact degrees as adjustment could be made in both the airplane's hardware and in the radio transmitter to optimize control

    1.5ms is the ideal center pulse. Extremes in either direction are roughly 1.0ms and 2.0ms. It doesn't hurt anything to go beyond those limits, but the pulse has to be sent within 20ms in order to hold a position.

    The primary problem here may be that you do not understand the history and the design limits of the servo. I also realize that you may have trouble with expressing detail in English. It might help to research the servo in your first language to fully understand how the pulses work.

    There is one situation where you might get rotation without really having control. It is usually when you power up the servo, the microcontroller might send a transient pulse that causes a jump that is rather random.
Sign In or Register to comment.