You can spoil my row any time.
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread Yesterday, 02:41
bmfrc bmfrc is offline
Registered User
FRC #5554
 
Join Date: Feb 2017
Location: Israel
Posts: 11
bmfrc is an unknown quantity at this point
encoder PIDController and set

Hi,

I'm trying to figure out the how to operate and use an encoder to maintain speed on our shooter.
  1. SetDistancePerPulse() - If our wheel circumference is 10cm then we should set SetDistancePerPulse(10/NUMBER_OF_PULSES). Using the GetDistance() will get the total distance in cm and the getrate() will get the cm per second. is that correct?

  2. pulses - We are using http://www.andymark.com/E4T-OEM-Mini...-p/am-3132.htm.
    The spec indicate:
    Cycles per Revolution: 360
    Pulses per Revolution: 1440
    Which one should we use? when we use 10/1440 we get rates and distanses that doesnt make sense. my feeling is that 10/250 make more sense.

  3. decoding scale - what exactly is the decoding scale and how does it affect our calculation?

  4. PIDController.SetSetpoint() - If we trying to get 10cm per second should we set PIDController.SetSetpoint(10) ?

Thanks a lot for your help!
Reply With Quote
  #2   Spotlight this post!  
Unread Yesterday, 02:54
ollien ollien is offline
Registered User
FRC #5202
 
Join Date: Feb 2015
Location: United States
Posts: 358
ollien is just really niceollien is just really niceollien is just really niceollien is just really nice
Re: encoder PIDController and set

1. If your wheel RADIUS is 10cm, then you should set setDistancePerPulse(10 * (2 * pi)/PULSES_PER_REVOLUTION). GetDistance will then get the total distance in cm and getRate will get the total cm per second.

2. Use ppr. The reason your values don't make sense is because you used circumference instead of radius.

3. I was never too sharp on this, but I BELIEVE 4X will result in you getting your ppr, while 1X will get you your cpr. In other words, you will get 1440 pulses with 4X and 360 pulses with 1X. I might have them flipped though.

4. Depends on what your PID controller is controlling. If it's controlling speed, sure. This purely depends on if you're feeding rate or distance into your PID controller.

EDIT: Major math error on my part. It should be 10*(2*pi)/PULSES_PER REVOLUTION

Last edited by ollien : Yesterday at 03:23. Reason: I made a math error.
Reply With Quote
  #3   Spotlight this post!  
Unread Yesterday, 03:05
bmfrc bmfrc is offline
Registered User
FRC #5554
 
Join Date: Feb 2017
Location: Israel
Posts: 11
bmfrc is an unknown quantity at this point
Re: encoder PIDController and set

Quote:
Originally Posted by ollien View Post
1. If your wheel RADIUS is 10cm, then you should set setDistancePerPulse(10/PULSES_PER_REVOLUTION). GetDistance will then get the total distance in cm and getRate will get the total cm per second.

2. Use ppr. The reason your values don't make sense is because you used circumference instead of radius.
Thanks for your help!!

Are you sure we should use the radius and not the circumference??
AFAK pulses represents degrees, so circumference/ppr will get the distanse per degree or degree fraction.
Reply With Quote
  #4   Spotlight this post!  
Unread Yesterday, 03:15
ollien ollien is offline
Registered User
FRC #5202
 
Join Date: Feb 2015
Location: United States
Posts: 358
ollien is just really niceollien is just really niceollien is just really niceollien is just really nice
Re: encoder PIDController and set

Quote:
Originally Posted by bmfrc View Post
Thanks for your help!!

Are you sure we should use the radius and not the circumference??
AFAK pulses represents degrees, so circumference/ppr will get the distanse per degree or degree fraction.
Linear displacement = angular displacement * radius. You may have seen this written as d = Θr in your physics class. You are correct that each pulse represents some number of degrees. In your example, one pulse represents .25 degrees (360/1440).

Last edited by ollien : Yesterday at 03:19.
Reply With Quote
  #5   Spotlight this post!  
Unread Yesterday, 03:25
ollien ollien is offline
Registered User
FRC #5202
 
Join Date: Feb 2015
Location: United States
Posts: 358
ollien is just really niceollien is just really niceollien is just really niceollien is just really nice
Re: encoder PIDController and set

I'm sorry for any confusion I caused. It's late at night over here and I forgot to check over my work. Haha. If you know the number of pulses per revolution, you therefore know the number of radians per pulse.

RPP = 2*pi/PPR.

