# Stable rpm on motor port

Hi,

i want to have a certain amount of rpm on my motor by rapidly changing amounts of torque. is “pwm” the right term for approaching that? i’m a newbie at this: do i have to connect to a servo port for this? what i need is a higher amount of motor current (close to the 2A)…

thanks!

PWM is used to control the motor current. To maintain a steady RPM, the motor shaft must be connected to a position or rotational velocity encoder that enables you to measure the rate of rotation. In response to small changes in rotational rate (as the motor load changes), you can change the PWM to restore the desired rate.

Ok, i understand. I’ve got a gear motor with 100 rpm. When i hold the axis (e.g. with my hand), it goes down to 90 rpm. Can you imagine that it is possible to measure this difference very accurate an rise the current so fast, that the motor e.g. comes back to 100 rpm after 100ms? and the other way round? if my motor is running at. e.g. 80 rpm and suddenly the mechanical hold is lowered, my motor goes up to 90 rpm but i need to constantly stay at 80. is that kind of accuracy possible with a normal velocity encoder? Is PWM more accurate than just changing the values of the motor speed? can i find a sample program somewhere for measuring the motor velocity and the corresponding change of PWM command?

thanks again!

This is done all the time. Basically this is how the cruise control on a vehicle works, but more generally the approach is called “Process Control”. However, no realistic implementation can maintain an exact rpm, so the device complexity depends on how accurately you need to maintain the rotational velocity. For example is 78-82 rpm OK, or do you need 79.99-80.01 rpm?

The details will depend on what motor and encoder combination you have. Pololu sells a few motors with built in encoders if you want to experiment.

Ok, i’ll try it out.
Another question to this topic:
I think about building my own accurate encoder, similar to an encoder of a mouse-wheel. what do you think? if i buy a like this one :
http://de.mouser.com/ProductDetail/Omron-Electronics/EE-SX1031/?qs=sGAEpiMZZMs8I5ltipPMAIyQ/BcseR7g
can i swich it to the orangutan-input? or do i need an additional ic or something?

I don’t think that encoder is very well suited to the needs you have for setting a precise motor speed.

I’d suggest either an integrated, enclosed, optical encoder, or an absolute magnetic encoder. Typically, those cost more, though, and require some attachment to the driven axle (sensor bit, or permanent magnet.)

Ok, but i read somewhere, that this one is used in optical computer-mice for encoding. or am i wrong. can you tell me another source or an example for a high resolution encoder i could use? the magnetic one which is used in the pololu motors has only 48 cpr, but for some reason (not for the project mentioned in this thread before), i need a very high resolution at the point, where the axle is nearly standing still…

https://www.pololu.com/catalog/product/959/faqs
Does it suit to my needs? (e.g. building a metal encoder wheel with holes inside for letting the reflection go through?)

I don’t think that’s any better, unfortunately.

This would be a great choice, but is probably outside of your price range:
digikey.com/product-detail/e … -ND/270081

Here’s something cheap that might work if you have the right shaft dimension:
vexrobotics.com/276-2156.html

The encoder you linked to seems very fiddly to get to work, as it requires you to adjust the sensor/shaft/disc yourself. If you’re OK doing that, it might work out OK. Also note that what you link is just the sensor – you still need a disc to sense.

I still have not tried it, because i still need to order the right motor, which is sold out at the moment. i think about the 67:1 (150 rpm) motor with the magnetic encoder. a cannot say exactly which accuracy i need, butt it will be something around 150+/- 1 rpm. do you think this is possible?

another question: i’ve got an orangutan 1284 controller. i think this one must be able to do this job, if well programmed. am i right? or does it make sense to buy e.g a jrk 21v3 motor controller for getting more accurate results concerning motor speed?

In principle, there is no problem to maintain 150+/-1 rpm with the right components. Whether you can actually obtain that performance depends on the motor, the gearing ratio, the variations in the load on the motor, the capabilities of the motor power supply/controller and the encoder that you choose. The microprocessor does not matter much as very little computation is required.

