Joystick Programming

Hello. Does the FRC default code allow 2 joysticks to be used? Also, is there any way to adjust the sensitivity of the controllers, or the speed of the motors?

Hi, and yes there is. The controllers (I’m going to guess that you mean the Victors) are pretty much un-programmable. The motors, however, are programmable by way of the Victors that run them. Now I’m not sure what you are using for the programming tool but we used the free ROBOTC software that can be downloaded from one of these forums(try searching FREE ROBOTC, that’s what I did). Let me know if it’s a different programming language and I’ll help you. You could also PM me if you need any more help.:slight_smile:

also, if you’re new at this and dont have anyone else who knows what they’re doing, avoid using MPLab…try EasyC or robotC instead. i dont have any experience with these, but they’re supposed to be easier!

I concur ROBOTC and EasyC are probably the easiest.

i just avoid them because they have ‘easy’ in them (well, just easyC) :stuck_out_tongue:

I’m sorry, I should have been a bit clearer: By controllers, I meant the joysticks.
Where in the code does it allow you to adjust motor sensitivity? Looking at the default code, I have no idea where I can adjust that.

if you look in the default code you will see lines like


pwm01 = p1_y
pwm02 = p2_y

pwm is the term for each of the moters. p1_y and p2_y are joystick 1 & 2 on the y axis. These give you a value between 0 and 255, with 127 being neutral. To adjust the sensitivity you can take the joystick input and apply a little bit of math and what you set the motors to will be less.

I will give you a link to a thread I posted in a couple of weeks ago on this.

Edit: http://www.chiefdelphi.com/forums/showthread.php?t=61929

I’m sorry what programming tool are you using? That code that wt200999 posted may be the code that works for EasyC only (i don’t know really). There are other codes that work with other systems.

Sorry about any confusion, that thread was about how to do it in easyC, the example I posted in there I wrote in MPlab. Someone else had posted code in that thread that works in easyC if you are using that.

OK…thanks for the info.

I have another question: What kind of algorithm or math should I use to reduce joystick sensitivity? I am really new to this programming thing…

Hi there.

ROBOTC makes using the joystick very easy. If you wanted to use the joysticks to drive your robot you could the following code:

while(true){
motor[port1] = frcRF[p1_y]; //maps pwm port 1 to the Y axis of Joy1
motor[port2] = frcRF[p2_y]; //maps pwm port 2 to the Y axis of Joy2
{

You can in exchange slow down the motors and still retain the joystick “movement” by dividing the values you’re getting from the joystick… like in this example:

while(true){
motor[port1] = (frcRF[p1_y] / 2); //maps pwm port 1 to half the value of the Y axis of Joy1
motor[port2] = (frcRF[p2_y] / 2); //maps pwm port 2 to half the value of the Y axis of Joy2
{

I posted here about what we do. It gives us maximum speed (something dividing doesn’t) and reduces sensitivity at low speeds. If you are using RobotC or EasyC, I don’t know how you would implement it, but I assume that it is possible (I mean, if those tools don’t allow working with arrays, I would be very disappointed).