View Full Version : Assigning Joystick buttons....
archiver
24-06-2002, 00:59
Posted by Bradford Stephens at 2/16/2001 9:36 PM EST
Student on team #351, Robomon All-Stars, from Clay High School and Iluka Resources, Inc.
Hello!
This is my first year in the competition, and my team's second. I'm the programmer, and am pretty handy with QBASIC. However, I took one look at this code and am totally boggled. I've been trying to tech myself how it works but have had no luck. I need to program several things, including two limit switches for our forklift, a compressor automatic shutoff, and more. None of these do I have the slightest clue how to wire to the digital input ports. Or program, for that matter.
But my most pressing need is this: we're using a two joystick drive system. This gives me four buttons to work with, because I don't really know how to wire additional toggle switches to the Op Interface ports (what pins do I put them on and how do I read the pin states?)...
anyway, I want the front trigger of my first joystick to control Relay 1 (click it once and it stays on, click it again and it stays off). I want the top trigger to control Relay 2 the same way, the front button on my 2nd joystick to control relay 3, and the top button oon it to control relay 4. How do I go about programming this?
Infinite Thanks in Advance!!! :D
*********
(t8r on)
*********
archiver
24-06-2002, 00:59
Posted by Joe Johnson at 2/16/2001 10:20 PM EST
Engineer on team #47, Chief Delphi, from Pontiac Central High School and Delphi Automotive Systems.
In Reply to: Assigning Joystick buttons....
Posted by Bradford Stephens on 2/16/2001 9:36 PM EST:
Try this
Onflag var bit
p1_sw_trig_old var bit
.
.
.
p1_sw_trig_old = 1
Onflag = 0
.
.
.
MainLoop:
.
.
.
if p1_sw_trig_old = 0 and p1_sw_trig = 1 and OnFlag = 1
then TurnOff
if p1_sw_trig_old = 0 and p1_sw_trig = 1 and OnFlag = 0
then TurnOn
goto SetRelays
Turnon:
OnFlag = 1
goto SetRelays
TurnOff:
Onflag = 0
SetRelays:
relay1_fwd = Onflag
.
.
.
goto MainLoop
Good Luck.
Joe J.
P.S. I wrote this from memory on the spot. It may
have bugs, but the
concept seems right to me.
archiver
24-06-2002, 00:59
Posted by Elliot Johnson at 2/17/2001 1:34 AM EST
Student on team #218, HP Robotics Team, from Highland Park High School and Double-E Inc..
In Reply to: Assigning Joystick buttons....
Posted by Bradford Stephens on 2/16/2001 9:36 PM EST:
:what pins do I put them on and how do I read the pin :states?...
Check the control system manual at www.innovationfirst.com
It provides lists of which pins do what on the four joystick ports. To add more switches, you solder the wires to correct pins on one of the 15 pin connectors in the kit. The pinout lists also identify which variable to use to read the switches.
later,
Elliot
archiver
24-06-2002, 00:59
Posted by Michael Bloomfield at 2/17/2001 9:00 AM EST
Student on team #375, Robotic Plague, from Staten Island Tech and Verizon.
In Reply to: Assigning Joystick buttons....
Posted by Bradford Stephens on 2/16/2001 9:36 PM EST:
Well here is some help on wiring additional digital switches on the OI. Let me know if u need additional help or need something explained in more detail.
Lets start off by realizing that one switch is actually 2 different input(variables)...so the middle pin on the switch is the ground and the other pins are the actual hot pins that output the 1(variable pins).
__
| |- Goes to one of Variable Pins
| |- Goes to Ground (See Pinout)
|_|- Goes to another one of Variable Pins
So lets say the top will be p4_sw_aux1 then would be set to pin 10. And lets say bottom will be set to p4_sw_aux2 would be set to pin 14. Middle goes to ground which lets use pin 4.
Port 4 Pinout for Digital Inputs
Pin Default Variable
2 p4_sw_trig
7 p4_sw_top
10 p4_sw_aux1
14 p4_sw_aux2
5 p1_sw_trig*
8 p1_sw_top*
9 p1_sw_aux1*
15 p1_sw_aux2*
4(ground)
12(gound)
* = Port 4 has access to the 4 unique digital inputs from Port 1 if you need those variables in Custom Switch. Allowing for a total of 16 unique digital inputs because every port has 4 unique variables but all the 16 variables can be accessed from Port 3 and 4 alone.
Now in your program just use p4_sw_aux1 and p4_sw_aux2 to access the different settings of switch using the wiring above. Same thing for analog except a little different to wire let me know if you need help with this as well. I hope that this helped a little and please feel free to email me if you have any other questions.
Also in code to make the switch stay when pushed forward and shut off when pushed other way try this:
In main loop:
' If pushed forward turn on
IF (p4_sw_aux1 = 0) THEN NotOn:
relay1_fwd = 1
relay1_rev = 0
NotOn:
' If pushed other way turn off
IF (p4_sw_aux2 = 0) THEN NotOff:
relay1_fwd = 0
relay_rev = 0
NotOff:
Hope this helps...let me know.
archiver
24-06-2002, 00:59
Posted by Nate Smith at 2/18/2001 3:25 PM EST
Other on team #66, Frostbite, from Willow Run High School and GM Powertrain.
In Reply to: Wiring Additional Switches on the OI
Posted by Michael Bloomfield on 2/17/2001 9:00 AM EST:
: * = Port 4 has access to the 4 unique digital inputs from Port 1 if you need those variables in Custom Switch. Allowing for a total of 16 unique digital inputs because every port has 4 unique variables but all the 16 variables can be accessed from Port 3 and 4 alone.
Actually, all 16 are available between ports 2 and 4...ports 1 and 3 have the LED drivers...unless they changed that on the 2001 controller and nobody told me there was a new control system manual out...
Nate
archiver
24-06-2002, 00:59
Posted by Michael Bloomfield at 2/19/2001 4:35 PM EST
Student on team #375, Robotic Plague, from Staten Island Tech and Verizon.
In Reply to: Actually...
Posted by Nate Smith on 2/18/2001 3:25 PM EST:
My mistake...you are correct. Port 2 & 4 can access all the Inputs and 1 & 3 control the LED Drivers. My bad...Mike.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.