Go to Post I like this thread because it means I don't have to leave my house to find something to complain about! - PayneTrain [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 11-12-2006, 16:56
mluckham's Avatar
mluckham mluckham is offline
Registered User
FRC #0758 (Sky Robotics)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Ontario, Canada
Posts: 116
mluckham will become famous soon enoughmluckham will become famous soon enough
Glitches Eliminated using Interrupt Context Saving, BUT ...

Glitches Eliminated using Interrupt Context Saving, BUT ...


Can someone give me some advice?

I have written some pulse-measurement code for last years' wheel encoders, and along the way I discovered some things.

1) the CCP (Capture/Compare) feature that would have been the ideal solution cannot be used because there are no CCP input pins available on the full-size controller.

2) therefore I had to use pulse edge detection - interrupt on the leading edge of the pulse, capture the time, reprogram to interrupt on trailing edge, interrupt on trailing edge, capture the time again - subtracting the two times to get pulse width. To get the times I use TIMER3 programmed at 1/10 microsecond resolution.

3) all along (even before I had started working on the pulse measurement code) I had been seeing glitches on printf() output and also servo chattering. I'm using Kevin's interrupt-driven serial port code, but the printf() glitches were happening using the standard IFI serial port code also.

Suspecting some registers were getting clobbered by the interrupt service routines, I played around with the interrupt #pragma in user_routines_fast and managed to fix both problems ... but at a cost of substantial additional overhead - that affects both the minimum length of pulse I can measure, and the accuracy in measuring them.

I have some other interrupt-driven code that implements a wallclock timer using TIMER0, but disabling those interrupts does not fix the glitches - they are coming from elsewhere.

Here is the #pragma along with comments:


Code:
#pragma interruptlow InterruptHandlerLow save=PROD, section(".tmpdata"), section("MATH_DATA") /* You may want to save additional symbols. */
			// Dec2006 - failure to save section .tmpdata results in glitchy servos
			//         - failure to save section MATH_DATA results in glitchy printf
			//         - COST OF SAVING SECTIONS IS ABOUT 14 MICROSECONDS PER SECTION!!!
			//           WHICH AFFECTS MEASURING ENCODER PULSE LENGTHS
			//              minimum pulse measurable with save=PROD  is 14 usec
			//              adding section (".tmpdata")              is 27 usec
			//              adding section ("MATH_DATA")             is 40 usec

I'm happy to be rid of the glitches, but if I wasn't getting them in the first place I wouldn't need the extra #pragma sections and could measure smaller pulses.

Can anyone shed some light on this?
 


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
Saving Seats Karthik General Forum 58 05-05-2006 13:04
using extrude to cut away material, but its backwards CmptrGk Inventor 11 08-04-2006 13:26
Approppriate Grammatical Context of "Frolic" Eugenia Gabrielov Chit-Chat 6 06-05-2005 16:24
Saving Pics Jeffel Chit-Chat 9 23-01-2005 13:09
Time Saving Idea archiver 1999 0 23-06-2002 22:19


All times are GMT -5. The time now is 01:22.

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