Go to Post so instead of saying why, we said why not? - Alpha Beta [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-2004, 17:34
bludstayne's Avatar
bludstayne bludstayne is offline
Registered User
#0547
 
Join Date: Nov 2003
Location: Fayetteville, TN
Posts: 10
bludstayne has a little shameless behaviour in the past
Send a message via AIM to bludstayne Send a message via Yahoo to bludstayne
Problems counting encoder pulses

We are having problems counting pulses with our encoders, even at very low speeds. We aren't sure whether this is a problem in the code or with the hardware, but our counting problem is so bad that we can watch the controller missing pulses on hyperterminal. Is anyone else having this problem?
__________________
I hate signatures. I wouldn't even consider having one.
  #2   Spotlight this post!  
Unread 02-02-2004, 17:43
kc8nod's Avatar
kc8nod kc8nod is offline
Registered User
AKA: Ted Hansen
FRC #1216 (Knights)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Oak Park Michigan
Posts: 43
kc8nod is on a distinguished road
Re: Problems counting encoder pulses

Do you know how fast you are sampling the inputs?
How about how fast the encoder shaft is turning?

Without seeing your code it is hard to diagnose.

If you are reading the inputs only once every 26ms, you are very likely to miss pulses.
  #3   Spotlight this post!  
Unread 02-02-2004, 17:47
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Problems counting encoder pulses

best to put sensor-checking code (if you are using a polling method) in user_routines_fast.c

the best way (if possible) to poll such sensors would probably be interrupts.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
  #4   Spotlight this post!  
Unread 02-02-2004, 18:23
bludstayne's Avatar
bludstayne bludstayne is offline
Registered User
#0547
 
Join Date: Nov 2003
Location: Fayetteville, TN
Posts: 10
bludstayne has a little shameless behaviour in the past
Send a message via AIM to bludstayne Send a message via Yahoo to bludstayne
Re: Problems counting encoder pulses

Our code is in user_routines_fast. We tried adding another variable to the code to count the loops when the code did not detect a high signal, and usually we looped several thousand times (at least) between "hits." As I said, we were going VERY slowly. Thanks for your ideas, though. We appreciate any help you can give us.
__________________
I hate signatures. I wouldn't even consider having one.
  #5   Spotlight this post!  
Unread 02-02-2004, 21:50
velocipenguin velocipenguin is offline
Registered User
#0246 (Overclocked)
Team Role: Programmer
 
Join Date: Feb 2004
Location: Boston, MA
Posts: 77
velocipenguin is on a distinguished road
Send a message via AIM to velocipenguin
Re: Problems counting encoder pulses

You might want to consider using an external counting circuit to count pulses and store them in some sort of register that can be read by the RC at any time. Before doing that, however, I would recommend modifying your code so that it uses interrupts to count pulses - this would eliminate any problems caused by the fairly low sample rate imposed by the rate at which the main loop executes.
  #6   Spotlight this post!  
Unread 02-02-2004, 21:56
Guest
 
Posts: n/a
Re: Problems counting encoder pulses

We have a custom circuit that converts the frequency of pulses to an analog signal from 0 to 5v. With the counting circuitry independent from the control loop in software, it is easier to isolate problems and work on the "real" programming
  #7   Spotlight this post!  
Unread 02-02-2004, 22:35
kc8nod's Avatar
kc8nod kc8nod is offline
Registered User
AKA: Ted Hansen
FRC #1216 (Knights)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Oak Park Michigan
Posts: 43
kc8nod is on a distinguished road
Re: Problems counting encoder pulses

Even if your code is running in user_routines_fast.c you can still miss pulses. Remember that everything comes to a screeching halt when it is time to run the Process_Data_From_Master_uP(). The most reliable way to count pulses is with an interrupt-driven routine. Perhaps you could look at Kevin Watson's example code at http://www.kevin.org/frc/
But if you really are turning the shaft very slowly (much greater than 26ms between pulses) it sound like you've got some other bug.
Why not post the code here?
  #8   Spotlight this post!  
Unread 02-02-2004, 23:07
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: Problems counting encoder pulses

Quote:
Originally Posted by kc8nod
Even if your code is running in user_routines_fast.c you can still miss pulses. Remember that everything comes to a screeching halt when it is time to run the Process_Data_From_Master_uP(). The most reliable way to count pulses is with an interrupt-driven routine. Perhaps you could look at Kevin Watson's example code at http://www.kevin.org/frc/
But if you really are turning the shaft very slowly (much greater than 26ms between pulses) it sound like you've got some other bug.
Why not post the code here?
Yes, there is an example written for the EDU-RC that should be easilly ported to the FRC-RC. Just drop encoder.c/.h into your project and modify user_routines_fast.c to call the interrupt handlers. The interrupt handlers are very efficient and should have no problem with many hundreds of counts per second (I've successfully done five thousand/sec).

-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
Official Beacon Tracking Code Posted Kevin Watson Programming 41 18-02-2004 21:04
Do you all have problems with.... Munkaboo Website Design/Showcase 19 03-03-2003 19:51
Joystick problems archiver 2001 3 24-06-2002 02:40
Radio problems -- not archiver 2000 1 23-06-2002 22:23
PUlse counting junkyarddawg Technical Discussion 1 31-01-2002 15:33


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

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