OCCRA
Go to Post Man, Dave always has to one up us. We build robots to play games, he build robots to go on other planets, Elgin makes CD 30 inches, you make it 63 inches. - Levin571 [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Events   CD-Media   CD-Spy   FRC-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 02-25-2012, 06:40 PM
cooltext cooltext is offline
Registered User
FRC #0835
 
Join Date: Jan 2012
Location: Michigan
Posts: 32
cooltext is an unknown quantity at this point
RPM calculator

I have the AS5030 rotary encoders and I was trying to find a way to calculate the RPM of our shooter motors with it. Does any one have any idea how to do so? I tried the counter class but I am having trouble selecting the

Code:
  AnalogTriggerOutput.Type triggerType
to use and how to calculate what voltage limits I should use for kTypeState.

Also how could I make it so it had a very small sampling time like .1 of a second?
Reply With Quote
  #2   Spotlight this post!  
Unread 02-27-2012, 08:31 AM
dbeckwith's Avatar
dbeckwith dbeckwith is offline
Lead Programmer
AKA: Daniel Beckwith
FRC #3205 (The Patriots)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: USA
Posts: 84
dbeckwith is an unknown quantity at this point
Re: RPM calculator

Try just using the Encoder class. That should have everything you need. Just make sure you use setDistancePerPulse() with the right units and you can get the speed (this class gives speeds in units per second, not minute, but you can always scale it).
__________________
q = (2*b) | ~(2*b);

if (life.getLemons() != null) this.lemonade = new Drink(life.getLemons());
else throw new NoLemonsException("What now?");


Reply With Quote
  #3   Spotlight this post!  
Unread 02-27-2012, 10:19 AM
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: 7,841
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
Quote:
Originally Posted by dbeckwith View Post
Try just using the Encoder class. That should have everything you need.

The AS5030 is not a quaderature encoder. It won't work with the encoder class.
Reply With Quote
  #4   Spotlight this post!  
Unread 02-27-2012, 04:02 PM
joelg236 joelg236 is offline
Registered User
AKA: Joel Gallant
no team
Team Role: Alumni
 
Join Date: Dec 2011
Rookie Year: 2012
Location: Calgary
Posts: 678
joelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond repute
Re: RPM calculator

Quote:
Originally Posted by Joe Ross View Post
The AS5030 is not a quaderature encoder. It won't work with the encoder class.
And what would you suggest then? That was not helpful.
Reply With Quote
  #5   Spotlight this post!  
Unread 02-27-2012, 04:45 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 6,025
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: RPM calculator

Quote:
Originally Posted by joelg236 View Post
And what would you suggest then? That was not helpful.
Well, it helped him avoid wasting time going down a rabbit hole.

A bit of advice, if you are open to it: as a newcomer you might want to be a bit more respectful, especially with people like Joe who have helped countless people over the past 10 years.


Reply With Quote
  #6   Spotlight this post!  
Unread 02-27-2012, 07:17 PM
cooltext cooltext is offline
Registered User
FRC #0835
 
Join Date: Jan 2012
Location: Michigan
Posts: 32
cooltext is an unknown quantity at this point
Re: RPM calculator

Thanks for your replies, but I was just wondering if anyone had any ideas for the RPM issue?

thanks
Dimitir
Reply With Quote
  #7   Spotlight this post!  
Unread 02-28-2012, 09:37 AM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 6,025
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: RPM calculator

Quote:
Originally Posted by cooltext View Post
Thanks for your replies, but I was just wondering if anyone had any ideas for the RPM issue?
You could try opening the P1 solder bridge and connecting the JP3-1 Cos signal to DIO and use the Counter class. Not sure if that would work. Has anyone tried it?

Or you could use a sensor more suited to your purpose.


Reply With Quote
  #8   Spotlight this post!  
Unread 02-28-2012, 10:39 AM
ProgrammerMatt ProgrammerMatt is offline
Programmer-Electrical-Mechanical
FRC #0228 (Gus)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Southington
Posts: 126
ProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really nice
Re: RPM calculator

The encoder class works with both i belive..
if so
Code:
Encoder myencoder = new Encoder(#);

myencoder.getRate();
the the rate works off ticks per secound you need to scale it down.
Reply With Quote
  #9   Spotlight this post!  
Unread 02-28-2012, 03:41 PM
dbeckwith's Avatar
dbeckwith dbeckwith is offline
Lead Programmer
AKA: Daniel Beckwith
FRC #3205 (The Patriots)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: USA
Posts: 84
dbeckwith is an unknown quantity at this point
Re: RPM calculator

Quote:
Originally Posted by ProgrammerMatt View Post
The encoder class works with both i belive..
if so
Code:
Encoder myencoder = new Encoder(#);

myencoder.getRate();
the the rate works off ticks per secound you need to scale it down.
No, I think Joe is right. The Encoder class is for quadrature encoders which use two signals, and this encoder the OP is trying to use only has one signal and if I'm not mistaken produces a different type of signal (the way it counts rotation is different). It's unfortunate that there's no built-in FRC class for those encoders though.
__________________
q = (2*b) | ~(2*b);

if (life.getLemons() != null) this.lemonade = new Drink(life.getLemons());
else throw new NoLemonsException("What now?");


Reply With Quote
  #10   Spotlight this post!  
Unread 02-28-2012, 03:57 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 6,025
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: RPM calculator


According to the operation manual for the AS5030 adapter board, if you open the P1 solder bridge you can access cos&sin quadrature signals at JP3 pins 1&3. Not sure if the WPILib Encoder class will work with those waveforms without some signal conditioning. Has anyone tried and succeeded?


Last edited by Ether : 02-28-2012 at 04:05 PM. Reason: corrected pinout
Reply With Quote
  #11   Spotlight this post!  
Unread 02-28-2012, 07:04 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 6,025
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: RPM calculator

Quote:
Originally Posted by Ether View Post
You could try opening the P1 solder bridge and connecting the JP3-1 Cos signal to DIO and use the Counter class. Not sure if that would work. Has anyone tried it?
Apparently someone has tried it, and was successful. See Post#3 in this thread:

https://decibel.ni.com/content/thread/11955


Reply With Quote
  #12   Spotlight this post!  
Unread 02-28-2012, 10:00 PM
ProgrammerMatt ProgrammerMatt is offline
Programmer-Electrical-Mechanical
FRC #0228 (Gus)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Southington
Posts: 126
ProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really nice
Re: RPM calculator

Does it output analog or digital? if its digital try using the Counter class, if its analog then use something like
Code:
int count
if(encoder.getVoltage() >"voltage when ticked") {
count = count + 1; // or count ++;
P.S i would think it is digital but if its not try that /\
Reply With Quote
  #13   Spotlight this post!  
Unread 02-28-2012, 10:09 PM
lineskier's Avatar
lineskier lineskier is online now
Registered User
AKA: mike
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2003
Location: Alton, New Shire
Posts: 666
lineskier has a reputation beyond reputelineskier has a reputation beyond reputelineskier has a reputation beyond reputelineskier has a reputation beyond reputelineskier has a reputation beyond reputelineskier has a reputation beyond reputelineskier has a reputation beyond reputelineskier has a reputation beyond reputelineskier has a reputation beyond reputelineskier has a reputation beyond reputelineskier has a reputation beyond repute
Re: RPM calculator

Get rate is not ideal.

We store a last time variable.

Take counter.getdistance / (current time - last time)

Then reset the counter.

You will get a much stabler speed this way
__________________
"Never let your schooling interfere with your education" -Mark Twain
Reply With Quote
  #14   Spotlight this post!  
Unread 03-01-2012, 04:30 PM
ProgrammerMatt ProgrammerMatt is offline
Programmer-Electrical-Mechanical
FRC #0228 (Gus)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Southington
Posts: 126
ProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really nice
Re: RPM calculator

Quote:
Originally Posted by lineskier View Post
Get rate is not ideal.

We store a last time variable.

Take counter.getdistance / (current time - last time)

Then reset the counter.

You will get a much stabler speed this way

this is straight out of the encoder class
Code:
     * Get the current rate of the encoder.
     * Units are distance per second as scaled by the value from setDistancePerPulse().
its practically the same as current time - last time
Reply With Quote
  #15   Spotlight this post!  
Unread 03-01-2012, 06:34 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 6,025
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: RPM calculator

Quote:
Originally Posted by ProgrammerMatt View Post
...its practically the same as current time - last time
GetRate() computes the rate based on the elapsed time of a single encoder pulse (the most recent one).

This is manifestly not the same as the computing the rate using delta counts since the last sample and dividing by the elapsed time since the last sample, for sample periods on the order of 20ms and encoder pulse periods associated with shooter wheel speeds.


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 08:06 AM.

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


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