View Single Post
  #2   Spotlight this post!  
Unread 28-02-2012, 19:29
plnyyanks's Avatar
plnyyanks plnyyanks is online now
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,113
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: Using a magnetic encoder to get speed of a motor

Can't you just WPILib's encoder VIs? Encoder Get has an output for rate, which is scaled accordingly to Distance Per Count (which you set when you opened the encoder in Begin.vi). That should do it for you.
Click image for larger version

Name:	Untitled.png
Views:	36
Size:	53.0 KB
ID:	12155

If you can't/don't want to calculate Rate this way, you can do it this way:
Code:
average_rate = delta_position / delta_time
So...
Code:
average_rate = (current_position - previous_position)/(current_time - previous_time)
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android
Reply With Quote