View Single Post
  #7   Spotlight this post!  
Unread 23-01-2008, 00:45
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 590
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: WPILib and FRC default code

Quote:
Originally Posted by RyanW View Post
Including ifi_aliases.h and ifi_default.h should let you do some things, like assign pwms and digital IOs directly. As for interrupts and the like, our team hasn't figured out how to do those with WPILib yet. We have a project made by taking the default code, adding WPILib, and commenting out everything that gave an error. This should theoretically let you use some of the WPILib functions with default code, but I really doubt ours works and I'm not sure how to get to work in general. It's probably best to stick with either WPILib or the IFI default code.

To get it to show you all the errors at once:
Go to Configure-->Settings, then click on the Projects tab and uncheck "Halt build on first failure".
You can catch interrupts with WPILib by calling RegisterInterruptHandler(). There are some examples in the documentation at the web site. This function lets you specify a port, rising or falling edge, and a function to call when the interrupt occurs. Remember: when you do this, your function runs as an Interrupt Service Routine (ISR). This means that all other interrupts are disabled while it is running. If you spend much time in your ISR, you run the risk of missing other interrupts and having other sensors and timing break.

Another (safer) way of catching fast events in WPILib is by registering an interrupt watcher. These series of functions (also in the documentation) will set up an internal ISR for you and set a variable when the interrupt occurs. Then in your non-interrupt code, you can poll that variable to see if the fast event has occured. This is useful in many cases, for example, knowing if a reed switch on a pneumatics piston closed, or watching one of the IR board ports.

As for using WPILib, I'd suggest starting with a clean program - you only need a single file and none of the IFI default code. Use the template on the web site or in the docs in that file. There you fill in your Initialization, Autonomous and OperaterControl code and your running. If you want to use some of the IFI/Microchip header files for direct access to digital ports, that's not a problem.
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute