go away spammer

Author Topic: Measure DC Gear Motor RPM  (Read 7010 times)

0 Members and 1 Guest are viewing this topic.

Offline twinsratioTopic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Measure DC Gear Motor RPM
« on: January 21, 2011, 02:35:21 AM »
Hi there,

I have a motor speed controller project using Cytron  SPG-E30-20k DC Gear Motor with Hall Effect Quadrature Encoder.

I need to know the actual rpm the motor is running at.

How can I get the actual rpm of the motor?

From the motor spec, I know that the resolution of the motor is 12 counts per revolution.,with gear ration of 20:1.

How to calculate or compute the rpm of the motor? Do I need pulse per revolution of motor to compute the rpm?
There is only count per revolution written in data sheet.

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
Re: Measure DC Gear Motor RPM
« Reply #1 on: January 21, 2011, 08:51:04 AM »
You get the pulse train from the encoder, integrate it over a time interval, say one second, and then your speed will be #counts/20 rps

Offline twinsratioTopic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: Measure DC Gear Motor RPM
« Reply #2 on: January 21, 2011, 09:51:18 AM »
Sorry Rbtying, I don't quite understand how to get the pulse train from the encoder. I don't quite understand what is pulse train. Can you elaborate more on how I could integrate it over a time interval?

Thank you in advance.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: Measure DC Gear Motor RPM
« Reply #3 on: January 21, 2011, 11:25:54 AM »
A "pulse train" is what the voltage output from the encoder looks like over time with the motor running. The encoder's output will go high, low, high, low, etc. So it looks like a 'train' of pulses.

Since you know there is 20 such pulses in one revolution of the motor, just count how many there are in 1 second and divide by 20, which gives you the rps (revolutions per second).

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Measure DC Gear Motor RPM
« Reply #4 on: January 21, 2011, 11:14:05 PM »
Hi,

I need to know the actual rpm the motor is running at.

How can I get the actual rpm of the motor?

From the motor spec, I know that the resolution of the motor is 12 counts per revolution.,with gear ration of 20:1.

How to calculate or compute the rpm of the motor? Do I need pulse per revolution of motor to compute the rpm?
There is only count per revolution written in data sheet.
Assuming you actually mean the speed of the motor and not its output shaft (which is 20 times slower) and that the 12 counts per revolution holds true, the formula would be:
  Pulses pr. second * 5

Another way of getting the number is measuring the time between each pulse and this way, the formula is:
  5 / T
Where T is the period of each pulse in seconds (the time from one pulse start to the time the next pulse start).

You need to see the data sheet about how to get the pulses from the decoder. If you post a link to the data sheet, a simple circuit could be suggested.

You need some kind of timer/counter to get the measurement of course.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline twinsratioTopic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: Measure DC Gear Motor RPM
« Reply #5 on: January 21, 2011, 11:54:52 PM »
Hi Soeren,

http://www.cytron.com.my/viewProduct.php?pid=KBQZOikuLx0ZNTIBBiYMJUMx4pzoDkE497BSxD2sgqE=

Please refer to the above link, it provides some details of the motor(SPG-30E-20K).

As you mentioned the formula would be "pulse per revolution.second *5", can I know what is it 5 and pulse per revolution.second means?

12 counts per revolution is the output of the shaft, main shaft is 240 counts per revolution.

Sorry, I'm kind of confused. Please advise and thank you for the time.

Thank you.

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Measure DC Gear Motor RPM
« Reply #6 on: January 22, 2011, 12:49:17 AM »
Hi,

No need to cross post to my PM box.

Please refer to the above link, it provides some details of the motor(SPG-30E-20K).
I'd say. The user manual has got all you need to do it.


[...] can I know what is it 5
Sure...
Hold up your left hand.
Start counting your fingers.
Assuming you didn't play too much with power tools, sooner or later, you should arrive at "5"  ;)


and pulse per revolution.
I wrote pulses per second and that really shouldn't need an explanation, but it's the count of pulses coming from the decoder in one second.


