Go to Post When I'm asked the question, "What is the most important computer language to learn to prepare me for a programming career?"; my answer is, "Your second one." - Greg McKaskle [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 21-02-2012, 20:42
jaysun jaysun is offline
Registered User
no team
 
Join Date: Feb 2012
Rookie Year: 2000
Location: USA
Posts: 17
jaysun is an unknown quantity at this point
Consistent encoder rate

Hi,

Our team is having trouble getting a consistent rate value from one of the optical encoders. The Rate value jumps around a lot, even when we use 1x decoding and choose to average 127 samples. When we made our own rate code based on the encoder's Distance, the variance persisted. It really messes with our PID loop when it tries to keep the speed of the motor consistent. (Note: the jumpiness occurs when the PID loop is not controlling the speed of the motor, so the problem is not caused by the PID controller.)

Any idea what the problem could be and how to fix it?

Thanks for any advice.

Last edited by jaysun : 21-02-2012 at 20:56.
  #2   Spotlight this post!  
Unread 21-02-2012, 22:00
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Consistent encoder rate

Quote:
Originally Posted by jaysun View Post
Hi,

Our team is having trouble getting a consistent rate value from one of the optical encoders. The Rate value jumps around a lot, even when we use 1x decoding and choose to average 127 samples. When we made our own rate code based on the encoder's Distance, the variance persisted. It really messes with our PID loop when it tries to keep the speed of the motor consistent. (Note: the jumpiness occurs when the PID loop is not controlling the speed of the motor, so the problem is not caused by the PID controller.)

Any idea what the problem could be and how to fix it?

Thanks for any advice.
What is the encoder brand and model number ?

If you rotate it slowly by hand and read the encoder counts, do you get consistent results for each rev of the shaft?

Check to make sure the optical disk is properly mounted to the shaft.


  #3   Spotlight this post!  
Unread 21-02-2012, 22:13
jaysun jaysun is offline
Registered User
no team
 
Join Date: Feb 2012
Rookie Year: 2000
Location: USA
Posts: 17
jaysun is an unknown quantity at this point
Re: Consistent encoder rate

We use this. Tomorrow I will make sure the optical disk is properly mounted to the shaft and I will rotate the shaft slowly by hand and read the encoder counts and I'll let you know if I get consistent results for each revolution of the shaft.
  #4   Spotlight this post!  
Unread 21-02-2012, 22:28
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Consistent encoder rate

Quote:
Originally Posted by jaysun View Post
We use this. Tomorrow I will make sure the optical disk is properly mounted to the shaft
Look at the 2:15 minute mark of this video:

http://www.youtube.com/watch?v=4hJfzhxZwKw


  #5   Spotlight this post!  
Unread 22-02-2012, 16:25
jaysun jaysun is offline
Registered User
no team
 
Join Date: Feb 2012
Rookie Year: 2000
Location: USA
Posts: 17
jaysun is an unknown quantity at this point
Re: Consistent encoder rate

Since I forgot my team is not meeting until next Tuesday, I will check it then.

Averaging the rate further with a moving average gives us a mostly constant speed (+-2%), but the problem is that when the PID loop adjusts the motor speed, it will oscillate the motors because the "moving-averaged" process variable that the PID uses does not accurately reflect the present rate of the motor. Would applying any of the filters described in this thread give us a smoothed rate that more accurately reflects the present speed of the motor?
  #6   Spotlight this post!  
Unread 28-02-2012, 19:23
jaysun jaysun is offline
Registered User
no team
 
Join Date: Feb 2012
Rookie Year: 2000
Location: USA
Posts: 17
jaysun is an unknown quantity at this point
Re: Consistent encoder rate

No luck. We have decided to look into testing the magnetic encoder from the KOP on a test motor.

Last edited by jaysun : 28-02-2012 at 20:19.
  #7   Spotlight this post!  
