PDA

View Full Version : Direct Control of PWMs and OI in WPILib


CyberWolf_22
01-22-2006, 12:54 AM
I have been reading over the WPILib and I am really excited about it but I still want to be able to perform advanced operations.

When I wrote some code using the ifi_aliases, like pwm01 or p1_y I, I can not compile it. I realize why these don't work because they are not defined anywhere but what I want to do is directly access the values of the OI inputs and the pwm ports when using WPILib. Is there any way for me to be able to do this?

Thank You,

Kingofl337
01-22-2006, 07:44 AM
This should help you out.

X = GetOIAInput(A,B);

X is the variable name you want assign you items too.
A is the OI port 1 through 4
B is the Axis on the joystick
1 = X-Axis
2 = Y-Axis
3 = Wheel
4 = Aux Port

Then to drive the motor.

SetPWM (C,D);
C is the PWM port number 1 - 12
D is the Value or Variable to be used to drive the motor.

Example of them working together to make a tank drive setup.

Joy1 = GetOIAInput(1,1);
Joy2 = GetOIAInput(2,1);

SetPWM (1,Joy1);
SetPWM (2,Joy2);

BradAMiller
01-22-2006, 07:43 PM
I have been reading over the WPILib and I am really excited about it but I still want to be able to perform advanced operations.

When I wrote some code using the ifi_aliases, like pwm01 or p1_y I, I can not compile it. I realize why these don't work because they are not defined anywhere but what I want to do is directly access the values of the OI inputs and the pwm ports when using WPILib. Is there any way for me to be able to do this?

Thank You,
You are correct. To get that extra performance you can access the OI values, and the PWM outputs and digital I/O directly. To get those values you need to include "ifi_aliases.h" and "ifi_default.h" files from the IFI default code (either 2005 or 2006).

It turns out that we are doing exactly that on the Team 190 robot - most of those functions you might replace with a single assignment statement are there for EasyC and correspond to blocks in the palette. If you are hand writing code, feel free to access those registers and IFI data structures directly.

rodgadashruba
01-24-2006, 02:21 PM
so all you would need to do is include the various libraries and you could use commands you would normally do w/out WPIlib intertwined with the WPIlib comands? i mean it makes sence but i am just chekcing if there is anything else that i would need to include

thanks

BradAMiller
01-25-2006, 07:25 AM
so all you would need to do is include the various libraries and you could use commands you would normally do w/out WPIlib intertwined with the WPIlib comands? i mean it makes sence but i am just chekcing if there is anything else that i would need to include

thanks
That is correct. And in fact, you only need to include the 2 libraries that are on the WPILib web site (unless you have additional libraries of your own). Those two libraries include all the IFI stuff - like ifi_utilities.o, etc.

So you can do these things:

include the IFI .h files (ifi_aliases.h, ifi_utilities.h, etc.) and write to the PWM, digital I/O, analog (may change in the future - post build season), and relay ports directly.
Include you own object files that don't change interrupts - except using the WPILib interrupt handling functions

Things you should NOT do:

Change the interrupt code. There is an interrupt handler built into WPILib and you can get interrupts delivered to your program. Check out the documentation if this is something you need.
You can't use the hardware timers - currently WPILib is using timer 1 and all the associated interrupt handlers. You could use other timers (without interrupts) for now, but I can't guarantee that this will continue to work in future versions.
Do not call get_data or put_data or any of the other IFI code to interact with the master processor. This is all done in the background in WPILib and making additional calls of this type will probably break your program.

If you have specific things that you want to do, please let me know and I'll tell you if it is safe.

Kruuzr
02-06-2006, 12:05 PM
That is correct. And in fact, you only need to include the 2 libraries that are on the WPILib web site (unless you have additional libraries of your own). Those two libraries include all the IFI stuff - like ifi_utilities.o, etc.

So you can do these things:

include the IFI .h files (ifi_aliases.h, ifi_utilities.h, etc.) and write to the PWM, digital I/O, analog (may change in the future - post build season), and relay ports directly.
Include you own object files that don't change interrupts - except using the WPILib interrupt handling functions

Things you should NOT do:

Change the interrupt code. There is an interrupt handler built into WPILib and you can get interrupts delivered to your program. Check out the documentation if this is something you need.
You can't use the hardware timers - currently WPILib is using timer 1 and all the associated interrupt handlers. You could use other timers (without interrupts) for now, but I can't guarantee that this will continue to work in future versions.
Do not call get_data or put_data or any of the other IFI code to interact with the master processor. This is all done in the background in WPILib and making additional calls of this type will probably break your program.

If you have specific things that you want to do, please let me know and I'll tell you if it is safe.

Brad...
I've just started playing with WPILib (and I love it!!!) but I was hoping to use the dashboard program I've written which utilizes the six user bytes. Are these accessable via WPILib???

Steve

BradAMiller
02-06-2006, 05:43 PM
Brad...
I've just started playing with WPILib (and I love it!!!) but I was hoping to use the dashboard program I've written which utilizes the six user bytes. Are these accessable via WPILib???
Steve
To be honest I have never played with the dashboard interface, but people keep asking about it. And over the last few days, I've been trying to find time to play around with it.

There is nothing explicitly done to support or preclude setting those values. I think you can just include ifi_aliases.h and write to those bytes. When the code does the get_data/put_data I think they will get sent over.

If you happen to try it first, please post a message with your results.

BradAMiller
02-06-2006, 06:06 PM
To be honest I have never played with the dashboard interface, but people keep asking about it.
I lied... just tried it and it works fine. You can write the user bytes and they show up in the dashboard.

So, have fun with it. I think I need to try writing a custom viewer. Would be nice for debugging.