Considering the release a Joystick hack Object
Keith Young
Posts: 569
You guys have been very helpful with a project I have been doing so I would like to return the favor. My project is currently using a USB Logitech Joystick as linked:
http://www.amazon.com/Logitech-Extreme-Joystick-Silver-Black/dp/B00009OY9U/ref=sr_1_1?ie=UTF8&qid=1296361030&sr=8-1

When you take it apart, you can remove the internal USB board and either simply plug in your own breadboard wires or even find the correct connection to make a PCB if you wish. There is enough space in there for a Prop on a custom made PCB if you wish to do so.
The joystick operates strangely in that the buttons aren't connected to high or low, but instead are pulsed on phases so that fewer wires can be used for the manufacturer. In order to get best use of this I made an assembly program, which is my first assembly program and also the first thing done almost "prefessional" enough to release.
Could you guys look over this and see if you like the idea? And also comment on what I need to change to make this releaseable.
Obviously it will need some sort of schematic.
http://www.amazon.com/Logitech-Extreme-Joystick-Silver-Black/dp/B00009OY9U/ref=sr_1_1?ie=UTF8&qid=1296361030&sr=8-1

When you take it apart, you can remove the internal USB board and either simply plug in your own breadboard wires or even find the correct connection to make a PCB if you wish. There is enough space in there for a Prop on a custom made PCB if you wish to do so.
The joystick operates strangely in that the buttons aren't connected to high or low, but instead are pulsed on phases so that fewer wires can be used for the manufacturer. In order to get best use of this I made an assembly program, which is my first assembly program and also the first thing done almost "prefessional" enough to release.
Could you guys look over this and see if you like the idea? And also comment on what I need to change to make this releaseable.
Obviously it will need some sort of schematic.
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
ADC_dpin = 1
ADC_cpin = 2
ADC_spin = 0
rudderc = 0
aileronc = 1
elevatorc = 2
throttlec = 3
OBJ
AD : "MCP3208_fast_ADC"
DB : "FullDuplexSerial"
VAR
long Shared
word rudder, aileron, elevator, throttle
long stack[256]
PUB Start
AD.Start(ADC_dpin, ADC_cpin, ADC_spin, 0) 'Start ADC
DB.Start( 31, 30, 0, 57600) 'Start Parallax Serial Terminal communication
cognew(@entry, @Shared) 'Begin running Assembly code
cognew(Check_Act, @stack[0]) 'Check status of joystick and act
Pub Check_Act
dira[27]~~
outa[27]~
dira[26]~~
outa[26]~
repeat
rudder := AD.In(rudderc) 'Get ADC value of Rudder
aileron := AD.In(aileronc) 'Get ADC value of Aileron
elevator := AD.In(elevatorc) 'Get ADC value of Elevator
throttle := AD.In(throttlec) 'Get ADC value of Throttle
DB.Dec(Shared) 'Display status of Buttons
DB.Str(String(13))
DB.Dec(rudder) 'Display Rudder value
DB.Str(String(13))
DB.Dec(aileron) 'Display Aileron value
DB.Str(String(13))
DB.Dec(elevator) 'Display Elevator value
DB.Str(String(13))
DB.Dec(throttle) 'Display Throttle value
DB.Str(String(13))
if shared & butt1 == butt1 'Check if trigger is pulled. Trigger is Button 1
outa[27]~~ 'Turn on light if trigger is pulled
else
outa[27]
if shared & butt13 == butt13 and shared & butt14 == butt14
outa[26]~~ 'If HAT switch is pushed forward and right
else 'turn on a light
outa[26]~
DAT
ORG 0
entry mov Mem, PAR
or dira,pinn21
or outa,pinn21
or dira,pinn25
or outa,pinn25
or dira,pinn24
or outa,pinn24
{{ or dira,pinn10 Un comment this area in order to use
or outa,pinn10 the 6 buttons on the base of the
or dira,pinn15 joystick and the throttle
or outa,pinn15
or dira,pinn17 ALL AREAS OF CODE COMMENTED OUT BELOW CONTROL
and outa,pinn17 JOYSTICK BASE. UNCOMMENT FOR THIS FUNCTION }}
or dira,pinn27
and outa,pinn27
xor outa,pinn21
xor outa,pinn25
xor outa,pinn24
'xor outa,pinn10
'xor outa,pinn15
mov time,cnt 'Current clock loaded into time
add time,delay 'delay added to time
:Loop
xor outa, pinn21 'Pin 21 PHASE 1
waitcnt time,delay
mov temp, ina
test temp, pinn23 wz '13 Hat Up
if_z or button, butt13
if_nz andn button, butt13
test temp, pinn22 wz '14 Hat Right
if_z or button, butt14
if_nz andn button, butt14
test temp, pinn19 wz '15 Hat Down
if_z or button, butt15
if_nz andn button, butt15
test temp, pinn20 wz '16 Hat Left
if_z or button, butt16
if_nz andn button, butt16
xor outa, pinn21
'--------------------------------------------------------------------
xor outa, pinn25 'Pin 25 PHASE 2
waitcnt time,delay
mov temp, ina
test temp, pinn20 wz '1 Trigger
if_z or button, butt1
if_nz andn button, butt1
test temp, pinn19 wz '2 Secondary
if_z or button, butt2
if_nz andn button, butt2
test temp, pinn22 wz '3 Bottom Left
if_z or button, butt3
if_nz andn button, butt3
test temp, pinn23 wz '4 Bottom Right
if_z or button, butt4
if_nz andn button, butt4
xor outa, pinn25
'----------------------------------------------------------------------------------
xor outa, pinn24 'Pin 24 PHASE 3
waitcnt time,delay
mov temp, ina
test temp, pinn20 wz '5 Top Left
if_z or button, butt5
if_nz andn button, butt5
test temp, pinn19 wz '6 Top Right
if_z or button, butt6
if_nz andn button, butt6
xor outa, pinn24
'-------------------------------------------------------------------------------------
{{ xor outa, pinn10 'Pin 10 PHASE 4
waitcnt time,delay
mov temp, ina
test temp, pinn12 wz '7
if_z or button, butt7
if_nz andn button, butt7
test temp, pinn11 wz '8
if_z or button, butt8
if_nz andn button, butt8
xor outa, pinn10
'------------------------------------------------------------------------------------
xor outa, pinn15 'Pin 15 PHASE 5
waitcnt time,delay
mov temp, ina
test temp, pinn13 wz '9
if_z or button, butt9
if_nz andn button, butt9
test temp, pinn14 wz '10
if_z or button, butt10
if_nz andn button, butt10
test temp, pinn12 wz '11
if_z or button, butt11
if_nz andn button, butt11
test temp, pinn11 wz '12
if_z or button, butt12
if_nz andn button, butt12
xor outa, pinn15 }}
wrlong button, Mem
jmp #:Loop ' Check trigger again using :loop
button byte %000000000000000
shareds long %000000000000000
rudders long %000000000000000
ailerons long %000000000000000
elevators long %000000000000000
throttles long %000000000000000
delay long 5000
pinn21 long |< 21
'pinn10 long |< 10
pinn25 long |< 25
pinn24 long |< 24
'pinn15 long |< 15
'pinn17 long |< 17
pinn27 long |< 27
pinn20 long |< 20
pinn19 long |< 19
pinn22 long |< 22
pinn23 long |< 23
'pinn12 long |< 12
'pinn11 long |< 11
'pinn13 long |< 13
'pinn14 long |< 14
butt1 long |< 0
butt2 long |< 1
butt3 long |< 2
butt4 long |< 3
butt5 long |< 4
butt6 long |< 5
' butt7 long |< 6
' butt8 long |< 7
' butt9 long |< 8
' butt10 long |< 9
' butt11 long |< 10
' butt12 long |< 11
butt13 long |< 12
butt14 long |< 13
butt15 long |< 14
butt16 long |< 15
temp long 0
time Res 1
Mem Res 1

