URgent Programming Help needed

Hi how are you doing i am doing programming for the first time and we are using a F-16 Fighter stick

http://www.surcouf.com/images/catalogue/34/77/g147734.jpg

I was wondering do any one know what we have to do so that we can use one of the buttons on this joystick to do some let say move the robot to a certain position. Like if you push a button on the joy stick the robot arm will move to a certain position. so what the process i have to go through to get this done. like what do we have to change in the code, and what wires do we have to use we are using the globe motors too. thank you

I understand that we have to use the code listen below but in what way or form
thanks

#define p1_sw_trig rxdata.oi_swA_byte.bitselect.bit0 /* Joystick Trigger Button, same as Port4 pin5 /
#define p1_sw_top rxdata.oi_swA_byte.bitselect.bit1 /
Joystick Top Button, same as Port4 pin8 /
#define p1_sw_aux1 rxdata.oi_swA_byte.bitselect.bit2 /
Aux input, same as Port4 pin9 /
#define p1_sw_aux2 rxdata.oi_swA_byte.bitselect.bit3 /
Aux input, same as Port4 pin15*/

The way the default code is set up, you don’t need to modify anything, if you are using pneumatics. Hook up the pneumatic valve (ask me if you don’t know how) to a Spike (bi-directional relay, provided in kit), hook up the power cables (positive to circuit breaker, negative to negative on circuit breaker), hook up the PWM cable to the Relay Output #1, and that pneumatic will operate when the trigger of Joystick 1 is pressed. Use Relay Output #2 for Joystick 2, and so on. The code that dictates this operation is not where you found it, it is in user_routines.c and is listed as follows:

relay1_fwd = p1_sw_trig & rc_dig_in01; /* FWD only if switch1 is not closed. /
relay1_rev = p1_sw_top & rc_dig_in02; /
REV only if switch2 is not closed. /
relay2_fwd = p2_sw_trig & rc_dig_in03; /
FWD only if switch3 is not closed. /
relay2_rev = p2_sw_top & rc_dig_in04; /
REV only if switch4 is not closed. */
relay3_fwd = p3_sw_trig;
relay3_rev = p3_sw_top;
relay4_fwd = p4_sw_trig;
relay4_rev = p4_sw_top;

You can change the behavior by changing these. Good luck, and tell me if something isn’t working or you don’t know how… :slight_smile:

JBotAlan has pointed out how the code can essentially copy the OI switches to RC relay outputs. If you want to do anything fancier than that, you’ll have a lot more programming in front of you. There are feedback sensors on robot joints, accelerometers and angular rate sensors, PID controls, etc… Get specific with your questions and we can give you specific help on how to do what you want.

(The section of the code you quoted is just providing “easy” names for the bits of communication from the master CPU that represent the state of the joystick switches.)

So, I was looking for some programming help and I think I found what I was looking for, but would like some reassurance. We are using one cylinder for our manipulator. My question was, “What programming do we need to do in order to activate that cylinder? We plan on using a double sylinoid (sp?).”
From what I read, we don’t need to do any additional programming. Part of the default code provides for use of the cylinder via a button or trigger on the joystick. Is this correct?
We are a rookie team and have access to VERY LIMITED programming experience. Any codes or help is GREATLY appreciated. :confused:

I couldn’t resist. I just posted this code elsewhere for another purpose, but it applies here as well.


if (p1_sw_trig==1)  // Cylinder one way
{
	relay2_fwd = 1;
	relay2_rev = 0;
}
else if (p1_sw_top==1) // Cylinder the other way
{
	relay2_fwd = 0;
	relay2_rev = 1;
}
else  // Cylinder not moving
{
	relay2_fwd = 0;
	relay2_rev = 0;
}