Servo motor help

hey, I’m using a continuous servo motor to rotate an acrylic piece. I know that angle cannot be used to set the position. with my program the acrylic can spin the amount i wanted. but after the first spin, the subsequent times it spins a little more than i wanted. this mistake, eventually after about 5 rounds can be spotted clearly. how do i correct this? btw i figured it out that using 1485 mircroseconds makes the motor stop.

#include <Servo.h> 

Servo myservo;  // create servo object to control a servo 




void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 

} 



void loop() 
{ 
  spin();
} 
void spin()
{
  myservo.writeMicroseconds(1550);
  delay(1000);
  myservo.writeMicroseconds(1485);
  delay(8000);

}

Your best bet might be to count the rotations using for example a reed switch or infrared sensor, these can get you resolution of 1,1/2,1/4 or more of a turn depending how many magnets or reflective strips you can fit into the constraints of your project.

Duane B

rcarduino.blogspot.com

I think there might be space constraints, but is IR detector fast enough to detect? Because i need to stop the rotor the moment it reaches the exact point. I'm afraid that it might take a split second to stop which might rotate the motor alittle further.

Its doesn't get much faster than light. There will be some inertia in your system so you might need a slight offset to account for the inertia.

Here is a rough idea how to use the approach based on a trial I did for measuring wheel speed -

http://rcarduino.blogspot.com/2011/12/traction-control-part-11-monitoring.html

Duane B

rcarduino.blogspot.com

oh wow! the wheels turn really fast. my rotor isn't fast at all. its actually a medicine dispenser. and the motor spins to push the medicines into a lower compartment for the user to take. now it turns accurately for the first spin, and then after maybe 2 spins it stops a little off position. then later it appears to be a big issue. IR detector sounds like a pretty good idea though, but I'm afraid about the space constraints. Anything i could do program wise?

What if you want to spin it to ther other way ?

myservo.writeMicroseconds(1550);

this will spin it , lets say → , what if we want to spin it ← ?

And chucky23 your servo is working all alone ? or it want to be connected to something else first ? how many pins does it needs to work a servo ? Thanks !

The IR Sensor here is tiny, about the size of a match head, the others in the previously are still small, around the size of an 8 pin chip.

http://rcarduino.blogspot.com/2012/03/reading-from-rc-reveiver-do-you-need.html

Other than that you just need room for paint - a dark ring with one white patch that shows the dispenser is where you want it.

As for left and right, you go lower for left servo.writeMicroseconds(1300); and higher for right servo.writeMicroseconds(1700);

This may be reversed but the idea is the same, the center point is usually around 1500 above rotations one way, below rotates the other way.

Duane B

rcarduino.blogspot.com

If your goal is to make the thing turn a repeatable angle, for example one full revolution of one half revolution, then a continuous rotation servo isn't a brilliant choice. Since you can only control the speed (not the position) it can't be positioned reliably unless you provide a separate feedback mechanism such as a rotary encoder. If you can arrange for the rotating assembly to operate any form of limit switch then a much simpler approach would be to emulator a car windscreen wiper parking circuit. With this approach, if you turn the control on and then off the motor will keep going until it reaches a park position. All you'd need to do then would be to turn the control on for long enough that you were sure the motor had moved away from it's current park position, then turn it off and wait for it to move to its next park position.

With this approach, the position when the motor stops won't be ultra precise because it relies on powering off the motor and letting it coast to a stop. I assume that's sufficient for you as long as it's reasonably consistent. If you need really tight control of the stop position you would need a closed loop control system, which adds complexity.

@invader7 yeah as what DuaneB said, 1500 is the centre most of the time but you can find yours by adjusting a little. if you want to spin the other way its lesser than 1500. and this might help you http://arduino.cc/en/Reference/ServoWriteMicroseconds and there are 3 pins one is the input(in my case the 5V) second is the output(which is connected to a digital pin in the arduino) 3rd is the ground pin. my servo is an output in this case. after a desired time interval, it will spin to drop the pills.

@DuaneB Thanks alot! i now have a rough idea of how to use the IR. Can i get back to you after i research more about it?

@PeterH The motor should turn an example(30degrees) every desired time that the user has entered before, to drop the pills in a lower platform. I wanted to use a roller switch, but the precision would be affected i guess, so i aborted the idea.

chucky23: precision would be affected i guess

How accurately do you need to control the positions? If you're just shoving pills around, it does not sound like the sort of thing that needs to be especially accurate.

You might incorporate some type of limit switch to control the servo when the dispenser is at a particular position.

//zoomkat servo button test 12-29-2011

#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
int button2 = 5; //button pin, connect to ground to move servo
int press2 = 0;
Servo servo1;

void setup()
{
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
  digitalWrite(5, HIGH); //enable pullups to make pin high
}

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    servo1.write(170);
  }    
  
  press2 = digitalRead(button2);
  if (press2 == LOW)
  {
    servo1.write(10);
  }
  
  /*else {
    servo1.write(90);
  }*/
}

Hi,
Did I not read somewhere if when you remove power from a DC motor you can place a small resistance or short across the terminals it will dynamic brake by magnetic induction…A DPDT relay (break before make can do it.
Just a thought…
Goodluck,
jolphil