Unread 28-02-2012, 20:48
slijin's Avatar
slijin slijin is offline
Pockets
AKA: Samuel Lijin
FRC #0694 (StuyPulse)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York City
Posts: 537
slijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to behold
Re: Consistent encoder rate

Quote:
Originally Posted by jaysun View Post
We use this. Tomorrow I will make sure the optical disk is properly mounted to the shaft and I will rotate the shaft slowly by hand and read the encoder counts and I'll let you know if I get consistent results for each revolution of the shaft.
How did this work out?
__________________

2010-12 CT Chairman's
2011 Galileo 5th seed
2010 NY Regional Winners
  #8   Spotlight this post!  
Unread 28-02-2012, 20:56
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Consistent encoder rate

Quote:
Originally Posted by slijin View Post
How did this work out?
Like so:

Quote:
Originally Posted by jaysun View Post
No luck. We have decided to look into testing the magnetic encoder from the KOP on a test motor.
  #9   Spotlight this post!  
Unread 28-02-2012, 21:55
slijin's Avatar
slijin slijin is offline
Pockets
AKA: Samuel Lijin
FRC #0694 (StuyPulse)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York City
Posts: 537
slijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to behold
Re: Consistent encoder rate

Quote:
Originally Posted by Ether View Post
Like so:
I wanted him to clarify whether that post was pertinent to the attempt at filters or rotating by hand. I should've been more clear on that point.
__________________

2010-12 CT Chairman's
2011 Galileo 5th seed
2010 NY Regional Winners
  #10   Spotlight this post!  
Unread 28-02-2012, 22:15
jaysun jaysun is offline
Registered User
no team
 
Join Date: Feb 2012
Rookie Year: 2000
Location: USA
Posts: 17
jaysun is an unknown quantity at this point
Re: Consistent encoder rate

I tightened the encoder discs on the axle as shown in the video, and I made sure there wasn't any slipping. When I rotated the encoders by hand, the Distance count was kind of consistent: I'd say about +-10 counts.

I tested an IIR filter of the encoder speed and compared it to a moving average. You can see an example of my results in this video. The problem with the PID loop adjusting the speed is still present. I'm still not sure if there is a good filter or not.
  #11   Spotlight this post!  
Unread 28-02-2012, 22:34
slijin's Avatar
slijin slijin is offline
Pockets
AKA: Samuel Lijin
FRC #0694 (StuyPulse)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York City
Posts: 537
slijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to behold
Re: Consistent encoder rate

Quote:
Originally Posted by jaysun View Post
I tightened the encoder discs on the axle as shown in the video, and I made sure there wasn't any slipping. When I rotated the encoders by hand, the Distance count was kind of consistent: I'd say about +-10 counts.

I tested an IIR filter of the encoder speed and compared it to a moving average. You can see an example of my results in this video. The problem with the PID loop adjusting the speed is still present. I'm still not sure if there is a good filter or not.
That's an extraordinarily noisy signal. Is the green the moving average and the red the IIR? Also, just out of curiosity: how are you obtaining the encoder input, through a Jaguar or the DSC?

I don't know about you, but we ran into issues with scratched encoder wheels and damaged encoder wires (there was no visible damage; I assume it was internal from abusive zip-tying, but swapping out the wire resolved the issue).

A bit of advice I've been given by my mentor (although I've never personally experienced this problem) is to always separate signal runs from power runs so that the power runs don't induce noise in the signal; if they have to cross, run them at right angles. Ether would be able to elaborate more on this.
__________________

2010-12 CT Chairman's
2011 Galileo 5th seed
2010 NY Regional Winners
  #12   Spotlight this post!  
Unread 28-02-2012, 22:58
jaysun jaysun is offline
Registered User
no team
 
Join Date: Feb 2012
Rookie Year: 2000
Location: USA
Posts: 17
jaysun is an unknown quantity at this point
Re: Consistent encoder rate

Quote:
Originally Posted by slijin View Post
That's an extraordinarily noisy signal. Is the green the moving average and the red the IIR? Also, just out of curiosity: how are you obtaining the encoder input, through a Jaguar or the DSC?

