Go to Post Johnny V-Neun. People just want to be his kind of cool... none of us really know why... - Pamela [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-02-2006, 12:36
jgeorge's Avatar
jgeorge jgeorge is offline
Mentor
AKA: Jacob George
FRC #0078 (AIR Strike)
Team Role: Engineer
 
Join Date: Feb 2006
Rookie Year: 2000
Location: Newport, RI
Posts: 2
jgeorge is an unknown quantity at this point
Encoder counting randomly off by x4 factor

Hi all,

I am using Grayhill 63K64 because I have a high speed shaft, 2000rpm, and wanted the ball bearing version of encoder. I am running it directly from the encoder to the 2006 RC input (no flip flop to buffer B phase) using two 3' servo cables. I am also using Kevin's latest version of encoder code (BTW, thanks Kevin, it is good stuff). The interrupt stuff is as is. In the slow loop, I read the encoder counts, do a delta between readings to get velocity at 26.2ms rate, and try to make decisions. Everything compiles and counts except.....

Every time I start the RC, I am never sure if the encoder will count a magnitude off by 4 times or not. For example, when measuring the rotation of spinning beam, I sometimes read vel of 16 ticks/loop or 64 ticks/loop for the same PWM setting to the motor. It appears random, possible related to software changes, but I have not isolated it to whether it is due to my changes or inherent in my hardware setup.

What I mean by random is that with one version, but multiple resets, it appears error repeats itself, always 16 or always 64. When I rewrite code and download, it could change but between resets, the new factor sticks. I do not know why main line coding should affect it because counter is in interrupt. Unless it is because I am using printf statement and the serial drivers (Kevin's, not IFI's) is using interrupts and is higher priority than the encoder interrupt and interfering somehow. I am only printing out about 25 chars every 26.2ms at 115K baud.

I also tried reversing the input 1 and input 11 signals, no luck. I tried moving to encoder 3 (pin 3 and 13, no luck). I have not tried short cable.

Any ideas?

Thanks in advance.
Jacob
__________________
JG78

Last edited by jgeorge : 02-02-2006 at 12:40. Reason: revise text
  #2   Spotlight this post!  
Unread 02-02-2006, 13:27
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Encoder counting randomly off by x4 factor

Quote:
Originally Posted by jgeorge
Hi all,

I am using Grayhill 63K64 because I have a high speed shaft, 2000rpm, and wanted the ball bearing version of encoder. I am running it directly from the encoder to the 2006 RC input (no flip flop to buffer B phase) using two 3' servo cables. I am also using Kevin's latest version of encoder code (BTW, thanks Kevin, it is good stuff). The interrupt stuff is as is. In the slow loop, I read the encoder counts, do a delta between readings to get velocity at 26.2ms rate, and try to make decisions. Everything compiles and counts except.....

Every time I start the RC, I am never sure if the encoder will count a magnitude off by 4 times or not. For example, when measuring the rotation of spinning beam, I sometimes read vel of 16 ticks/loop or 64 ticks/loop for the same PWM setting to the motor. It appears random, possible related to software changes, but I have not isolated it to whether it is due to my changes or inherent in my hardware setup.

What I mean by random is that with one version, but multiple resets, it appears error repeats itself, always 16 or always 64. When I rewrite code and download, it could change but between resets, the new factor sticks. I do not know why main line coding should affect it because counter is in interrupt. Unless it is because I am using printf statement and the serial drivers (Kevin's, not IFI's) is using interrupts and is higher priority than the encoder interrupt and interfering somehow. I am only printing out about 25 chars every 26.2ms at 115K baud.

I also tried reversing the input 1 and input 11 signals, no luck. I tried moving to encoder 3 (pin 3 and 13, no luck). I have not tried short cable.

Any ideas?

Thanks in advance.
Jacob
As I pointed out in the encoder_readme.txt file, you may need a line driving circuit at high count rates (2100/sec is high) to drive the capacitance of the cabling. Try it at lower spin rates and see if the problem goes away. If you can find a way to gear it down, that would be good. You can also use a 74ACT244 or 74LS244 IC mounted close to the encoder to send the signals through the cabling.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #3   Spotlight this post!  
Unread 02-02-2006, 14:38
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,113
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 counting randomly off by x4 factor

Just to reduce the number of variables, try putting in some code to toggle an otherwise unused output every time you compute the delta. Look at that output with a scope to see that you're actually doing it every 26.2 milliseconds. That'll help tell you where to focus your attention.

Look at the encoder output with the scope too, just to make sure that it stays consistent.
  #4   Spotlight this post!  
Unread 02-02-2006, 15:50
jgeorge's Avatar
jgeorge jgeorge is offline
Mentor
AKA: Jacob George
FRC #0078 (AIR Strike)
Team Role: Engineer
 
Join Date: Feb 2006
Rookie Year: 2000
Location: Newport, RI
Posts: 2
jgeorge is an unknown quantity at this point
Re: Encoder counting randomly off by x4 factor

Alan, Thanks for good suggestions. I will try to wrangle a scope from somewhere into the school to check encoder signals. And do the output bit test trick as well. Should give a good picture of situation.

Kevin, Thanks for reply. I will build the board. But, why does it work sometimes? Just marginal you think? I was going to stop all prints and see if it works better as the TX buffer intr. taking too long might interfere with the encoder phase B read causing the problem. Maybe in some versions of code, the print time is synched with the encoder phase B just right! In any case, I agree with you that it appears I will have to build board.
__________________
JG78
  #5   Spotlight this post!  
Unread 02-02-2006, 16:11
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,082
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Encoder counting randomly off by x4 factor

I would guess it is marginal.
  #6   Spotlight this post!  
Unread 02-02-2006, 21:17
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Encoder counting randomly off by x4 factor

Quote:
Originally Posted by jgeorge
Alan, Thanks for good suggestions. I will try to wrangle a scope from somewhere into the school to check encoder signals. And do the output bit test trick as well. Should give a good picture of situation.

Kevin, Thanks for reply. I will build the board. But, why does it work sometimes? Just marginal you think? I was going to stop all prints and see if it works better as the TX buffer intr. taking too long might interfere with the encoder phase B read causing the problem. Maybe in some versions of code, the print time is synched with the encoder phase B just right! In any case, I agree with you that it appears I will have to build board.
Yeah, it would be great to put a scope on it and see what's happening. Make sure you look at the signals at the robot controller (sorry if I'm pointing out something obvious). If you figure out what's going on please post your findings.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
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 Code Kevin Watson Programming 47 18-02-2008 12:56
encoder vs. motor stephenthe1 Programming 55 06-01-2005 22:07
Updated Encoder Code Available Kevin Watson Programming 2 04-01-2005 01:00
how to add steps in the provided encoder program for the edu Zaramel2002 Programming 3 11-02-2004 08:35
Problems counting encoder pulses bludstayne Programming 7 02-02-2004 23:07


All times are GMT -5. The time now is 21:00.

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