Comments
Andre'
{{ Keith Young Jan 30 2011 This assumes colors of wires are the same throughout the manufacturing history of this product. You may wish to check this so as to be sure you aren't connecting this bass ackwards. Joystick ----------------------------------------------------------------- Red ┼ Pin 19 and Pull Up 3.3V (I use 10Kohm) Green ┼ Pin 20 and Pull Up 3.3V White ┼ Pin 21 Yellow ┼ Pin 22 and Pull Up 3.3V Pink ┼ Pin 23 and Pull Up 3.3V Orange ┼ Pin 24 Grey ┼ Pin 25 Brown ┼ 3.3V Rudder Pot Black ┼ 1st Channel ADC Blue ┼ GND Red ┼ 3.3V Aileron Pot Green ┼ 2nd Channel ADC Elevator Pot White ┼ 3rd Channel ADC Black ┼ GND Joystick Base ------------------------------------------------------------ Orange ┼ Pin 15 Black ┼ Pin 14 and Pull Up 3.3V Brown ┼ Pin 13 and Pull Up 3.3V Grey ┼ Pin 12 and Pull Up 3.3V Pink ┼ Pin 11 and Pull Up 3.3V Yellow ┼ Pin 10 White ┼ GND Throttle Pot Green ┼ 4rth Channel ADC Red ┼ 3.3V }} CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 ADC_dpin = 1 ADC_cpin = 2 ADC_spin = 0 rudderc = 0 aileronc = 1 elevatorc = 2 throttlec = 3 OBJ AD : "MCP3208_fast_ADC" DB : "FullDuplexSerial" VAR long Shared word rudder, aileron, elevator, throttle long stack[256] PUB Start AD.Start(ADC_dpin, ADC_cpin, ADC_spin, 0) 'Start ADC DB.Start( 31, 30, 0, 57600) 'Start Parallax Serial Terminal communication cognew(@entry, @Shared) 'Begin running Assembly code cognew(Check_Act, @stack[0]) 'Check status of joystick and act Pub Check_Act dira[27]~~ outa[27]~ dira[26]~~ outa[26]~ repeat rudder := AD.In(rudderc) 'Get ADC value of Rudder aileron := AD.In(aileronc) 'Get ADC value of Aileron elevator := AD.In(elevatorc) 'Get ADC value of Elevator throttle := AD.In(throttlec) 'Get ADC value of Throttle DB.Dec(Shared) 'Display status of Buttons DB.Str(String(13)) DB.Dec(rudder) 'Display Rudder value DB.Str(String(13)) DB.Dec(aileron) 'Display Aileron value DB.Str(String(13)) DB.Dec(elevator) 'Display Elevator value DB.Str(String(13)) DB.Dec(throttle) 'Display Throttle value DB.Str(String(13)) if shared & butt1 == butt1 'Check if trigger is pulled. Trigger is Button 1 outa[27]~~ 'Turn on light if trigger is pulled else outa[27]~ if shared & butt13 == butt13 and shared & butt14 == butt14 outa[26]~~ 'If HAT switch is pushed forward and right else 'turn on a light outa[26]~ DAT ORG 0 entry mov Mem, PAR or dira,pinn21 or outa,pinn21 or dira,pinn25 or outa,pinn25 or dira,pinn24 or outa,pinn24 {{ or dira,pinn10 Un comment this area in order to use or outa,pinn10 the 6 buttons on the base of the or dira,pinn15 joystick and the throttle or outa,pinn15 or dira,pinn17 ALL AREAS OF CODE COMMENTED OUT BELOW CONTROL and outa,pinn17 JOYSTICK BASE. UNCOMMENT FOR THIS FUNCTION }} or dira,pinn27 and outa,pinn27 xor outa,pinn21 xor outa,pinn25 xor outa,pinn24 'xor outa,pinn10 'xor outa,pinn15 mov time,cnt 'Current clock loaded into time add time,delay 'delay added to time :Loop xor outa, pinn21 'Pin 21 PHASE 1 waitcnt time,delay mov temp, ina test temp, pinn23 wz '13 Hat Up if_z or button, butt13 if_nz andn button, butt13 test temp, pinn22 wz '14 Hat Right if_z or button, butt14 if_nz andn button, butt14 test temp, pinn19 wz '15 Hat Down if_z or button, butt15 if_nz andn button, butt15 test temp, pinn20 wz '16 Hat Left if_z or button, butt16 if_nz andn button, butt16 xor outa, pinn21 '-------------------------------------------------------------------- xor outa, pinn25 'Pin 25 PHASE 2 waitcnt time,delay mov temp, ina test temp, pinn20 wz '1 Trigger if_z or button, butt1 if_nz andn button, butt1 test temp, pinn19 wz '2 Secondary if_z or button, butt2 if_nz andn button, butt2 test temp, pinn22 wz '3 Bottom Left if_z or button, butt3 if_nz andn button, butt3 test temp, pinn23 wz '4 Bottom Right if_z or button, butt4 if_nz andn button, butt4 xor outa, pinn25 '---------------------------------------------------------------------------------- xor outa, pinn24 'Pin 24 PHASE 3 waitcnt time,delay mov temp, ina test temp, pinn20 wz '5 Top Left if_z or button, butt5 if_nz andn button, butt5 test temp, pinn19 wz '6 Top Right if_z or button, butt6 if_nz andn button, butt6 xor outa, pinn24 '------------------------------------------------------------------------------------- {{ xor outa, pinn10 'Pin 10 PHASE 4 waitcnt time,delay mov temp, ina test temp, pinn12 wz '7 if_z or button, butt7 if_nz andn button, butt7 test temp, pinn11 wz '8 if_z or button, butt8 if_nz andn button, butt8 xor outa, pinn10 '------------------------------------------------------------------------------------ xor outa, pinn15 'Pin 15 PHASE 5 waitcnt time,delay mov temp, ina test temp, pinn13 wz '9 if_z or button, butt9 if_nz andn button, butt9 test temp, pinn14 wz '10 if_z or button, butt10 if_nz andn button, butt10 test temp, pinn12 wz '11 if_z or button, butt11 if_nz andn button, butt11 test temp, pinn11 wz '12 if_z or button, butt12 if_nz andn button, butt12 xor outa, pinn15 }} wrlong button, Mem jmp #:Loop ' Check trigger again using :loop button byte %000000000000000 delay long 5000 pinn21 long |< 21 'pinn10 long |< 10 pinn25 long |< 25 pinn24 long |< 24 'pinn15 long |< 15 'pinn17 long |< 17 pinn27 long |< 27 pinn20 long |< 20 pinn19 long |< 19 pinn22 long |< 22 pinn23 long |< 23 'pinn12 long |< 12 'pinn11 long |< 11 'pinn13 long |< 13 'pinn14 long |< 14 butt1 long |< 0 butt2 long |< 1 butt3 long |< 2 butt4 long |< 3 butt5 long |< 4 butt6 long |< 5 ' butt7 long |< 6 ' butt8 long |< 7 ' butt9 long |< 8 ' butt10 long |< 9 ' butt11 long |< 10 ' butt12 long |< 11 butt13 long |< 12 butt14 long |< 13 butt15 long |< 14 butt16 long |< 15 temp long 0 time Res 1 Mem Res 1http://obex.parallax.com/objects/706/
I can assure you that this object can drive a servo location and it's speed, it can read any combination of its buttons, and read every axis when those functions are added. They just are not included in this demo at the moment. I don't want you to feel you may be paying $30.00 for a joystick that won't work.
I will likely make a YouTube Video shortly.
Please comment as this is my first OBEX upload, I'd like to be sure I'm not missing anything.
Anyone who already owns this type of joystick please test this. See if the instructions are clear and if you can get it working easily your first attempt.
Someone with more electronics experience may know for example if a different pull up resistor value is more optimal.
Nice Project. My other Hobby the more expensive one is flying RC 3D Heli's. I was wondering are you planing on flying a RC plane or something with your rig. I think that would be neat to fly a RC plane with that set up. Just curious. Going to check out the new Object.
-Ron
This joystick is fully hackable so you could use throttle for collective, and twist of the joystick for the tail collective. Plenty of buttons for all the channels on any plane. 16 buttons if I recall, plus I set it up so you can take any combination of those buttons.
But for general flight and motion control, even for Hydra games etc, this thing could be pretty cool. Plus with PWM etc it can be made to work on an Arduino or pretty much whatever someone happens to be using.