I don't know about you, but we ran into issues with scratched encoder wheels and damaged encoder wires (there was no visible damage; I assume it was internal from abusive zip-tying, but swapping out the wire resolved the issue).

A bit of advice I've been given by my mentor (although I've never personally experienced this problem) is to always separate signal runs from power runs so that the power runs don't induce noise in the signal; if they have to cross, run them at right angles. Ether would be able to elaborate more on this.
I should clarify my last post and note that my video was not based off my actual data. I generated the "measurement" (green line) by adding a random number to the rate I set - in reality the "amplitude" of the noise is about half of that. The red line is the IIR, and the blue line is the moving average.

With the optical encoder I use the DSC.

Yes, I made sure the encoder wheels were not scratched - I scratched a lot of them when we first started using them last year. We did twist the encoder wires with a hand drill to make the wiring look good - maybe that's a problem?

Thanks for the ideas. I'll try to use a new, different encoder cable and separate the power and data wires and see if the rate I get is any less noisy.

Last edited by jaysun : 28-02-2012 at 23:01.
  #13   Spotlight this post!  
Unread 28-02-2012, 23:55
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Consistent encoder rate

Here are a couple other things to consider:

Quote:
Originally Posted by jaysun View Post
I tightened the encoder discs on the axle as shown in the video, and I made sure there wasn't any slipping. When I rotated the encoders by hand, the Distance count was kind of consistent: I'd say about +-10 counts.
+-10 out of how many? and roughly how accurately did you rotate it (i.e. by "eye" or did you make a mark etc)

Quote:
Originally Posted by jaysun View Post
The Rate value jumps around a lot, even when we use 1x decoding and choose to average 127 samples.
127 samples at 20ms per sample? That's 2½ seconds. That's not what you meant is it?

Quote:
When we made our own rate code based on the encoder's Distance, the variance persisted.
This doesn't sound right. Would you mind describing exactly what you did?

- 1x or 4x?

- Counter class or Encoder class or something else?

- sample time? how controlled? measured or assumed?

- did your code look like this: read count, subtract previous count, divide by measured elapsed time since previous sample?


  #14   Spotlight this post!  
Unread 29-02-2012, 00:13
slijin's Avatar
slijin slijin is offline
Pockets
AKA: Samuel Lijin
FRC #0694 (StuyPulse)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York City
Posts: 537
slijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to behold
Re: Consistent encoder rate

Quote:
Originally Posted by jaysun View Post
I should clarify my last post and note that my video was not based off my actual data. I generated the "measurement" (green line) by adding a random number to the rate I set - in reality the "amplitude" of the noise is about half of that. The red line is the IIR, and the blue line is the moving average.

With the optical encoder I use the DSC.

Yes, I made sure the encoder wheels were not scratched - I scratched a lot of them when we first started using them last year. We did twist the encoder wires with a hand drill to make the wiring look good - maybe that's a problem?

Thanks for the ideas. I'll try to use a new, different encoder cable and separate the power and data wires and see if the rate I get is any less noisy.
Twisting the wires like that is some serious abuse; you're placing a lot of tension on a solid length of copper. Wire may flex, but spinning it is asking for trouble. If anything, braid the wires.

To clarify, I don't mean separating the power and data lines coming from the encoder; I meant separating all 4 encoder lines (+5, A, B, GND) from the power lines going to the motor. Ether, could you comment on how recognizable this effect would be?
__________________

2010-12 CT Chairman's
2011 Galileo 5th seed
2010 NY Regional Winners
  #15   Spotlight this post!  
Unread 29-02-2012, 00:30
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Consistent encoder rate

Quote:
Originally Posted by slijin View Post
Ether, could you comment on how recognizable this effect would be?
I don't have any pertinent test data. It would make a good project. Put a scope on an encoder signal wire and observe the noise when it's routed near motor wires. Has anybody done this and have data to share?


Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 01:36.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi