Go to Post Mostly, however, I find that once the students start building a robotics project, they are too busy learning for me to teach. - dtengineering [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-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 28-01-2013, 00:23
Hypnotoad's Avatar
Hypnotoad Hypnotoad is offline
Junior Assistant Secretary of Moon
no team
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2011
Location: California
Posts: 114
Hypnotoad is infamous around these partsHypnotoad is infamous around these partsHypnotoad is infamous around these partsHypnotoad is infamous around these partsHypnotoad is infamous around these partsHypnotoad is infamous around these parts
Counter class issues

I am using the counter class as a makeshift encoder. During testing I had the code print out what value the getPeriod function was getting. The print statement however, was only outputting the correct number when the sensor gave a pulse. While there was no pulse it gave me zeroes. Does anyone have any clue as to why this may be happening?
__________________
The following sentence is true.
The preceding sentence is false.
This sentence is false.
This signature is false.
My teeth are false.
Reply With Quote
  #2   Spotlight this post!  
Unread 28-01-2013, 06:19
MagiChau's Avatar
MagiChau MagiChau is offline
Registered User
AKA: Michael Chau
FRC #0085 (B.O.B. (Built on Brains))
Team Role: Alumni
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Zeeland, Michigan
Posts: 875
MagiChau is just really niceMagiChau is just really niceMagiChau is just really niceMagiChau is just really nice
Re: Counter class issues

getPeriod() would be working as intended. If the encoder is not getting a pulse it means the velocity is zero and thus getPeriod is zero.

Here's the actual source code for the method.

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;
    }
The counter class will run the getStopped() method if the pulse did not change within x period and set the time to stalled.

Code:
public boolean getStopped() {
        return m_counter.readTimerOutput_Stalled();
    }

Last edited by MagiChau : 28-01-2013 at 06:23.
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 10:08.

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