Alternative to digital rotary encoder

When you like to have precise control of a motor, it is normal to use a digital rotary encoder to provide a feed back signal to the microcontroller. The most common encoders are optical encoders with a transparent rotor with 20 up to 1000 lines blocking the light every revolution. Digital hall element encoders are in use as well, but they typically got about 11 to 21 steps each revolution. In most cases the encoder got two sensors, so you get directional information of the rotor position.

Two alternatives to the digital rotary encoders are small, brushed DC motors or small, brushless motors (synchronous motors). You want the brushed DC motor to have at least five rotor poles. Small DC motors often got only three rotor poles, but more poles provide less ripple voltage of the electromagnetic voltage force (EMF) from it.

Some applications need to have a large speed range of the motor drive. A DC motor for feed back is a suitable alternative in such cases. Furthermore, digital encoders with a high number of optical lines can be quite expensive, while a small DC motor costs below 0.5 $. But a DC motor does not provide the positional information, that a digital encoder does.

I have seen argued, that it is hard to provide a speed range of a motor drive above 100:1, but I think it might be because of the limitation you get from the digital encoder.

This video show a test set-up with a brushed DC motor and a brushed DC motor feed-back, that got a 1000:1 speed ratio.
https://youtu.be/oQxcpLYyCSM

In the video, an Arduino Nano controls the motor via an H-bridge. You will also need four quadrant control of the DC-motor to obtain the good low speed control, because the variable reluctance (cogging moment) of the motor will make you need to provide reverse current in parts of the rotation cycle. The feed back DC-voltage from the tiny tachogenerator use two operational amplifiers to provide a low-speed and a high-speed analog signal to the Arduino, because the 10 bit resolution of the ADC would not be sufficient otherwise.

Did you ever use other kinds of rotary encoders than the digital types?

For low speed applications a gated clock feeding a counter has been used. For high speeds measuring the number of pulses per time unit felt better. This calls for a precise clock/time reference.
If position knowledge is wanted using a kind of zero sensing sensor plus an incremetal/ decremental pulsing sensor could be an option.

Thanks. I just like to understand what this means. Is it a way to measure the time between two rising edges of the signal from a digital rotary encoder?

Exactly! Much is about short measuring time or the resolution.

I did consider this method to measure the time between pulses, but I do not think, that it is sufficient. I explain a bit about it in the video. The reason is, that you got two long time between updates of the speed signal, and therefore the speed loop frequency becomes too low.

With a speed of 11 RPM as seen in video and with a digital encoder with 1000 pulses each revolution (expensive) you get a new speed signal with a frequency of 183 Hz. With the extra tiny DC motor for feed back signal, it is quite easily to have a 5 kHz speed loop frequency, and it is 27 times faster. Furthermore you have to deal with the problems of a variable speed loop frequency with the digital encoder. The more affordable encoders got 100 pulses each revolution, and then the situation gets worse. That is why I state, that the use of digital encoders is not preferable for such applications.

I'll have to check the details later, including watching the video.. I'm not fully clear, for now, about the range of RPM's.

Just looked at the video.
"Tachogenerator"..... I still don't get a grip of what it makes, in frequency.

I don't understand what that is.

You have been testing and evaluating things. Fine. What is the data out of the current setup? Max and min pulse frequency for the RPM range used?

Perhaps tachogenerator is an old term, but it means an electrical machine just like a DC motor, that provides an output voltage proportional to the applied rotational speed. A brushed DC motor can be used for that purpose. Therefore the speed is measured by a voltage and not as a frequency or pulses. Before digital electronics were used, such Tachogenerators were made to provide feed back signals or control signals for speed of rotating machinery.

In this test set up, a feed back loop is controlling the speed of the motor via a PID controller. Its calculation rate of this loop is 5 kHz in this test.

