Go to Post I just like that PVC is the most basic need of humankind according to that diagram. Whatever would we do without it?! - Po-ser [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
  #1   Spotlight this post!  
Unread 01-02-2015, 11:40
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: How to implement an encoder with one speed clock, and one direction signal.

What encoder are you using? How do you have it wired to the roboRIO?
Reply With Quote
  #2   Spotlight this post!  
Unread 01-02-2015, 11:45
orbobigge orbobigge is offline
Head Programmer/President
AKA: Matthew
FRC #3284 (laser)
Team Role: Programmer
 
Join Date: Feb 2015
Rookie Year: 2011
Location: Camdenton
Posts: 7
orbobigge is an unknown quantity at this point
Re: How to implement an encoder with one speed clock, and one direction signal.

Quote:
Originally Posted by Alan Anderson View Post
What encoder are you using? How do you have it wired to the roboRIO?
It's a trackball encoder, with the clock signal wired to the first input, and the direction signal wired to the second input.
Reply With Quote
  #3   Spotlight this post!  
Unread 01-02-2015, 13:21
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,561
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: How to implement an encoder with one speed clock, and one direction signal.

Quote:
Originally Posted by orbobigge View Post
It's a trackball encoder, with the clock signal wired to the first input, and the direction signal wired to the second input.
I'm not familiar with trackball encoders, and couldn't find any description of one that uses a clock and direction outputs. Can you point to a datasheet?
Reply With Quote
  #4   Spotlight this post!  
Unread 01-02-2015, 13:32
orbobigge orbobigge is offline
Head Programmer/President
AKA: Matthew
FRC #3284 (laser)
Team Role: Programmer
 
Join Date: Feb 2015
Rookie Year: 2011
Location: Camdenton
Posts: 7
orbobigge is an unknown quantity at this point
Re: How to implement an encoder with one speed clock, and one direction signal.

Quote:
Originally Posted by Joe Ross View Post
I'm not familiar with trackball encoders, and couldn't find any description of one that uses a clock and direction outputs. Can you point to a datasheet?
No, we found this within an old keyboard, made by Cherry Switch. The trackball uses 2 encoders, one for the X, and one for the Y. With an oscilloscope we found two outputs on each encoder. The first output is a clock pulse based on the encoder wheel rotation. The second output is high for clockwise, and low for counterclockwise rotation.

We are trying to use the Counter::SetExternalDirection method. According to the source codes comments:

/**
* Set external direction mode on this counter.
* Counts are sourced on the Up counter input.
* The Down counter input represents the direction to count.
*/

When setting the counter for k1X, the Get() method returns a 0 or a 1. The GetDirection() method return true or false, according to the direction of rotation. We cannot get the Get() method to count more than 0 or 1. Any help appreciated.
Reply With Quote
  #5   Spotlight this post!  
Unread 01-02-2015, 16:06
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: How to implement an encoder with one speed clock, and one direction signal.

Quote:
Originally Posted by orbobigge View Post
No, we found this within an old keyboard, made by Cherry Switch. The trackball uses 2 encoders, one for the X, and one for the Y. With an oscilloscope we found two outputs on each encoder. The first output is a clock pulse based on the encoder wheel rotation. The second output is high for clockwise, and low for counterclockwise rotation.

We are trying to use the Counter::SetExternalDirection method. According to the source codes comments:

/**
* Set external direction mode on this counter.
* Counts are sourced on the Up counter input.
* The Down counter input represents the direction to count.
*/

When setting the counter for k1X, the Get() method returns a 0 or a 1. The GetDirection() method return true or false, according to the direction of rotation. We cannot get the Get() method to count more than 0 or 1. Any help appreciated.
Now understanding your issue more, I wonder if you could make a class inheriting from DigitalSource and "fake" the 2nd digital input of a quadrature encoder. Since you know the actual situation you're in and you know the format a quadrature encounter is expecting the 1s and 0s to flow, you can fake it:
-If input A is 1 and input B is forward, then return 0
-If input A is 0 and input B is forward, then return 1
-If input A is 1 and input B is backwards, then return 0
-If input A is 0 and input B is backwards, then return 1

Something like
Code:
class FakeQuadrature : public DigitalSource
{
public:
  // construct/pass in things, override other DigitalSource virtual functions...

  bool Get()
  {
    bool count = trackBallCount.Get();
    bool dir = trackBallDirection.Get();
    if(count && dir) return 0;
    else if(count && !dir) return 1;
    else if(!count && dir) return 1;
    else if(!count && !dir) return 0;
    return 0;
  }
private:
  DigitalInput trackBallCount;
  DigitalInput trackBallDirection;
};
Then once you've got that built, send it in as the 2nd DigitalInput to the Encoder class's constructor.
Reply With Quote
  #6   Spotlight this post!  
Unread 01-02-2015, 20:25
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: How to implement an encoder with one speed clock, and one direction signal.

I've never tried external direction mode on a counter, but the documentation I have read suggests that you should be able to make it work using an Encoder in 1x or 2x mode.
Reply With Quote
  #7   Spotlight this post!  
Unread 02-02-2015, 00:24
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: How to implement an encoder with one speed clock, and one direction signal.

You shouldn't need to fake anything like others are saying. The counter directly supports external direction. Simply select that mode.
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 12:01.

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