second means?
Second: A short time for humans and a very long time for a microcontroller.
(I'm just rambling here, as I don't really know what you're getting at).


12 counts per revolution is the output of the shaft, main shaft is 240 counts per revolution.

Sorry, I'm kind of confused. Please advise and thank you for the time.
Perhaps a deep breath and a back to square one is in order...
What do you want to measure - motor speed or output shaft speed?
What tools do you have to do that (counter/timer, oscilloscope or whatever)?
Do you have any insight in electronics and can you build from a schematic?
Why do you need to measure the RPM anyway?

The user manual, page 5, the connector.
Pin
 1 and 2 is for the motor supply.
 3 should have +5V (supply for the "pulse output circuit")
 4 is ground (0V) for the pulse circuit
Since you are not interested in the direction of rotation, you can use either pin 5 or pin 6 as the pulse output.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline twinsratioTopic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: Measure DC Gear Motor RPM
« Reply #7 on: January 22, 2011, 02:12:24 AM »
Hi Soeren,

Actually I wanted to measure the output shaft speed in RPM. I'm doing a dc motor speed controller project, and my project supervisor asked me to measure the motor shaft output rpm. 

I have only oscilloscope, no timer or counter. From oscilloscope, I'm getting frequency of 228Hz and period of 4.38ms. Is that any way I could calculate the rpm from the about data from oscilloscope? And may I know how to get pulse per revolution?



Thank you,

Offline hopslink

  • Robot Overlord
  • ****
  • Posts: 202
  • Helpful? 14
Re: Measure DC Gear Motor RPM
« Reply #8 on: January 22, 2011, 05:02:13 AM »
Shaft rpm will be given by:

(encoder_count_per_second * 60) / (encoder_count_per_revolution * output_gear_ratio)

Plugging in values of encoder_pulses_per_revolution = 12 and output_gear_ratio = 20  this will simplify to:

encoder_count_per_second / 4

Measuring just one of the encoder output channels looks to change things slightly. From the diagram in the datasheet it looks like a 'count' is a binary state change on either of two channels so 'count' is not the same as pulses per channel (where a pulse is a cycle of the waveform measured from (either) one of the encoder output channels - which you are measuring with your 'scope). Fortunately the diagram also suggests that there should be three pulses per revolution on either of the channels.

So for measuring using one output of the encoder, shaft rpm will be given by:

(channel_pulses_per_second * 60) / (channel_pulses_per_revolution * output_gear_ratio)

Plugging in values of  channel_pulses_per_revolution = 3 and output_gear_ratio = 20  this simplifies nicely to:

Shaft rpm = channel_pulses_per_second

If you get 228Hz from one channel of your encoder then the shaft should be turning at 228 rpm.

Channel pulses per revolution for the shaft is:

channel_pulses_per_revolution * output_gear_ratio = 60

N.B. This is based on my interpretation of the datasheet and it's non-definition of exactly what a 'count' is. To confirm by experimentation - disconnect power to the motor but leave the encoder powered and connected to your scope. Slowly turn the output shaft a quater turn and count complete output cycles on one channel of the encoder. This will be 15 if my interpretation is correct, if it is more like 60 then 'count' and 'pulse' can be used interchangeably so use the first formula.  
« Last Edit: January 22, 2011, 09:20:58 AM by hopslink »

Offline twinsratioTopic starter

  • Jr. Member
  • **
  • Posts: 16
  • Helpful? 0
Re: Measure DC Gear Motor RPM
« Reply #9 on: January 22, 2011, 06:39:30 AM »
Hi hopslink.....


Thank you so much.....it's been  a great help for me.

Thank you so much and at the same time thanks to Soeren.

Thank you.

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Measure DC Gear Motor RPM
« Reply #10 on: January 22, 2011, 11:54:55 AM »
Hi,

Measuring just one of the encoder output channels looks to change things slightly. From the diagram in the datasheet it looks like a 'count' is a binary state change on either of two channels so 'count' is not the same as pulses per channel (where a pulse is a cycle of the waveform measured from (either) one of the encoder output channels - which you are measuring with your 'scope). Fortunately the diagram also suggests that there should be three pulses per revolution on either of the channels.
The data sheet says 12 pulses per rotation and so does the source code!
I guess you're misreading the quadrature output curve to get to your conclusion?


N.B. This is based on my interpretation of the datasheet and it's non-definition of exactly what a 'count' is.
Oh, the data sheet is quite clear on that IMO and the source code substantiates the 12 pulses per revolution.


The formula for output shaft RPM is (5/20)/T or 0.25/T
The 4.38ms inter-pulse time thus equates to: 0.25 / 0.00438 = 57 RPM.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline hopslink

  • Robot Overlord
  • ****
  • Posts: 202
  • Helpful? 14
Re: Measure DC Gear Motor RPM
« Reply #11 on: January 22, 2011, 04:24:02 PM »
Quote
The data sheet says 12 pulses per rotation and so does the source code!
The the datasheet actually says 12 'counts' per revolution and makes no mention of pulses. To me a logic pulse would be a 0>1 transition followed by a 1>0 (or 1 cycle of a square wave).

The quadrature output curve suggested to me that a 'count' was effectively a logic state transition on either channel A OR B and thus the 12 'count' is the result of 3 complete square wave cycles (pulses) output on BOTH channels.

As the OP is measuring using an oscilloscope I was working on the assumption that he is probing between the Hall effect sensor GND input and ONE (either) of the output channels A or B, thus should see a square wave with a frequency 3x the motor rev/s.  

Quote
I guess you're misreading the quadrature output curve to get to your conclusion?
Very likely  :). I wasn't completely sure, thus my Nota Bene... however looking at the source code it appears to support my conclusion, counting state transitions on both channels.

Code: [Select]
countAB=0; //reset the counter
lcd_clr();        //clear lcd screen
while(countAB < limit) //while counter is in the limit
{ //motor will overshoot because it can not sudden stop
initA = A; //get current A value //overshoot depends on load and speed of the motor
initB = B; //get current B value
do
{
run_cw(speed); //run motor in clockwise direction with user defined speed
}while(initA ==A && initB ==B);        //continue run until state change
countAB++; //increment counter for each state change
}

Quote
Oh, the data sheet is quite clear on that IMO...
And in my opinion it isn't clear enough. The fact it leaves scope for opinion suggests it is incomplete!    
« Last Edit: January 22, 2011, 04:32:53 PM by hopslink »

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Measure DC Gear Motor RPM
« Reply #12 on: January 22, 2011, 05:13:17 PM »
Hi,

The the datasheet actually says 12 'counts' per revolution and makes no mention of pulses. To me a logic pulse would be a 0>1 transition followed by a 1>0 (or 1 cycle of a square wave).

The quadrature output curve suggested to me that a 'count' was effectively a logic state transition on either channel A OR B and thus the 12 'count' is the result of 3 complete square wave cycles (pulses) output on BOTH channels.

12 counts, on that we agree (and counts equals pulses and periods - just different ways to wiev it).
Each count has got 4 logic states (eg. 00, 01, 11 and 10) when you are doing quadrature on the two 90° offset pulse trains. If you looked at just a single signal, each count would have just two logic states, "0" and "1".
Perhaps that clears it up for you?


Code: [Select]
countAB=0; //reset the counter
[...]

You missed:
Code: [Select]
    //convert the desired agle to the total angle at the rear shaft (multiply gear ratio)                       
    smalldegree = desire_angle *gear_ratio;
    //12 count per revolution at the rear shaft
    //meaning each count represent 30 degree
    //to calculate how many counts needed for the desire angle
    //we divide total angle at the rear shaft with 30 degree   
    limit = smalldegree/30;

30° each step.
One revolution is 360°.
360/30=12


Quote
Oh, the data sheet is quite clear on that IMO...
And in my opinion it isn't clear enough. The fact it leaves scope for opinion suggests it is incomplete!    

Unless you're a certified electronics engineer, or have the equivalent knowledge on the subject, your opinion is not a valid argument!

There will always be someone with a differing opinion and lack of understanding, but...
Data sheets are targeted for being used by engineers, not for amateurs lacking the fundamentals of the subject and thereby the definitions that are not mentioned, since they're considered a prerequisite to understanding the data sheet in the first place.

To read this data sheet correctly, you need to understand the basic concepts of quadrature signals, counts/pulses/periods and logic states.

I wouldn't try to decode my GF's knitting recepies, as I don't have a clue of the basics, but should I for some strange reason change my mind, I would start with a couple of really basic knitting books and work my way towards an understanding, rather than just try to "interpret" the weird codes, that she reads as if clear language.
They're not incorrect, imprecise or open to interpretation (if you want the exact product it describes) just because I don't understand them.

In the same spirit, you may wanna read up on the subject (of quadrature detectors, not knitting of course ;))
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline hopslink

  • Robot Overlord
  • ****
  • Posts: 202
  • Helpful? 14
Re: Measure DC Gear Motor RPM
« Reply #13 on: January 22, 2011, 07:26:31 PM »
Quote
12 counts, on that we agree
That depends what you call a count... see below :)

