Go to Post OMFG! Sanity prevails! It's unprecedented! - Kevin Sevcik [more]
Home
Go Back   Chief Delphi > Technical > Control System > Sensors
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
  #4   Spotlight this post!  
Unread 14-01-2008, 18:28
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 592
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: Programming the Infrared board

Quote:
Originally Posted by Abrakadabra View Post
Hi Brad -

Thanks for doing this. This is also a good example of showing that you can use the IFI headers in a WPILib program, something that's not so apparent on first glance.

Some questions:

- I think I understand what RegisterRepeatingTimer() does, although it is not really documented. The header file says that timer interrupt handlers are "called with interrupts disabled". However, do you not also need to disable interrupts when you access the shared globals in the main( ) routine?
You're right... not documented, I'll try to fix that. It is called as an interrupt service routine so you want the code to be fast. As far as the shared globals in the main routine... good question. I don't think it's a problem because the interrupt service routine never turns them off and there is only a single value. If you wanted to count the number of times the IR code was received in the ISR and decrement the count in the main program, then it would have to be protected. As it is, I don't think you lose anything, but I could be wrong.

Quote:
Originally Posted by Abrakadabra View Post
- The variables "changed" and "previous" in your ISR don't seem to do anything? Again, I think I understand what you are trying to do (e.g. collect all the commands in between times that the program actually checks for them), but "previous" never gets set to anything other than zero, and "changed" is calculated, but then not used. Would it not be simpler to just say:
Code:
 irCommands |= current;
and then the main() routine can turn off each bit as it gets processed? I think that's what the code is essentially doing now, since "previous" is always zero.
You are so right about the previous variable not being set... I must have been sleeping. And I showed it to a few people and nobody else noticed. What I was trying to do was only set the bit on a change from off to on so. I didn't want two polls to look like two events. If you just OR the new value into the result, then if in one ISR call the bit is set, then before the next 30ms period, the main program clears the bit, then the next timer interrupt notices that the bit is still set, it would like to two button presses.

Thanks for noticing the problem!

Brad
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote
 


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
pic: Programming prototyping board Andrew Schuetze Extra Discussion 3 08-12-2007 18:30
Perf Board = BS2-IC Carrier Board? indieFan Electrical 2 16-09-2004 08:28
What is the true field infrared emitter? scottm87 Programming 4 20-04-2004 18:22
Ordering the TSOP34840 Infrared Receivers yaman Electrical 5 23-01-2004 02:10
Infrared Beacon Board AlphaOmega870 Electrical 5 23-01-2004 01:58


All times are GMT -5. The time now is 17:33.

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