ok, so can you perhaps tell me if you think i have got these right components? i’ll describe the case more detailed:

at the moment i have got a 100:1 pololu motor without the encoder. i have two external gears (gear motor shaft:rotation axis = 15:12, so that my axis is rotating at 80 rpm, when the motor runs on full speed.)
the problem is, that the force on the rotation axis is changing rapidly during every single rotation (from around 0.15 Nm to -0.5 Nm, because there is a weight moving on the axis, which first must be raised with the power of the motor, and then it rotates back, amplified by gravity).
what i thought about was using a motor with a higher force, so that the influence of the falling weight is not so big. i thought about trying the 150rpm-motor and having different gears to come down to these 80rpm, but also being able to run it at only e.g. 70% of its power, so that i have some power left to interfear in correspondence with the values coming from the encoder. at the moment i think, my current setting is not the very best, but i’m still not sure, if the encoder and the robot controller can handle this fast change of forces. what do you think about that?

If you have this motor and encoder combination pololu.com/catalog/product/1446, it should provide sufficient torque (1.5 Nm) and encoder accuracy to do what you want.

ok, i’ll order it and try it out (at the moment i only have the one without the encoder…)

concerning the control of motor speed, is there any advantage of a motor controller like https://www.pololu.com/catalog/product/1392 compared to the orangutan that i have?

You will need to figure out how to program either the Orangutan or the controller to do what you want and that will require some study of the documentation. I’m not sure that the JRK controller can be made to work, as it is not designed to fully utilize a quadrature encoder, and seems to have some rather limiting expectations regarding the tachometer frequency on the feedback input.

ok, thank you once more. i programmed something similar some time ago, i just wanted to be sure that the hardware i’m using is the right one, because i remember that it was a little tricky, and if there would be a more stable solution with some other hardware, i would not want to leave out this chance…

Hi everyone,

after some searches i finally fond the perfect sensor/disc setup for my needs it is a 500 cpr disc with this optical sensor

http://at.mouser.com/ProductDetail/Avago-Technologies/HEDS-9100A00/?qs=sGAEpiMZZMsWp46O%252bq11WaQ6L28J1o0%252bfDRDNaiGhv4%3d

i also bought another optical sensor, which is much cheaper, but i don’t understand the wiring. i tried to connect just the ir emitter and measure the output voltage with a multimeter, but i think i had the wrong wiring. can you tell me which pins get the +/- and which ones have the (changing) output voltage?

here is the corresponding document:

mouser.com/ds/2/427/tcut1300-96295.pdf

On that second sensor, you need to provide 1.5V on the Anode, and tie the Cathode to ground. At that point, the emitter will start emitting, and you can read a resistance change on the emitters of the phototransistors.
Typically, you will want to use a pull-up resistor (say, 4.7 kOhm?) from +5V to the collector, tie the emitters together, and tie the emitters to ground. Then you can see the voltage at the collector fluctuate as the wheel spins within the sensor. (Here’s hoping I got the +/- right on the transistors – it’s been a long time since I paid attention to BJTs in schematics; using MOSFETs these days…)

Regarding your other response (I’m late coming back here :

You had the idea of using a 150 rpm motor instead of a 100 rpm motor “to get more power.” Unfortunately, that’s not how it works. The “power” comes from the windings in the motor, and generate a certain amount of torque at a certain rpm. The 100 rpm and the 150 rpm motors have the same windings, and thus the same original torque. When you gear these motors down to 80 rpm, they will have the exact same amount of torque (modulo gearbox losses, which are likely small.) The main thing you can do to get a kind of motor with stronger windings, or to over-volt your motor to get more power. If you use PWM control to keep a constant RPM, the over-volting will average out and not hurt the motor, unless you try to push it harder than it’s designed to go.

For the varying workload that you suggest, though, the best solution is likely a counter-balance weight. Instead of trying to compensate in drive power, add a counter-balancing weight that makes the load even around the cycle. This will not only make controlling the motor simpler, it will significantly reduce vibration and wear on the motor and mechanical system, and thus make it last a lot longer.