Quote
counts equals pulses and periods - just different ways to wiev it.
Each count has got 4 logic states (eg. 00, 01, 11 and 10) when you are doing quadrature on the two 90° offset pulse trains. If you looked at just a single signal, each count would have just two logic states, "0" and "1".
Perhaps that clears it up for you?

That clears up YOUR definition of a 'count', and in this case it matches my definition of a 'pulse' as seen by the OP using an oscilloscope on one output channel.

Quote
You missed...
I didn't include it, but probably should have, so for completeness:
Code: [Select]
void motor_run(unsigned char speed, unsigned long degree)
{
desire_angle = degree;
//in this case gear ratio is 1:20
gear_ratio = 20;
//convert the desired agle to the total angle at the rear shaft (multiply gear ratio)
smalldegree = desire_angle *gear_ratio;
//12 count per revolution at the rear shaft
//meaning each count represent 30 degree
//to calculate how many counts needed for the desire angle
//we divide total angle at the rear shaft with 30 degree
limit = smalldegree/30;

countAB=0; //reset the counter
lcd_clr(); //clear lcd screen
while(countAB < limit) //while counter is in the limit
{ //motor will overshoot because it can not sudden stop
initA = A; //get current A value //overshoot depends on load and speed of the motor
initB = B; //get current B value
do
{
run_cw(speed); //run motor in clockwise direction with user defined speed
}while(initA ==A && initB ==B); //continue run until state change
countAB++; //increment counter for each state change
}
//once program exit the previous while loop
//meaning that the motor has reached the desired angle
stop(1000);
}
As you point out they divide the angle by 30 to give 12 'counts' per motor revolution and call that number limit.

