go_away

Author Topic: Continuous Rotation of Servos Anit-clockwise  (Read 2279 times)

0 Members and 1 Guest are viewing this topic.

Offline LycusTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Continuous Rotation of Servos Anit-clockwise
« on: July 29, 2008, 05:04:57 AM »
Hi All,

Hope this is the correct place to post this query. It's either Electronics or Software. I tend to think its an electronics issue, but...

For a bit of background I'm trying to build the $50 robot. However there are a couple of changes to the basics. I'm using an ATmega168 and Hitec HS-425BB servos. This is mainly due to the fact that both were cheaper to purchase here in Australia than the ATmega8 and the HS-311 (go figure!). I'm programming the 168 with the AVRISPII.

I managed to centre the servos using the following code:
Code: [Select]
while
{
    servo_left(60);
    delay_cycle(20);
}

I then had to recharge my batteries (6V 4 pack Alkaline). When I went back to the system The servos started rotating in an anti-clockwise direction. I wanted to change the Speed value to change the direction, but to no avail. The servos still only rotate in an anti-clockwise direction.

My question is: is this to do with the charge of the batteries, the microcontroller clock, or the servos, either because they're not actually centred correctly, or they're rated differently to the HS-311?

As far as I can tell the ATmega168 runs at the same speed as the ATmega8, and I was told there was no real difference between the HS-311 and the HS-425BB.

Sorry about the long post, but any help would be appreciated. Ultimately I will fork out for the correct microcontroller and servos for the project if I have to, but I hope it doesn't come to that.

Cheers

Lycus
There are 10 people in the world,
Those that understand Binary,
And those that don't.

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Continuous Rotation of Servos Anit-clockwise
« Reply #1 on: July 29, 2008, 05:59:02 AM »
I believe the 50 dollar robot code might need some modification for the ATmega 168
http://www.societyofrobots.com/step_by_step_atmega168_swapout.shtml


And the ATmega 168 can run at a higher frequency then the ATmega 8
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: Continuous Rotation of Servos Anit-clockwise
« Reply #2 on: July 29, 2008, 09:58:00 AM »
read the datasheet for your servos. what does it tell you?

Offline LycusTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: Continuous Rotation of Servos Anit-clockwise
« Reply #3 on: July 30, 2008, 02:59:46 AM »
Thanks for the replies guys.

Airman00: I've modified the makefile, but the CKDIV8 was not checked, allowing the 168 to run at the faster speed, I'll check the CKDIV8 fuse and see what happens.

Pomprocker: Not sure what part of the data sheet I'm looking at. It seems pretty standard - neutral at 1500 uS (1.5 mS), voltage range from 4.8V to 6.0V, speed at 4.8V is 0.21/60 deg @no load, stall torque is 3.3kg.cm(45.82oz.in), operating angle 45 /ONE SIDE PULSE TRAVELING 400usec, direction CLOCK WISE/PULSE TRAVELING 1500 TO 1900usec.

As a noob, I probably should have followed the tutorial to the letter.  :)

Cheers.
There are 10 people in the world,
Those that understand Binary,
And those that don't.

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Continuous Rotation of Servos Anit-clockwise
« Reply #4 on: July 30, 2008, 05:39:02 AM »
Lycus its definitely the faster speed thats screwing it up.

Really you can keep the faster speed and just increase the servo cycles

lets say at 4 mhz its 20 cycles so at 8 mhz its 40 cycles
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: Continuous Rotation of Servos Anit-clockwise
« Reply #5 on: July 30, 2008, 10:00:19 AM »
oh yeah on my $50 robot I multiplied all the values by 8 when running at 8MHz.

The default MCU in that tutorial is the ATmega8, which runs at 1MHz by default, and you can change it to 8MHz if you want. The ATmega168 runs at 8MHz by default, so in the source code you need to prepare for that by multiplying values for your servos and timers. (anything that needs a pulse)

programming CKDIV8 takes your 8MHz speed, divides it by 8, and leaves your processor running at 1MHz  :(
« Last Edit: July 30, 2008, 10:03:41 AM by pomprocker »

Offline LycusTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: Continuous Rotation of Servos Anit-clockwise
« Reply #6 on: July 31, 2008, 04:03:52 AM »
Thanks Guys,

That was the problem. I checked CKDIV8 and it all worked.

Next step is to change the code to run at 8MHz.

Once again thanks for the help.
There are 10 people in the world,
Those that understand Binary,
And those that don't.

 


Get Your Ad Here

data_list