Knowing this, combined with d = Θr, we know that each pulse will travel us a linear distance of RPP * r. In your case, this would be (2 * pi)/(1440) * 10 cm, for a 10 cm radiused wheel.
Reply With Quote
  #6   Spotlight this post!  
Unread Yesterday, 03:38
bmfrc bmfrc is offline
Registered User
FRC #5554
 
Join Date: Feb 2017
Location: Israel
Posts: 11
bmfrc is an unknown quantity at this point
Re: encoder PIDController and set

Quote:
Originally Posted by ollien View Post
I'm sorry for any confusion I caused. It's late at night over here and I forgot to check over my work. Haha. If you know the number of pulses per revolution, you therefore know the number of radians per pulse.

RPP = 2*pi/PPR.

Knowing this, combined with d = Θr, we know that each pulse will travel us a linear distance of RPP * r. In your case, this would be (2 * pi)/(1440) * 10 cm, for a 10 cm radiused wheel.
In other words its circumference/ppr :-)
Reply With Quote
  #7   Spotlight this post!  
Unread Yesterday, 03:39
ollien ollien is offline
Registered User
FRC #5202
 
Join Date: Feb 2015
Location: United States
Posts: 358
ollien is just really niceollien is just really niceollien is just really niceollien is just really nice
Re: encoder PIDController and set

Quote:
Originally Posted by bmfrc View Post
In other words its circumference/ppr :-)
You know, I never noticed that relationship. I always thought it through as a calculation of distance with radians per tick.

I'll let someone else answer this. I think I've successfully talked myself into a circle here.
Reply With Quote
  #8   Spotlight this post!  
Unread Yesterday, 03:40
bmfrc bmfrc is offline
Registered User
FRC #5554
 
Join Date: Feb 2017
Location: Israel
Posts: 11
bmfrc is an unknown quantity at this point
Re: encoder PIDController and set

Quote:
Originally Posted by ollien View Post
You know, I never noticed that relationship. I always thought it through as a calculation of distance with radians per tick.

I'll let someone else answer this. I think I've successfully talked myself into a circle here.
lol thanks man!!!
Reply With Quote
  #9   Spotlight this post!  
Unread Yesterday, 13:56
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,609
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: encoder PIDController and set

1x and 4x decoding affect which edges the FPGA counts, but not the reported distance. When you select 4x, WPILib scales the output to be the same as 1x, ie if DistancePerPulse is 1, in 4x you would get values of 1.0, 1.25, 1.50, 1.75, 2.0, and in 1x you would just get 1.0, 2.0, etc.

The FPGA measures rate by timing successive pulses. In 4x decoding, the next pulse is from the opposite channel, which means that you will see a lot of noise. If you look phase relation specs for the the E4T, the relationship can vary by up to 60 degrees, which means you could get 2/3 of the measurement as noise. It's much better to use 1x decoding for rate, so the same edge is always being counted. It's also better to use a lower resolution encoder, so that there is a longer time period between pulses.

This is based on using the roboRIO for decoding the encoder. If using the Talon SRX, the opposite applies, it's rate algorithm wants a very high resolution encoder (although this might not be an issue with the 2.22 firmware).

Last edited by Joe Ross : Yesterday at 15:34.
Reply With Quote
  #10   Spotlight this post!  
Unread Today, 05:14
bmfrc bmfrc is offline
Registered User
FRC #5554
 
Join Date: Feb 2017
Location: Israel
Posts: 11
bmfrc is an unknown quantity at this point
Re: encoder PIDController and set

Thanks Joe!
I'm really new to this stuff..

Quote:
Originally Posted by Joe Ross View Post
1x and 4x decoding affect which edges the FPGA counts, but not the reported distance. When you select 4x, WPILib scales the output to be the same as 1x, ie if DistancePerPulse is 1, in 4x you would get values of 1.0, 1.25, 1.50, 1.75, 2.0, and in 1x you would just get 1.0, 2.0, etc.
Im not sure i understand the scaling thing.
if 4X output higher resolution to 1.25, 1.50 VS 1, 2 of the 1x, where is the scaling?
Does it affect the DistancePerPulse calculation from our side? we devide the circumference by 360 or 1440?

Quote:
Originally Posted by Joe Ross View Post
It's much better to use 1x decoding for rate, so the same edge is always being counted. It's also better to use a lower resolution encoder, so that there is a longer time period between pulses.
What about measuring distance? should we use 4x decoding?
Reply With Quote
Reply


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 15:30.

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