I am not sure what you mean by pulse frequency. But the PWM frequency provided to the motor is 20 kHz in order to prevent audio noise from that. The max motor speed at 12 V in this set-up is 11.000 RPM. The nominal voltage of the motor is 16 V, so it can run a bit faster within its specification. The main thing is to be able to control the speed of such a motor at a low speed like 11 RPM and with fast load response. This is how a steady state situation at 123rpm looks like, with about one revolution shown:

In order to keep a low speed reasonable constant, the controller needs to work with a quite fast sample sample rate of the feedback and control. For each dot in this curve, the PWM output was corrected 20 times.
Please just ask, if you need more information - I got a lot more.

Thanks! Like a dynamo.

Know that many Arduinos only have a 10 bit, 0 - 1023, ADC. Some use 12 bits, 0 to 4097. That's the resolution You will get.

I'm a bit outside my comfort zone now.

You aim for the step response, reacting firmly to quick changes in the load?

You have more knowledge then I have, it looks like. Never worked with matters like this.

This or that kind of rotation decoder, it looks like the resolution of the controller is important. What does the tachometer output really look like? Is it AC or like a rectified AC? Filters do impact the responce time.

1 Like

The Arduino Nano V3 I use only got 10 bit. Therefore I use two analog inputs, and one of them amplify the tachometer voltage more than the other. In this way I obtain about 2 bits more at lower speeds. At 11 RPM as shown in video, the mean digital value is 3.3, and therefore the speed there is on the limit. But due to ripple voltage and noise it will flip up and down all the time and you will get a more accurate mean value. A 12 bit ADC may help. Due to the speed here I use a higher ADC clock frequency, and it reduces the accuracy about ½ LSB.

In the test shown, I measure this voltage every 0.2 ms (5 kHz) and a new PWM value is calculated. It is hard for the microcontroller and code used to go faster than that.

Yes. The mechanics of this load step is seen in video, and it is of cause not an ideal step in load, because of the dynamics of the mechanics involved. But it provides a repeatable way to adjust the values of the PID controller and evaluate other ways of control. I also tried IR compensation and measurement of own EMF in motor. This is a plot of a load step response. The load start to be applied at 40 ms.

Yes, there is more detail to this. This is a picture from my old oscilloscope with the voltage from the tiny DC motor I use as tachogenerator and the signal from a digital hall element sensor with one magnet on the same shaft. Zero voltage is one division from bottom of oscilloscope screen:

In theoretical ideal terms, you get a rectified voltage from 6 phase sine voltages with a brushed DC motor (tacho generator) with 3 rotor poles. With a DC motor with 5 rotor poles (as used here) you get a rectification of 10 phase voltages, so the ripple frequency becomes 10 times the rotation frequency. This is when things are "perfect", but the angle of the commutator is never perfectly adjusted. You get small short spikes from commutator. At higher speeds you can have the commutators jumping a bit causing small disruptions in output voltage. In this case I use a simple RC filter with 15 ohm and 1 uF. The tachogenerator got an internal inductance of about 0.1 mH. The 1 uf capacitor keeps the voltage when the commutator is jumping.

I consider another alternative better alternative to the digital encoder using an synchronous three phase brushless motor as you see here. It is a cheep motor intended for small drones with a mass of 6 grams:

Question: have you noticed even smaller motors of this kind on the market?

If you attach one of the terminals to a center voltage of the supplies to the Arduino and measure the other two voltages (v1 and v2), then you can calculate the speed of the motor from the EMF between two phases by this equation:

EMF = 2 * sqrt( (sq(v1) + sq(v2) -v1*v2)/3);

This value will be close to a constant (without ripple) at a constant speed regardless of rotor position. So you could do that at lower speeds and measure the frequency at higher speeds. A problem is, that you need to keep track of the rotary direction, So it will require some more calculations to provide the angle position. The calculated EMF will rise again at “negative” rotation direction. With a brushed DC motor, you will get a negative voltage directly.

Impressive. Nothing to add.

[/quote]

