Go to Post There's no feeling quite like that one you get when you're behind the diamond plate controlling a metal beast that you've put your blood (literally), sweat (more literally), and tears (probably literally) into, and it working. Undescribable. - scali [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 02-04-2013, 00:39
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
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 RPM Issues

Quote:
Originally Posted by meltbox360 View Post
Here are the pictures.
I see what you mean about the wiring.

Encoder mounting looks better than I imagined.


Reply With Quote
  #17   Spotlight this post!  
Unread 02-04-2013, 00:42
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
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 RPM Issues

Quote:
Originally Posted by meltbox360 View Post
I asked in a second edit earlier. Not sure at all. Sorry I checked the docs and then I realized I have no idea how to do this stuff correctly without some experimentation.
I don't have any C++ examples.

This link might help:

http://firstforge.wpi.edu/sf/go/artf...v=1&_pagenum=1


Reply With Quote
  #18   Spotlight this post!  
Unread 02-04-2013, 00:53
meltbox360 meltbox360 is offline
Registered User
FRC #4302
 
Join Date: Jan 2012
Location: Chicago, Il
Posts: 32
meltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of light
Re: Consistent Encoder RPM Issues

Quote:
Originally Posted by Ether View Post
I don't have any C++ examples.

This link might help:

http://firstforge.wpi.edu/sf/go/artf...v=1&_pagenum=1


I may not be understanding but do i have to recompile WPIlib to change that? Thanks.
Reply With Quote
  #19   Spotlight this post!  
Unread 02-04-2013, 01:02
meltbox360 meltbox360 is offline
Registered User
FRC #4302
 
Join Date: Jan 2012
Location: Chicago, Il
Posts: 32
meltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of light
Re: Consistent Encoder RPM Issues

Without recompiling, just setting everything up I am getting a spread of 1100 rpm at max speed. Between 5200 and 6300 rpm so the same issue as the encoder class with pretty much the same spread. I am unsure of how to handle the FPGA but I will keep digging around. Thanks to everyone who has helped out so far. You guys showed up quick!
Reply With Quote
  #20   Spotlight this post!  
Unread 02-04-2013, 01:04
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
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 RPM Issues

Quote:
Originally Posted by meltbox360 View Post
do i have to recompile WPIlib to change that?
You have to recompile the parts you change, I guess. I've not done this with C++. Do you have a guru you could ask?


Reply With Quote
  #21   Spotlight this post!  
Unread 02-04-2013, 01:08
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
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 RPM Issues

Quote:
Originally Posted by meltbox360 View Post
Without recompiling, just setting everything up I am getting a spread of 1100 rpm at max speed. Between 5200 and 6300 rpm so the same issue as the encoder class with pretty much the same spread.
I think setting the FPGA sample ring buffer will bring that down to an acceptable level without introducing undue phase lag. If you can get a good signal you may be able to use the very simple bang-bang control.


Reply With Quote
  #22   Spotlight this post!  
Unread 02-04-2013, 01:08
meltbox360 meltbox360 is offline
Registered User
FRC #4302
 
Join Date: Jan 2012
Location: Chicago, Il
Posts: 32
meltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of light
Re: Consistent Encoder RPM Issues

Quote:
Originally Posted by Ether View Post
You have to recompile the parts you change, I guess. I've not done this with C++. Do you have a guru you could ask?


I do not at this moment but yes if I am to change the C++ I will have to recompile. Lets see how difficult this is. I'll post back as soon as I figure something out. I'm sure there's at least a semblance of a guide on compiling it. The link you posted is immensely helpful. The changes will be simple.
Reply With Quote
  #23   Spotlight this post!  
Unread 02-04-2013, 01:11
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
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 RPM Issues

Quote:
Originally Posted by meltbox360 View Post
I'll post back as soon as I figure something out.
I may be gone shortly, it's past 1am here.


Reply With Quote
  #24   Spotlight this post!  
Unread 02-04-2013, 01:11
meltbox360 meltbox360 is offline
Registered User
FRC #4302
 