So by YOUR definition of a count above, they should count (limit * 4) state transitions on lines A&B.

The code shows they count only limit transitions NOT (limit * 4) ie their definition of a 'count' is different to yours (yours being correct for quadrature encoders). By your definition this encoder has just 3 'counts' per revolution according to the code... Hence my argument that IMO ;) the data sheet should be explicit on exactly what the manufacturer means by a 'count'.

Quote
Unless you're a certified electronics engineer, or have the equivalent knowledge on the subject, your opinion is not a valid argument!
Quite right!

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Measure DC Gear Motor RPM
« Reply #14 on: January 22, 2011, 11:28:05 PM »
Hi,

So by YOUR definition of a count above, they should count (limit * 4) state transitions on lines A&B.

The code shows they count only limit transitions NOT (limit * 4) ie their definition of a 'count' is different to yours (yours being correct for quadrature encoders). By your definition this encoder has just 3 'counts' per revolution according to the code... Hence my argument that IMO ;) the data sheet should be explicit on exactly what the manufacturer means by a 'count'.
I stand corrected about the ambiguity of this data sheet/user manual!
(Just cleaned up their messy code a bit to be able to follow it - I get a feeling that it's produced in India or China, or perhaps my editor just makes it look bad... Or both).

You are absolutely correct about the count vs. pulse in this manual and hence that the manual ought to be a bit more specific about their use of non-standard definitions.

With this in mind, the formula should be just 1/T and the 4.38 ms thus equates to (1/0.00438=) 228.3 RPM

I sure hope the mechanical quality of the motor/gear head surpasses that of its documentation.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

 


Get Your Ad Here