Thanks for the response. In this other thread, the encoder is discussed. The final application is for motor drives to vintage sewing machines. The main problem for many sewing machines are, that you like to have a wide speed range and very good low speed control, while the load vary a in a sewing cycle. When you start to sew, the static friction can resist movement, and when you press the speed pedal down, then studently the machines take off and 3 stitches are made before you can react, and you did only want one stitch. This video try to show what is required, but actually I like to see better performance than this:
https://youtu.be/uTB8DnyYAlA
What you see in this video is however significantly better than the best sewing machines, and almost all users of sewing machines are actually used to have very bad speed control.
I like to find out how much better it can be done and my first goal is to use a normal brushed DC motor. And the other video I linked to in start of this thread is only with a smaller motor to prove some concepts.

At higher speeds you got no problem because the rotational inertia will make the machine continue. At low speeds the machine easily just stop, when you want to have the needle penetrate some heavy fabric. At low speeds you also got the cogging moment from motor reluctance to overcome. Therefore low speeds are much harder to control than high speeds. Short term you need to provide high torque and current to the motor and in significant excess of the nominal long term current limit of the motor in order to sew heavy fabrics with heavy sewing thread. On the other hand you do not want to damage the sewing machine with too high torque.

Above you see a case with steady state 123 rpm with no load, and the controller struggle to keep a reasonable constant motor speed. Both positive and negative currents are applied to the DC motor. From my experiments, it seems to me, that you need to have the speed control loop operating at about 1 kHz update frequency. There is also a motor current control loop, and it needs to update faster at 10 kHz, but it is easier to handle. In this case timer1, that controls the PWM to motor, do also trigger the ADC to make the H-bridge current measurement at right timing. It is done without interrupt.

When you consider to have the motor run at 30 rpm, then a 1000 line encoder will provide 500 Hz pulses/sec, but I like to see an update of speed at 1 kHz. At high speed, 20000 rpm a 1000 line encoder should deliver 333 kHz, and it starts to be a problem for interrupt routines and similar used. So in this case some other strategy is needed. Using the digital encoders do cause some considerations and change of mode. They may also be expensive and require interrupt routines.

Therefore I look for some alternative methods to measure rotational speed.

I hope this provides you with some more information, but otherwise just ask.

It is the same thing as in so many other threads:

As soon as the complete project is described different but good suiting solutions can be made.

A long time ago I saw a video on youtube about the UHU-servomotor-controller on a sewing-machine. I tried to find it but I had no luck.

No ! I am far away from beeing a sewing-expert and far away from a sewing.machine-expert but there are solutions to this that give you excellent control.

Here is a video that shows what such a servo-drive is able to manage.
In my opinion a servomotor is the way to go for two reasons:

  1. high endspeed high maximum rpm
  2. very good control of
    • rpm
    • acceleration
    • position

with a servocontroller you can start stop on fractions of a single revolution
and this is what this video shows

The homepage of the UHU-servo-controller is still online
http://uhu-servo.de/Einstieg.htm
http://uhu-servo.de/servo_en/PIDsimple.pdf

There is a small german company that produces a UHU-servo-controller

If there are some other requirements that rule out a servomotor-drive in your case you should describe these requirements precisely

best regards Stefan

No. This video show almost nothing. But it is stille better than many other machines - I agree on that. Let me explain.

  1. This video shows jump start to a rather high speed of about 60 stitches per minute. The machine cannot make very low speed, and it is typical, that these servo motors got a limited speed range often about 1:25 or perhaps up to 1:45. Look at other video and compare and you see 8 stitches/min and no jump start. Jump start do also mean, that you cannot hear when the machine will start to sew. Suddenly it starts when you press the pedal sufficiently.

  2. A slow speed increase to max speed is not shown, and it will probably have some uneven behavior.

  3. Very small steps forward is not shown, and I know you cannot do that with the pedals they use.

  4. when it runs that high low speed, then it is hard to evaluate how it reacts to load variation. But I think it is reasonable.

The servo motor you show is for an industrial sewing machines, and they got very high torque in a set up like he show with reduced gearing. It is hard to limit the torque, and you can easily get a household vintage sewing machine damaged by that.

