Go to Post When FIRST teams are as numerous and as well supported as basketball teams, we will know that our culture is preparing young people to compete in the 21 st century and we are spending our 2 million minutes wisely. - N7UJJ [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 Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 09-02-2013, 14:16
bhughes bhughes is offline
Registered User
no team
 
Join Date: Jan 2013
Rookie Year: 1999
Location: Michigan
Posts: 24
bhughes is on a distinguished road
60 / getPeriod() returns 3,000,000

We have encountered a problem where doing this:
Code:
double getRate() {
    return 60 / counter.getPeriod();
}
Randomly returns 3,000,000 sometimes. We're using it to determine how accurate our bang-bang is by averaging the difference between the setpoint RPM and the real RPM, and it works well until at seemingly random times it will return strange high numbers. Other than the high numbers, it returns accurate ones. We are using a once-per-rev hall effect sensor and we've gotten (by graphing the data) within 20+- rpm of what we'd like. The random large numbers mess up our data, and we're wondering what would cause this to happen.

This is getPeriod():
Code:
public double getPeriod() {
    double period;
    if (m_counter.readTimerOutput_Stalled()) {
        return Double.POSITIVE_INFINITY;
    } else {
        period = (double) m_counter.readTimerOutput_Period() / (double) m_counter.readTimerOutput_Count();
    }
    return period / 1.0e6;
}
How would m_counter.readTimerOutput_Stalled() return true? That's when it is considered "stopped", correct?
  #2   Spotlight this post!  
Unread 09-02-2013, 14:28
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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: 60 / getPeriod() returns 3,000,000

Quote:
Originally Posted by bhughes View Post
We have encountered a problem where doing this:
Code:
double getRate() {
    return 60 / counter.getPeriod();
}
Randomly returns 3,000,000 sometimes.
What is your setpoint rpm?

How fast is your wheel spinning when this glitch happens?


  #3   Spotlight this post!  
Unread 09-02-2013, 14:30
bhughes bhughes is offline
Registered User
no team
 
Join Date: Jan 2013
Rookie Year: 1999
Location: Michigan
Posts: 24
bhughes is on a distinguished road
Re: 60 / getPeriod() returns 3,000,000

Quote:
Originally Posted by Ether View Post
What is your setpoint rpm?

How fast is your wheel spinning when this glitch happens?
4500rpm for both questions. It gets to the setpoint far before the glitch happens.
  #4   Spotlight this post!  
Unread 09-02-2013, 14:36
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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: 60 / getPeriod() returns 3,000,000

Quote:
Originally Posted by bhughes View Post
4500rpm for both questions. It gets to the setpoint far before the glitch happens.
How fast are you running the control algorithm. i.e., at what rate are you calling counter.getPeriod()?


  #5   Spotlight this post!  
Unread 09-02-2013, 14:38
bhughes bhughes is offline
Registered User
no team
 
Join Date: Jan 2013
Rookie Year: 1999
Location: Michigan
Posts: 24
bhughes is on a distinguished road
Re: 60 / getPeriod() returns 3,000,000

Quote:
Originally Posted by Ether View Post
How fast are you running the control algorithm. i.e., at what rate are you calling counter.getPeriod()?
We've tested at the 20ms periodic methods (removed all other code), and still seen the problem.
  #6   Spotlight this post!  
Unread 09-02-2013, 14:49
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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: 60 / getPeriod() returns 3,000,000

Quote:
Originally Posted by bhughes View Post
We've tested at the 20ms periodic methods (removed all other code), and still seen the problem.
What's the part number of your Hall sensor?

Can you post a picture of how you have the magnet mounted to the wheel.

Working hypothesis: vibration is randomly causing the sensor to read the rising edge twice.


  #7   Spotlight this post!  
Unread 09-02-2013, 15:10
bhughes bhughes is offline
Registered User
no team
 
Join Date: Jan 2013
Rookie Year: 1999
Location: Michigan
Posts: 24
bhughes is on a distinguished road
Re: 60 / getPeriod() returns 3,000,000

Quote:
Originally Posted by Ether View Post
What's the part number of your Hall sensor?

Can you post a picture of how you have the magnet mounted to the wheel.

Working hypothesis: vibration is randomly causing the sensor to read the rising edge twice.
We purchased the one pictured here from their team. (it is a newer "version", but as far as I can tell the same hardware components.) I seem to remember it having this sensor, but I could be wrong. This is what it looks like when mounted.
  #8   Spotlight this post!  
Unread 09-02-2013, 15:28
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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: 60 / getPeriod() returns 3,000,000

Quote:
Originally Posted by bhughes View Post
We purchased the one pictured here from their team. (it is a newer "version", but as far as I can tell the same hardware components.) I seem to remember it having this sensor, but I could be wrong. This is what it looks like when mounted.
I can't tell for sure from the angle the picture is taken at, but it doesn't look like the Hall sensor is mounted in the correct orientation relative to the magnet. Could you post a couple of pics taken from x,y,&z directions?

Also, it looks like the Hall end of the PCB is unsupported and the Hall chip is dangling at the end of its long leads. It could be vibrating. Try stuffing some tissue paper under the leads to dampen it and see if it makes a difference. Easy enough to try.


  #9   Spotlight this post!  
Unread 09-02-2013, 15:37
bhughes bhughes is offline
Registered User
no team
 
Join Date: Jan 2013
Rookie Year: 1999
Location: Michigan
Posts: 24
bhughes is on a distinguished road
Re: 60 / getPeriod() returns 3,000,000

Here's an album.

We'll try and dampen the vibration. Right now that seems to be the most likely cause.
  #10   Spotlight this post!  
Unread 09-02-2013, 16:17
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,745
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: 60 / getPeriod() returns 3,000,000

You definitely don't have the Hall sensor oriented correctly. The "flat" part of the sensor should be perpendicular to the magnet. If you don't bend anything, then the correct orientation is with your mounting board parallel to the face your magnets are mounted on. Preferably with all those components on the side facing the wheel.

Or, you can bend the Hall sensor backwards, towards the back of the mounting board, away from the side all the components are mounted from.

(30 seconds later) EDIT: Also, why not put something in your GetRate function that tosses out obviously incorrect values like a period less than 0.0001 seconds or something?
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #11   Spotlight this post!  
Unread 09-02-2013, 16:25
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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: 60 / getPeriod() returns 3,000,000

Quote:
Originally Posted by Kevin Sevcik View Post
(30 seconds later) EDIT: Also, why not put something in your GetRate function that tosses out obviously incorrect values like a period less than 0.0001 seconds or something?
It's better to understand what's causing the problem, fix it if you can, and make it work right than to cover up the problem.

But if you do filter out the glitches in software, then increment an error counter each time it happens. Monitor that error counter during non-competition use to make sure it isn't getting worse and worse over time.


  #12   Spotlight this post!  
Unread 09-02-2013, 17:19
bhughes bhughes is offline
Registered User
no team
 
Join Date: Jan 2013
Rookie Year: 1999
Location: Michigan
Posts: 24
bhughes is on a distinguished road
Re: 60 / getPeriod() returns 3,000,000

Thanks guys. We mounted it horizontally and added tissue to relieve vibration. The bug hasn't come up since. We're actually within 2-5rpm from our setpoint, which is awesome.
  #13   Spotlight this post!  
Unread 09-02-2013, 17:35
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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: 60 / getPeriod() returns 3,000,000

Quote:
Originally Posted by bhughes View Post
We mounted it horizontally and added tissue to relieve vibration.
Can you post some pics please


  #14   Spotlight this post!  
Unread 09-02-2013, 18:42
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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: 60 / getPeriod() returns 3,000,000

Quote:
Originally Posted by bhughes View Post
We're actually within 2-5rpm from our setpoint, which is awesome.
agrees well with a simple ballpark calculation:
Attached Thumbnails
Click image for larger version

Name:	4500_1_1_calc.png
Views:	49
Size:	4.5 KB
ID:	13900  

Last edited by Ether : 09-02-2013 at 18:59.
  #15   Spotlight this post!  
Unread 09-02-2013, 22:34
kenavt's Avatar
kenavt kenavt is offline
Registered User
AKA: Colin S
no team
Team Role: Alumni
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Ann Arbor
Posts: 253
kenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond reputekenavt has a reputation beyond repute
Re: 60 / getPeriod() returns 3,000,000

Quote:
Originally Posted by Kevin Sevcik View Post
(30 seconds later) EDIT: Also, why not put something in your GetRate function that tosses out obviously incorrect values like a period less than 0.0001 seconds or something?
We had the same problem as the OP last year, with a similar data resolution, and this year (our values were more like 90,000 RPM). This is what we've done, for lack of a better solution.

EDIT: We're using LabVIEW, and the Counter class's Period output (from the Get.vi).
__________________
University of Michigan Computer Engineering '17

FRC 2337 student alumni (2010-2013)
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 02:28.

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