Go to Post 256:1 gear reductions provide surprisingly little torque once the gears have failed. - Kevin Sevcik [more]
Home
Go Back   Chief Delphi > Technical > Electrical
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
  #1   Spotlight this post!  
Unread 03-01-2013, 05:33 PM
arun4444 arun4444 is offline
Registered User
FRC #3760
 
Join Date: Jan 2013
Location: Bronx
Posts: 26
arun4444 has a little shameless behaviour in the past
Encoder Problem.

So i am trying to get these encoders working,

http://www.grayhill.com/web1/images/...ncoder_63r.pdf

Connected pin 1(encoder) to DigitalI/O in digital sidecar Pin Signal 1
Connected pin 2(encoder) to DigitalI/O in digital sidecar Pin Power 1
Connected pin 3(encoder) to DigitalI/O in digital sidecar Pin Signal 2
Connected Pin 5(encoder) to DigitalI/O in digital sidecar Pin ground 3

and here is the java code i am using to test

Code:
 public void disabled(){
        Encoder TestEnc = new Encoder(2,1);
        TestEnc.reset();
        for(;;){
            System.out.println(TestEnc.get());
            Timer.delay(1);
        }
    }
i just keep getting a 0, no matter how much i rotate the encoder, both directions.

I tested the encoder with an arduino and it seems to work fine.

I switched to another digital sidecar and the problem persists.

any ideas?

cheers
arun
  #2   Spotlight this post!  
Unread 03-01-2013, 05:43 PM
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: Encoder Problem.

You never call TestEnc.start();
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional
  #3   Spotlight this post!  
Unread 03-01-2013, 10:50 PM
arun4444 arun4444 is offline
Registered User
FRC #3760
 
Join Date: Jan 2013
Location: Bronx
Posts: 26
arun4444 has a little shameless behaviour in the past
Re: Encoder Problem.

Changed code to :

Code:
    public void disabled() {
        Encoder TestEnc = new Encoder(2, 1);
        TestEnc.reset();
        TestEnc.start();        
        for (;;) {
            System.out.println(TestEnc.get());
            Timer.delay(1);
        }
    }
still same result
  #4   Spotlight this post!  
Unread 03-02-2013, 12:45 AM
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: Encoder Problem.

Try taking out the Timer.delay()
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional
  #5   Spotlight this post!  
Unread 03-02-2013, 01:45 AM
William Kunkel William Kunkel is offline
Programming Lead
AKA: Kunkel
FRC #0422 (Mech Tech Dragons)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Richmond, VA
Posts: 94
William Kunkel is an unknown quantity at this point
Re: Encoder Problem.

Do you have access to an oscilloscope? They're really helpful with debugging encoder problems, and let you see if it's a code-side or electronics-side issue.
  #6   Spotlight this post!  
Unread 03-02-2013, 02:12 PM
arun4444 arun4444 is offline
Registered User
FRC #3760
 
Join Date: Jan 2013
Location: Bronx
Posts: 26
arun4444 has a little shameless behaviour in the past
Re: Encoder Problem.

I am pretty sure the encoder works cause it works fine on a arduino
  #7   Spotlight this post!  
Unread 03-02-2013, 02:57 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,997
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: Encoder Problem.

Quote:
Originally Posted by arun4444 View Post
I am pretty sure the encoder works cause it works fine on a arduino
At least check with a handheld voltmeter and make sure the encoder is getting power.

And as long as you're doing that, use the voltmeter to check that channels A and B are cycling.


  #8   Spotlight this post!  
Unread 03-02-2013, 06:38 PM
slijin's Avatar
slijin slijin is offline
Pockets
AKA: Samuel Lijin
FRC #0694 (StuyPulse)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York City
Posts: 537
slijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to behold
Re: Encoder Problem.

Try changing "TestEnc" to "testEnc". You're not supposed to capitalize variable names.

If that doesn't work:
  • Check the output of getRaw().
  • Make sure there's a codewheel on the shaft you're rotating, and make sure that the codewheel has lines for the encoder to read. Improper installation can result in the codewheel's markings getting scratched off, which will wreak havoc on your encoder's readout.
__________________

2010-12 CT Chairman's
2011 Galileo 5th seed
2010 NY Regional Winners
  #9   Spotlight this post!  
Unread 03-02-2013, 06:50 PM
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: Encoder Problem.

Quote:
Originally Posted by slijin View Post
Try changing "TestEnc" to "testEnc". You're not supposed to capitalize variable names.
I don't see any reason it wouldn't work if you capitalize variable names. In fact, I highly recommend using some sort of mixed case or underscores to separate words in variables for readability.

I personally am a fan of capitalizing the first letter of a variable name to indicate it is a variable, and naming all macros in all capitals with underscores separating words to differentiate them.

I've also seen incredibly structured variable naming methods that define everything about a variable in the name. For example, using three to six letter module name prefixes, and coding the type or units in (e.g. p for pressure, or kpa for kilopascals), or type of variable (e.g. m for map, c for calibration, etc.) and these work as well.

It's really all personal preference, as long as you are consistent the compiler really doesn't care at all.
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
  #10   Spotlight this post!  
Unread 03-02-2013, 07:16 PM
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,569
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: Encoder Problem.

Agreed that capitalization won't change anything. Rearranging deck chairs on the Titanic, that is. I think the C++ convention of variables starting with lower case letters is to distinguish them from classes and functions with start with uppercase letters. Though this may be Java, which has the opposite standard, I think.

I think your reset and start calls need to be in the other order. I'd also suggest putting an extra println in your loop just to make sure you're actually getting into the loop and all that. Possibly with an increment just for kicks.

I'd also recommend checking the outputs with a multimeter just to make sure that's not the problem. We have a different encoder board that's been fried and isn't good anymore. The only way you can tell is the output is constantly at 0.7V, never 0V or 5V as it should be. It's super easy to accidentally fry an output with static, so don't assume that it's still working fine just because it used to. Trust, but verify.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #11   Spotlight this post!  
Unread 03-02-2013, 09:49 PM
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: Encoder Problem.

Quote:
Originally Posted by Kevin Sevcik View Post
Agreed that capitalization won't change anything. Rearranging deck chairs on the Titanic, that is. I think the C++ convention of variables starting with lower case letters is to distinguish them from classes and functions with start with uppercase letters. Though this may be Java, which has the opposite standard, I think.
Other way around, Java uses camelCase(), C++ uses CaptialCase()
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional
  #12   Spotlight this post!  
Unread 03-02-2013, 10:29 PM
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: Encoder Problem.

Quote:
Originally Posted by arun4444 View Post
Connected pin 1(encoder) to DigitalI/O in digital sidecar Pin Signal 1
Connected pin 2(encoder) to DigitalI/O in digital sidecar Pin Power 1
Connected pin 3(encoder) to DigitalI/O in digital sidecar Pin Signal 2
Connected Pin 5(encoder) to DigitalI/O in digital sidecar Pin ground 3
Why are you using the ground pin on a third DIO port, instead of one of the ports you're already connecting to?

If you measure across encoder pins 2 and 5, is it actually receiving 5 volt power?

Is there a reason you initialize the encoder object with DIO 2 and 1 in that order, instead of 1 and 2?
  #13   Spotlight this post!  
Unread 03-03-2013, 11:36 AM
slijin's Avatar
slijin slijin is offline
Pockets
AKA: Samuel Lijin
FRC #0694 (StuyPulse)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York City
Posts: 537
slijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to behold
Re: Encoder Problem.

Quote:
Originally Posted by apalrd View Post
I don't see any reason it wouldn't work if you capitalize variable names. In fact, I highly recommend using some sort of mixed case or underscores to separate words in variables for readability.

I personally am a fan of capitalizing the first letter of a variable name to indicate it is a variable, and naming all macros in all capitals with underscores separating words to differentiate them.
Quote:
Originally Posted by Kevin Sevcik View Post
Agreed that capitalization won't change anything. Rearranging deck chairs on the Titanic, that is. I think the C++ convention of variables starting with lower case letters is to distinguish them from classes and functions with start with uppercase letters. Though this may be Java, which has the opposite standard, I think.
I've ran into weird errors with Java when the leading character isn't a lowercase letter, hence my suggestion.

Quote:
Originally Posted by Kevin Sevcik View Post
I think your reset and start calls need to be in the other order. I'd also suggest putting an extra println in your loop just to make sure you're actually getting into the loop and all that. Possibly with an increment just for kicks.
I don't believe there's any problem with the order of the reset() and start() calls, as start() initializes the accumulator, and reset() just resets the count to 0 - one does not affect the other.

Quote:
Originally Posted by Kevin Sevcik View Post
I'd also recommend checking the outputs with a multimeter just to make sure that's not the problem... It's super easy to accidentally fry an output with static, so don't assume that it's still working fine just because it used to. Trust, but verify.
He did say that the encoder worked fine on an Arduino.
__________________

2010-12 CT Chairman's
2011 Galileo 5th seed
2010 NY Regional Winners
  #14   Spotlight this post!  
Unread 03-03-2013, 12:01 PM
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,569
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: Encoder Problem.

Quote:
Originally Posted by slijin View Post
I've ran into weird errors with Java when the leading character isn't a lowercase letter, hence my suggestion.
I'm skeptical. Mostly because I've seen programmers use all sorts of capitalization schemes and have them work. If they're consistent. If you're prone to typos and accidentally using different capitalization then that's obviously going to cause issues. Similarly if you accidentally name a variable identically to a function or class or something.
Quote:
Originally Posted by slijin View Post
I don't believe there's any problem with the order of the reset() and start() calls, as start() initializes the accumulator, and reset() just resets the count to 0 - one does not affect the other.
Technically it strobes a reset bit on the counter in the FPGA. I'll agree it probably doesn't matter since it does this during the setup of the Counter object before you can start the Counter. So the reset() call probably sn't even necessary.
Quote:
Originally Posted by slijin View Post
He did say that the encoder worked fine on an Arduino.
Which was before it was likely rewired or atleast moved to being hooked to the Sidecar. Which is not a 100% guaranteed benign operation. It should take no more than 10 minutes to test this and if it DOES turn out to be wired wrong or blown, it will save you days or weeks of debugging a program that's trying to read a bad encoder. I like to knock off low hanging fruit in my troubleshooting so I don't feel like an idiot later when I've spent hours on something I could've spent 10 minutes checking at the beginning. If you're really that desperately attached to not "wasting" 5-10 minutes, then do the check while you're downloading code or rebooting the robot and otherwise twiddling your thumbs. Or recruit a helper to check for you while you're plugging away at your code. Just check it to give us all some peace of mind.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #15   Spotlight this post!  
Unread 03-03-2013, 03:53 PM
arun4444 arun4444 is offline
Registered User
FRC #3760
 
Join Date: Jan 2013
Location: Bronx
Posts: 26
arun4444 has a little shameless behaviour in the past
Re: Encoder Problem.

Ok, finally debugged the problem - the cable which connects the digital side-car to the crio was not crimped properly? with pins etc switched around? changed that cable and everything works ok!!
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:54 AM.

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