The man in the video is happy about the performance, because many other machines is a lot worse. And many users are used to worse situations. But it does not mean, that there is still room for a lot of improvement.

As I have said already:

Is changing to a different motor an option "YES" or "NO"

What is the maximum torque in Nm (Newton-meter) that you want?
post a number

Depending on these answers a stepper-motor might be suitable and offers very precise positioning.

Such a servomotor works with the same interface step / direction
A servomotor offers precise positioning too

You can command a servomotor

  • to rotate 0.5 degree and then stop again
  • to rotate 20 degree and then stop again
  • to rotate 77.5 degree and then stop again
  • to rotate at any angle you like
    and in addition it is a closed loop system which means the real position is measured

Another option close to ready to use is this

Edit:

I came across this guy who developped a sensorless brush-less-motor positioning control.
WOW !

The problem with normal stepper motors with around 100-200 steps each revolution is, that they got a low maximum speed range - typically you cannot make them run at speeds above 1000 rpm. You also like to be able to sew fast.
No problem in specifying the mechanical properties. I shall do it on the main shaft of the sewing machine, because then the gearing is free to motor.
Speed range: 8 to 2000 rpm. At low speeds you need to provide a short term torque of 3.5 Nm. The motor power loss should be below 350 W in this situation to limit too fast temperature rise (it also depends of the mass of the motor). The mean torque at low speeds is likely below 1.2 Nm. At high speeds a shaft power limit of 140 W is sufficient, and it is 0.7 Nm. At low speeds you need good responsive speed control to limit the effect of load variations.

It will be nice to add on needle stop, that can be disabled and you can choose to stop at needle down or needle up. These positions are within 20 degrees of shaft. You then need to be able to get a fast stop from high speed with the inertia of machine and motor. Normally it is done with a magnet somewhere on shaft and digital hall elements to provide the stop signal. Low cost of components are preferred. Noise from motor is allowed, but it should not be annoying. Sometimes you like to have a little noise, because your ears works as a fast feed back on what is going on with the sewing proces.

I hope this provides reasonable information about requirements - otherwise ask.
With a brushed DC motor I looked at solutions with a gearing of 1:10 to motor.

I have tried to look a bit on the BLDC motors for drones and some RC hobby equipment. The price of such motors are going down. It seems that a lot is going on in development of FOC with ESCs to such motors. The motors seems quite powerful even though the weight are low. But for drones you do not need the low speed control and torque. But similar motors are used for robotics as well.

I just looked this video now. Yes, it is amazing. If some of these drives are made to be flexible with software, I think there could be a lot of possibilities in that.

A 1000 line encoder using interrupts on a 30RPM shaft can deliver 2kHz pulses/sec by triggering on all 4 rising and falling changes of the A&B signal lines, and you can trim it down to 1kHz by configuring the interrupts to just trigger on A changes or 500Hz with just A falling. At 30000RPM, you could use and ABZ encoder and switch over to triggering off of the index pulse, or run the AB signals through a divider. With some adaptive coding and a 1000PPR ABZ encoder you could handle a range from 15RPM to 30000RPM with interrupts between 1kHZ to 30kHz with some tradeoffs between resolution and speed. With some hardware dividers you could extend that RPM coverage further.

I guess, that it would be possible, but it do not seam easy like just reading the voltage from a DC tacho generator as shown above. I do not think, that the specific time between each edge of the two digital outputs from the encoder would be the same. So each of the four transitions timing would need to be calibrated individually.

Just now I use timer1 of the Arduino Nano for 20 kHz PWM to motor and control of ADC for current measurement. How can other timers be used to measure the time between transitions? Could you provide some link to an encoder, that you might suggest?

I should like to get a bit closer on how it is done, and how accurate it might be in the speed range. I think it can be hard to rely on interrupt routines to measure some timing, and therefor some hardware timer solution is needed to measure the time between these edges from encoder.