Go to Post The game transcends the competition, and this is beautiful. - Taylor [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
  #31   Spotlight this post!  
Unread 29-01-2013, 11:01
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Best way to measure period between pulses? Counters and FPGA

Quote:
Originally Posted by jhersh View Post
There is a finite resolution on the timing of the pulses. That period is 6.525 us per edge. In your system, does that correspond to 375 RPM? You may want to turn on averaging to improve the resolution (but increase the latency).



Sounds like a coincidence, maybe? Where are you getting 20ms as the refresh period? Just because that's the Driver Station's packet rate?



No. The FPGA only implements method 2.
Thanks a TON Joe!

This post clarified pretty much everything we're seeing.

We WERE hitting the 6.525us timing resolution per edge. That corresponded (coincidentally) with the resolution of 375 RPM we were seeing, at our desired speed.

There'll be a more detailed post, or even a whitepaper once we've sorted everything out, but we've got a really neat solution together involving SetSemiPeriod(true), a mostly white disc with a single small black sector, and an averaging window that holds about 10ms worth of reads at our slowest speed.
__________________
In life, what you give, you keep. What you fail to give, you lose forever...
  #32   Spotlight this post!  
Unread 29-01-2013, 12:23
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,089
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: Best way to measure period between pulses? Counters and FPGA

Quote:
Originally Posted by Mr. Lim View Post
we've got a really neat solution together involving SetSemiPeriod(true), a mostly white disc with a single small black sector, and an averaging window that holds about 10ms worth of reads at our slowest speed.
May I ask? What is the slowest speed you want to control, and what speed are you running your speed control algorithm?



  #33   Spotlight this post!  
Unread 29-01-2013, 13:00
AdamHeard's Avatar
AdamHeard AdamHeard is offline
Lead Mentor
FRC #0973 (Greybots)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Atascadero
Posts: 5,507
AdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond repute
Send a message via AIM to AdamHeard
Re: Best way to measure period between pulses? Counters and FPGA

Quote:
Originally Posted by jhersh View Post
There is a buffer that will hold up to 127 samples for each counter / encoder. It has write pointer that does form a ring buffer. The sum of the samples between the write pointer - average_size (usually) and write pointer are summed every 0.1 us * average_size (yeah I know... overkill) and made available to the driver (i.e. not on demand) along with the number of samples available. When a counter is reset, the write pointer is moved to mark all samples unwritten (so the "count" returned would be 0).

The I/O is 6.525 us from sample to sample. The timer used has a 1 us resolution. So the actual resolution is 6..7 us. However, the error is not cumulative across the average. Regardless of the number of samples averaged, the error is less than 7.525 us.



The FPGA interface function is called writeTimerConfig_AverageSize(). Looks like we never exposed that to the WPILib API layer in C++ (and therefore Java). It's exposed in LabVIEW.

Cheers,
-Joe
So, we are unable to use this with C++?
  #34   Spotlight this post!  
Unread 29-01-2013, 13:06
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,089
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: Best way to measure period between pulses? Counters and FPGA

Quote:
Originally Posted by AdamHeard View Post
So, we are unable to use this with C++?
See post #29 in this thread:

http://www.chiefdelphi.com/forums/sh...3&postcount=29


  #35   Spotlight this post!  
Unread 01-02-2013, 01:39
TravSatEE's Avatar
TravSatEE TravSatEE is offline
Spacecraft Engineer and more
FRC #2035 (Robo Rockin' Bots)
Team Role: Engineer
 
Join Date: Jan 2012
Rookie Year: 2002
Location: Monterey, CA
Posts: 26
TravSatEE is infamous around these partsTravSatEE is infamous around these parts
Re: Best way to measure period between pulses? Counters and FPGA

Quote:
Originally Posted by jhersh View Post
That is what I was saying. It is not in the WPILib API layer in C++ and Java. That means if you care to use the hardware feature, you need to move down a layer.

Cheers,
-Joe
Are you aware of any other features that are not implemented in C++ or Java but are in LabView (even outside of counters)?

I'd also appreciate any clarification on what you mean by moving down a layer. Other than switching to LabView, is there some other action that can be taken? I thought the FPGA code was handled by the cRIO imaging tool and no modifications to the FPGA programming are allowed. Is this your understanding as well? I am not sure if your comment implies more is available.
  #36   Spotlight this post!  
Unread 01-02-2013, 01:55
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: Best way to measure period between pulses? Counters and FPGA

Quote:
Originally Posted by TravSatEE View Post
Are you aware of any other features that are not implemented in C++ or Java but are in LabView (even outside of counters)?
I think Java is missing SPI maybe?

In general we try to make everything the same.

Quote:
Originally Posted by TravSatEE View Post
I'd also appreciate any clarification on what you mean by moving down a layer. Other than switching to LabView, is there some other action that can be taken? I thought the FPGA code was handled by the cRIO imaging tool and no modifications to the FPGA programming are allowed. Is this your understanding as well? I am not sure if your comment implies more is available.
The FPGA code is there. It does not need to be edited.

The layer that most people write their code is only in the "User Code" layer. The layer below that is the "WPILib" layer. That is the layer that I mean that you need to edit if you want this functionality in that language. You may even be able to call into the FPGA interface layer directly from your user code if you call it at a time that it won't be overwritten by WPILib.
  #37   Spotlight this post!  
Unread 01-02-2013, 12:01
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,572
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: Best way to measure period between pulses? Counters and FPGA

Quote:
Originally Posted by TravSatEE View Post
Are you aware of any other features that are not implemented in C++ or Java but are in LabView (even outside of counters)?
I've been filing bugs in the WPILIB Java tracker when I find something that is implemented in LabVIEW but not in Java. See http://firstforge.wpi.edu/sf/tracker...ilib_java_bugs

The things I've found are SPI, DMA, and CAN periodic status. Someone else filed a bug about digital input interrupts only being partially implemented. For SPI, I attached an implementation that works for me in the tracker.
  #38   Spotlight this post!  
Unread 01-02-2013, 12:31
TravSatEE's Avatar
TravSatEE TravSatEE is offline
Spacecraft Engineer and more
FRC #2035 (Robo Rockin' Bots)
Team Role: Engineer
 
Join Date: Jan 2012
Rookie Year: 2002
Location: Monterey, CA
Posts: 26
TravSatEE is infamous around these partsTravSatEE is infamous around these parts
Re: Best way to measure period between pulses? Counters and FPGA

Quote:
Originally Posted by jhersh View Post
I think Java is missing SPI maybe?

In general we try to make everything the same.



The FPGA code is there. It does not need to be edited.

The layer that most people write their code is only in the "User Code" layer. The layer below that is the "WPILib" layer. That is the layer that I mean that you need to edit if you want this functionality in that language. You may even be able to call into the FPGA interface layer directly from your user code if you call it at a time that it won't be overwritten by WPILib.
Thanks for your clarification, jhersh. I understand what you mean now. The students do edit WPILIB also. However, this year the netbeans plugin makes this more difficult. The wpilib netbeans project directory and source code were placed in .zip files. I have not understood why this was done. I think we need to make the code more quickly accessible, and this repackaging does the opposite.

Quote:
Originally Posted by Joe Ross View Post
I've been filing bugs in the WPILIB Java tracker when I find something that is implemented in LabVIEW but not in Java. See http://firstforge.wpi.edu/sf/tracker...ilib_java_bugs

The things I've found are SPI, DMA, and CAN periodic status. Someone else filed a bug about digital input interrupts only being partially implemented. For SPI, I attached an implementation that works for me in the tracker.
Joe, thanks for this input. I had actually stopped looking at this website since it seemed like the development work slowed down there and WPI had since created other websites. I do know that java wpilib has changed some since last year, but the underlying squawk java virtual machine is still timestamped December 2011 when the cRIO boots. There are other features missing as well, such as UDP networking support. This is actually highly misleading in the wpilib javadoc, as the documentation implies that the functionality exists. However, the code executes with a runtime exception. Frustrates the students to be this misleading. Some of the javadoc in general leaves a lot to be desired also.

I'll happily work with the key java developers on the above.
  #39   Spotlight this post!  
Unread 01-02-2013, 12:41
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,572
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: Best way to measure period between pulses? Counters and FPGA

Quote:
Originally Posted by TravSatEE View Post
I had actually stopped looking at this website since it seemed like the development work slowed down there and WPI had since created other websites.
The Support Page on screenstepslive says to file bugs in the firstforge tracker. There have been 7 java bugs closed since kickoff (4 documentation and 3 fairly simple bugs).

I figure that if there isn't a bug filed, you can't complain about it not being fixed.

Last edited by Joe Ross : 01-02-2013 at 13:01.
  #40   Spotlight this post!  
Unread 01-02-2013, 13:38
nightpool's Avatar
nightpool nightpool is offline
robotRectifier
AKA: Evan
no team (formerly of CORE 2062)
Team Role: Alumni
 
Join Date: Oct 2011
Rookie Year: 2011
Location: Waukesha, WI
Posts: 81
nightpool is on a distinguished road
Re: Best way to measure period between pulses? Counters and FPGA

Hey, kinda a thread hijack, but this seemed like the best place to ask. We're using a photo-eye based encoder on our team (due to issues mounting traditional shaft encoders) and are having issues with GetPeriod() when we drop below 20 rps where it returns infinity about half of the time, and the correct speed the rest of the time. GetPeriod() apparently returns infinity only if the counter is "stalled". Does anyone know what this means, or if there's a way around it? Overriding GetPeriod doesn't work, as m_counter is private, not protected. I'm guessing that the FPGA has some kind of threshold where if it doesn't see an edge it assumes the wheel has stopped. Is there any way of modifying that, maybe giving it a large tolerance?
__________________
Proud alum of CORE 2062.
www.core2062.com
  #41   Spotlight this post!  
Unread 01-02-2013, 13:43
Thad House Thad House is offline
Volunteer, WPILib Contributor
no team (Waiting for 2021)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Thousand Oaks, California
Posts: 1,099
Thad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond repute
Re: Best way to measure period between pulses? Counters and FPGA

The is a function you can use to set what the FPGA sees as stopped. its the setMinRate function.
__________________
All statements made are my own and not the feelings of any of my affiliated teams.
Teams 1510 and 2898 - Student 2010-2012
Team 4488 - Mentor 2013-2016
Co-developer of RobotDotNet, a .NET port of the WPILib.
  #42   Spotlight this post!  
Unread 01-02-2013, 14:41
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,572
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: Best way to measure period between pulses? Counters and FPGA

Quote:
Originally Posted by sst.thad View Post
The is a function you can use to set what the FPGA sees as stopped. its the setMinRate function.
In the Encoder class it's called setMinRate, in the Counter class it's called setMaxPeriod.
  #43   Spotlight this post!  
Unread 01-02-2013, 14:56
MisterG's Avatar
MisterG MisterG is offline
Think twice post once.
AKA: Alan Gilgenbach
FRC #2062 (C.O.R.E. - Community of Robotics Engineers)
Team Role: Team Spirit / Cheering
 
Join Date: Mar 2011
Rookie Year: 2011
Location: Waukesha, WI
Posts: 120
MisterG is a name known to allMisterG is a name known to allMisterG is a name known to allMisterG is a name known to allMisterG is a name known to allMisterG is a name known to all
Re: Best way to measure period between pulses? Counters and FPGA

Quote:
Originally Posted by sst.thad
The is a function you can use to set what the FPGA sees as stopped. its the setMinRate function.
Quote:
Originally Posted by Joe Ross View Post
In the Encoder class it's called setMinRate, in the Counter class it's called setMaxPeriod.
Sounds like the answer to our problems.

I imagine that we don't want to use the stalled feature at all. Is there a downside to setting the max period to a high value? e.g. 6 seconds period is equivalent to 10 RPM. This would seem safe at any reasonably low speeds. Is there any functionality trade off to setting a high max period?
__________________
Alan Gilgenbach
C.O.R.E 2062
  #44   Spotlight this post!  
Unread 01-02-2013, 15:10
nightpool's Avatar
nightpool nightpool is offline
robotRectifier
AKA: Evan
no team (formerly of CORE 2062)
Team Role: Alumni
 
Join Date: Oct 2011
Rookie Year: 2011
Location: Waukesha, WI
Posts: 81
nightpool is on a distinguished road
Re: Best way to measure period between pulses? Counters and FPGA

Doesn't that mean it wouldn't be able to tell if the wheel is actually stopped?
__________________
Proud alum of CORE 2062.
www.core2062.com
  #45   Spotlight this post!  
Unread 01-02-2013, 15:16
Thad House Thad House is offline
Volunteer, WPILib Contributor
no team (Waiting for 2021)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Thousand Oaks, California
Posts: 1,099
Thad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond repute
Re: Best way to measure period between pulses? Counters and FPGA

If you look at the code the only reason it has that function is to not have a divide by 0 error. In the get period function, it uses that bool in order to not make it divide by 0.
__________________
All statements made are my own and not the feelings of any of my affiliated teams.
Teams 1510 and 2898 - Student 2010-2012
Team 4488 - Mentor 2013-2016
Co-developer of RobotDotNet, a .NET port of the WPILib.
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 13:10.

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