Go to Post It's not very graciously professional to point out the un-gracious professionalism in others. - Taylor [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 10-02-2007, 17:06
E_Unit E_Unit is offline
Registered User
FRC #1799
 
Join Date: Feb 2007
Location: Colorado
Posts: 1
E_Unit is an unknown quantity at this point
Encoder help

I am using an optical shaft encoder with 128 clicks/revolution. I have set up the kevin.org encoder code but am only receiving one direction for feedback (0 and -1). I am curious if anyone else is having this problem or if anyone knows how we might get it to give us feedback for two directions.
  #2   Spotlight this post!  
Unread 10-02-2007, 20:21
JBotAlan's Avatar
JBotAlan JBotAlan is offline
Forever chasing the 'bot around
AKA: Jacob Rau
FRC #5263
Team Role: Mentor
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Riverview, MI
Posts: 723
JBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond repute
Send a message via AIM to JBotAlan Send a message via Yahoo to JBotAlan
Re: Encoder help

I'm having trouble understanding your post. Do you mean that when you spin the shaft of the encoder one direction, you get -1, and the other direction you get 0? Does the counter count at all? I think there's a debug mode; look in the header file and enable it if you see the option.

You may have the encoder wired incorrectly. Which digital input is it plugged into? Which encoder do you have? Can you point me to a spec sheet?

JBot
__________________
Aren't signatures a bit outdated?
  #3   Spotlight this post!  
Unread 15-02-2007, 18:43
JHale JHale is offline
Registered User
no team
 
Join Date: Feb 2007
Rookie Year: 2008
Location: Nowhere
Posts: 14
JHale is an unknown quantity at this point
Re: Encoder help

(From the same team)

W have the Phase A signal hooked up to Digital IO 1, and Phase B hooked up to Digital IO 11 as per the Kevin.org code.

When we print off the value from Get_Encoder_1_Count(); all that is returned is either 256 or 260 without any change when the encoder is rotated.

When we print off the value of digital_io_01, all that we are able to see is a -1 or a 0 (Which is odd because the ios should be showing 1 or 0, not a negative).

Also, when we reset the encoder count after each call of the count, the encoder alternates between 1 and 0. When you are turning it forward, we get a 1, and backwards a 0. However, when we allow the code to handle counting, all we see are 256 or 260.

I am reading through the code and will be trying the Quadrature code tonight.

Thank you!
  #4   Spotlight this post!  
Unread 15-02-2007, 18:45
Bharat Nain's Avatar
Bharat Nain Bharat Nain is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Jan 2004
Rookie Year: 2003
Location: New York
Posts: 2,000
Bharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond repute
Send a message via AIM to Bharat Nain Send a message via MSN to Bharat Nain
Re: Encoder help

Don't forget to look at the FAQ: http://www.kevin.org/frc/encoder/
__________________
-= Bharat Nain =-

Whatever you do, you need courage. Whatever course you decide upon, there is always someone to tell you that you are wrong. There are always difficulties arising that tempt you to believe your critics are right. To map out a course of action and follow it to an end requires some of the same courage that a soldier needs. Peace has its victories, but it takes brave men and women to win them. - Ralph Waldo Emerson
  #5   Spotlight this post!  
Unread 15-02-2007, 23:19
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 help

Quote:
Originally Posted by JHale View Post
When we print off the value from Get_Encoder_1_Count(); all that is returned is either 256 or 260 without any change when the encoder is rotated.
How are you printing it? Note that the function returns a long integer. If you're trying to print it with a %d format, you'll only get the topmost two bytes.
  #6   Spotlight this post!  
Unread 16-02-2007, 11:02
JBotAlan's Avatar
JBotAlan JBotAlan is offline
Forever chasing the 'bot around
AKA: Jacob Rau
FRC #5263
Team Role: Mentor
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Riverview, MI
Posts: 723
JBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond repute
Send a message via AIM to JBotAlan Send a message via Yahoo to JBotAlan
Re: Encoder help

Quote:
Originally Posted by Alan Anderson View Post
How are you printing it? Note that the function returns a long integer. If you're trying to print it with a %d format, you'll only get the topmost two bytes.
That's what I was thinking too--printf() is very particular about the data type coming in.

To print out the encoder count, you could typecast it to an int for printf:
Code:
printf("Encoder 1 is %d\r\n", (int)Get_Encoder_1_Count());
would do it, I think.

I can't seem to find the documentation for the printf function, so I can't give you the %whatever value you need to make a long int print...I'm not even sure if it's possible directly. Just typecast it as I showed, and it should give you a good value out.

JBot
__________________
Aren't signatures a bit outdated?
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Encoder help Windward Programming 21 14-01-2006 15:10
Encoder code with hall effect sensors help brownster Programming 10 19-02-2005 09:23
Need Help with Encoder - Won't Count Clicks Kingofl337 Programming 5 16-02-2005 18:30
encoder.c Gary Bonner Programming 2 14-01-2005 13:41
shaft encoder help stephenthe1 Programming 2 03-12-2004 16:09


All times are GMT -5. The time now is 13:53.

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