Call the function only once from your Initialize function and WPILib will start checking the status of the pressure switch every 500ms and operate the compressor when needed. The compressor should be connected to a spike connected to the specified relay port.
There is a new version of WPILib on the web site that has some changes that were just added today to help us with some motor control. So here you go:
Modified Motor function to be aware of the deadband in the Victor 884 speed controllers. The Victor 884 has a built-in deadband that runs from 117-137 of PWM values sent to it. The Motor function will now take values from 0-127 and 0-(-127) and scale them to fit into the actual working range of the Victor which is 23-116 and 138-232. This means that values sent to the motors will tend to be more continuous without the discontinuity in the range. The Motor function is used by Drive and Motors so if you use these functions, the change will be seen in those functions as well.
There is another function added,
unsignd char GetPacketNumber(void)
that returns the OI packet number. Each time a new packet is received from the master processor this number is incremented. It is only a 8 bit value so it wraps around every 256 packets, but it provides an indication of when there is new data received.
Let me know if you find any problems, particularly with the Motor change. I think this will help - it did for some motors controlled by PID loops for us. There were too many conflicting controls and was getting very confusing.
No - the SetPWM function still sends whatever value you give to the PWMs. That way you can use the Motor(port, value) function to get the scaled version, and SetPWM(port, value) to get the unmodified output version.
I’m attempting to compile a student’s program that was written and exported from EasyC. I don’t have EasyC and as such I’m using MPLab and your library to build the project. Everything goes well until the link step. It then notifies me that the “Coff file format is out of date” for the objects in the lib file. It wants to rebuild the library, but I obviously don’t have the source. Naturally, Microchip changed their coff format with the new version of their compiler. I’m using version 3.01 of the compiler, which comes with version 4.01 of the linker. Can you post the source to the library so it can be rebuilt? If not, what version are you using to build the library so I can downgrade?
WPILib is built with the version 7.20 of MPLab and 2.40 of the compiler. The newer tools generate a different output file format, and do some (possibly) incompatible optimizations with interrupt handlers. The IFI code which is included with WPILib is also on the older tools and also prevents the use of the new compiler.
To be sure, I’d suggest switching to those versions of the tools. You can get them from the CD that was included in the kit of parts.
I’ve updated our EasyC with the new libraries. To test I added
InitPressureSwitch(1,2);
to our code and built it. It returned no errors but a warning that the above function call had no prototype. I’m not sure how to rectify this with EasyC, any thoughts?
You should also replace the UserAPI.h file to get the new functions to be available in your version of EasyC. Then if you reference the function there won’t be any warnings.
There are additional functions in Builtins.h that you might also want to use. They are documented (mostly) in the PDF file.
I started coding up our full application using WPILib but I ran across a big difference between the documentation and what I assume are new functions. In the userAPI.h file, there are two camera functions:
The first is obviously a changed version of InitializeCamera() and the second must be new. Could you give a quick rundown of how they work, especially the ‘cameraInitIndex’ parameter of InitCamera() ? And how do we set camera parameters as there is no place to set up a CameraInitializationData struct.
You caught me! I just put up a new version with the function definition included in the BuiltIns.h file.
There are a few functions in WPILib which are hard for programmers to use, but easy for EasyC to automatically generate. These are two of those functions.
The function:
InitializeCamera(CameraInitializationData *c);
that you can call passing the address of the camera initialization structure. This is probably easiest for you to use. The other function:
InitCamera(unsigned char cameraInitIndex);
was intended for EasyC. It assumes that there is an array of those structs and the argument is the index to the one you want to use.
My suggestion is to initialize a structure with the camera parameters you want to use and call InitializeCamera. It’s actually called from inside of InitCamera anyway.
The other functions to use the camera data are:
CaptureTrackingData(…) - this is the one you described
and
TPacket *CopyTrackingData(void);
Is the function that I intended hand-coding programmers to use. This returns a pointer to a static structure containing a TPacket inside of WPILib. When you call the function, it turns off interrupts, grabs the most recent packet, and puts it into the static structure - then returns its address.
Then you can write code like this:
TPacket t = CopyTrackingData();
conf = t->confidence;
There is a new version of WPILib that has better error handling for the CMUCam. It will now fail more quickly if the camera is not detected and there is a function to get the status from the camera after initialization.
Please post something with your results. I have tested it on a 2006 controller with the camera disconnected from the serial adapter and also with the serial adapter disconnected from the robot and both seem to work.
Be sure to save the old version this close to shipping in case you don’t like the results.