Posts: 25
Joined: Sat Jan 19, 2013 7:40 pm

accurate rotation of a motor

Wed Dec 14, 2016 12:54 am

Good evening,

I am working on an idea to projection map a rotating object turned by a motor mounted above it.

The total piece of work will be 40 seconds long and loop continuously, I am going to (hopefully) use openFrameworks to map the content to the object but need your advice regarding rotating the object at the correct speed and keeping it all in time.

I understand that servo motors can give an exact position but I have never seen one used and have no idea where to begin coding this.

If i wanted the rotation to be frame accurate would that be possible? say 360 degrees in 40 seconds @ 25fps would require 0.36 degrees per frame (or 9 degrees per second)

Is this possible and if so how do I go about controlling it from the PI?

Many thanks


Posts: 849
Joined: Tue Dec 15, 2015 4:55 pm
Location: Detroit, MI USA
Contact: Website


Wed Dec 14, 2016 12:57 am

Youtube "how stepper motors work"
Robotics tips, hacks, book extras

Posts: 254
Joined: Wed Jun 20, 2012 2:51 pm
Location: Southampton, England

Re: accurate rotation of a motor

Thu Dec 15, 2016 4:05 pm

You need to look up servo motors and stepper motors.
To keep it brief, with a servo motor you send it a PWM signal and it moves to a position proportional to the pulse width. These motors are normally limited to a fraction (generally about 1/4 to nearly 1) of a turn in their travel, but you can get multi-turn or continuous servos. They require two wires: ground and signal.
Stepper motors turn a small fraction (depending on the motor design) of a full rotation each time you change the control signals through the looping pattern. They are not limited in how far they turn, and require between 4 and 6 wires depending on the type.
Because most servos cannot complete a full revolution you probably want a stepper for this project.

Posts: 4054
Joined: Fri Jun 08, 2012 6:03 pm

Re: accurate rotation of a motor

Thu Dec 15, 2016 5:38 pm

Also worth mentioning that you also get motors with encoders fitted which will report their either their exact position (absolute encoders) or how much they are moving (relative encoders).

Stepper motors are more commonly used though in applications such as 3D printers. The 3D printer will also have "end-stops" which are either optical or mechanical switches so that the print head can be moved back to the start point.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: accurate rotation of a motor

Thu Dec 15, 2016 6:49 pm

Is it continuous, smooth rotation you are looking for, or step-motion?

If movemenmt is in increments, a stepper is a good choice. Stepper motors commonly have 200 steps per rotation (1.8°), 400 can be had too (0.9°). With a simple controller eg an L298 H-bridge, you can double the resolution to 0.9/0.45 degrees respectively by half-stepping. Finer movement still requires more sophisticated micro-stepping driver electronics, which will offer intermediate steps from half to perhaps 1/128. Twenty-five 1/128 microsteps on a 1.8° motor is 0.352°, twenty-six such microsteps is 0.366°, either side of your 0.36° figure. Maybe you can compromise on the length of the clip?

As an alternative to a sophisticated stepping controller, you might use a mechanical gearbox on the shaft of the stepper to achieve something similar with a simple L298 half-step controller.

If the motion is to be continuous, you may also use a stepper motor with a microstepping driver to achieve your specified rotation speed.

Posts: 100
Joined: Wed Oct 24, 2012 9:15 pm
Location: Cheltenham, UK

Re: accurate rotation of a motor

Sat Dec 17, 2016 7:10 pm

Would suggest you explore using a PWM driven motor, not a stepper motor, to get your movement. You might also consider a simple gear box to reduce the speed and increase the torque to meet your application. A five pole brush motor would be better than a 3pole motor. Don't even think about brushless motors, they are really too good for this.

Getting the speed right is the important bit. Once you've got the motor speed under some control, you'll need a simple disc on the motor shaft with holes or slots spaced evenly around the circumference and a LED/Photo Cell sensing the holes/slots and report back to a PIO pin.

Then there's the far from simple bit of counting the pulses, working out how fast they're going and adjusting the PWM drive to compensate. If you want, this can get you into a whole world of complex motor control theory but a simple pulse count over time averaged over a number of samples should be within reach. Then adjust the motor drive in small increments to zero in on target speed.

A stepper could do it but think this way is better for smooth/quiet operation. Is also the way my Meade telescope moves around and does it very smoothly. And another thing... the motor controllers out there usually do either ONE stepper or TWO brush motors.

Remember, try and do something impossible every day and you'll be a lot cleverer by the end of the month. Recognise and reward failure so you can spot it coming at you next time.
Share and Enjoy.

Posts: 100
Joined: Wed Oct 24, 2012 9:15 pm
Location: Cheltenham, UK

Re: accurate rotation of a motor

Mon Dec 19, 2016 10:20 pm

What I should have added above was that my outline above would suite a simple power transistor/MOSFET for the PWM drive system with perhaps a protection diode across the motor. This would keep the parts count and costs to a minimum.
Share and Enjoy.

Return to “Automation, sensing and robotics”