Join Date: Jan 2012
Location: Chicago, Il
Posts: 32
meltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of light
Re: Consistent Encoder RPM Issues

Quote:
Originally Posted by Ether View Post
I may be gone shortly, it's past 1am here.


Not a problem. Check back tomorrow if you could. Appreciate the help.
Reply With Quote
  #25   Spotlight this post!  
Unread 02-04-2013, 11:49
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
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 RPM Issues

Quote:
Originally Posted by meltbox360 View Post
Not a problem. Check back tomorrow if you could. Appreciate the help.
I'm here. How's it going?


Reply With Quote
  #26   Spotlight this post!  
Unread 02-04-2013, 12:28
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,188
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: Consistent Encoder RPM Issues

Quote:
Originally Posted by Ether View Post
I don't have any C++ examples.

This link might help:

http://firstforge.wpi.edu/sf/go/artf...v=1&_pagenum=1


Cool trick, I wasn't aware we could poke the FPGA in that manner. This should work for the OP, but a "slower" sensor shouldn't do anything but help.
Reply With Quote
  #27   Spotlight this post!  
Unread 02-04-2013, 12:44
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
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 RPM Issues

Quote:
Originally Posted by Tom Bottiglieri View Post
This should work for the OP, but a "slower" sensor shouldn't do anything but help.
Indeed. At frisbee shooter wheel speeds, many teams have had excellent results with one-count-per-rev sensors (optical and magnetic). One-count-per-rev sensors don't require changing the FPGA sample ring buffer default size.


Reply With Quote
  #28   Spotlight this post!  
Unread 02-04-2013, 15:28
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is online now
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,729
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: Consistent Encoder RPM Issues

If you're having issues recompiling WPILib, you can do this more simply by grabbing copies of Counter.cpp and Counter.h and renaming the files and class from "Counter" to something like "AvgCounter". Then add them to your workspace and make a code change similar to the java one in the FirstForge link. In fact, I'd recommend doing it this way since it's a lot simpler than recompiling WPILib. It's what I did when I wanted a modified version of the PIDController and the PIDSubsystem classes.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
Reply With Quote
  #29   Spotlight this post!  
Unread 02-04-2013, 16:42
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,537
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: Consistent Encoder RPM Issues

We saw the same problem in LabView last year (you'll find many threads about it). The getrate (or period) only calculates between the last 2 ticks. So if you have many many ticks between loops, it actually hurts you because the time used between the ticks is very small, and creates a large amount of error. The benefit of using the counter is that you can set it to average a certain number of results to minimize the error.

If you can't follow what others are saying, there is a quick and dirty way that we used in LabView.

Each time your code loops, take the total number of counts from each loop and divide it by the total amount of time between loops.

You'll get some inaccuracies, but it should give you all the accuracy you really need for a frisbee firing PID loop. They're not nearly as sensitive to speed as the basketballs were last year. We're using this method on our first shooter wheel (only because we already had it wired up and didn't want to swap sensors) and have had acceptable results.

We're using 341's method of the 2011 photosensor and reflective material that results in 1 count per RPM. The resolution that we see on that wheel is superior to the first method.

Last edited by Tom Line : 02-04-2013 at 16:45.
Reply With Quote
  #30   Spotlight this post!  
Unread 02-04-2013, 17:05
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
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 RPM Issues

Quote:
Originally Posted by Tom Line View Post
Each time your code loops, take the total number of counts from each loop and divide it by the total amount of time between loops.
Just a heads-up. The above method has some issues of its own to be aware of:

1) the answer is only as good as the method you use to get (or control) the elapsed time

2) any task swaps or lengthy interrupts which occur between reading the counts and getting the elapsed time will create signal spikes.

3) the faster you run your code, the more RPM jitter you get due to count quantization (for example, at 10ms and 6000 RPM with a 250 counter, the jitter would be ~24 RPM)

4) the slower you run your code, the more phase lag you get in the sensor signal (for example, at 20ms there'd be ~10ms lag)



Last edited by Ether : 02-04-2013 at 18:47. Reason: removed pronoun for clarity
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 13:40.

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