• Please review our updated Terms and Rules here
  • Exhibitor application for VCF West 2022 is now open! If you are interested in exhibiting, please fill out the form here.

Joystick problem?

EvanK

VCFed Founder
Joined
Aug 14, 2003
Messages
1,017
Location
New Jersey
I'm using the Apple joystick A2M2002.

Ran this test program:

10 X=PDL(0):Y=PDL(1)
20 PRINT X,Y
30 GOTO 10

The four corners report correctly (0,0; 0,255; 255,0; 255,255) but when the joystick centers it shows 130,89. If I adjust the trim knobs then the corners would be wrong.

How do I fix this?
 

roberttx

Veteran Member
Joined
Aug 6, 2015
Messages
1,130
Location
Texas
The four corners report correctly (0,0; 0,255; 255,0; 255,255) but when the joystick centers it shows 130,89. If I adjust the trim knobs then the corners would be wrong.

Although I recently got an Apple joystick, I've yet to play with it, so the following might be utter nonsense. Nevertheless, would they necessarily be wrong? When it's in a corner, is it tracking position the same way as it does elsewhere, or simply reporting that it's at the extreme positions?

Also, thanks for the program - I'll use it to test mine, when I have time.
 

KC9UDX

Space Commander
Joined
Jan 27, 2014
Messages
7,468
Location
Lutenblag
Welcome to the world of analogue joysticks. This is why they aren't used much.

Your results don't necessarily indicate a problem. But you might be able to improve your numbers by replacing the pots. Or you might need to redesign the joystick mechanically or electrically.
 

roberttx

Veteran Member
Joined
Aug 6, 2015
Messages
1,130
Location
Texas
But you might be able to improve your numbers by replacing the pots.

That reminds me of something that I meant to mention, but failed to do so. How about giving the pots a shot of DeOxit, or similar?
 

EvanK

VCFed Founder
Joined
Aug 14, 2003
Messages
1,017
Location
New Jersey
Mike Willegal suggested putting a delay in line 30 between checking each paddle. That fixed it! Now it works without line 70 or any other of the software correction methods that I thought were needed.

The simplified program:

10 GR:COLOR=2
20 PLOT 10,10
30 X=PDL(0):FOR W=1 TO 25:NEXT W:Y=PDL(1)
40 X=X/6.4:Y=Y/6.4
50 PLOT X,Y:pRINT INT(X),INT(Y)
60 FOR W=1 TO 50: NEXT W
70 COLOR=0:pLOT X,Y:COLOR=2
80 GOTO 30

Hi-res version:

10 HGR:COLOR=2
20 HPLOT 10,10
30 X=PDL(0):FOR W=1 TO 25:NEXT W:Y=PDL(1)
40 X=X/6.4:Y=Y/6.4
50 PLOT X,Y:pRINT INT(X),INT(Y)
60 FOR W=1 TO 50: NEXT W
70 COLOR=0:pLOT X,Y:COLOR=2
80 GOTO 30

This is a proof-of-concept for me. I'm making a game where you drive a (physical) Lego robot, powered by the 1980s Lego / Apple II kit, to avoid (or maybe capture!) on-screen obstacles. Limiting it to BASIC even though assembly is "better" because A.) I want to demo this to kids in the VCFed museum, and B.) I never learned assembly.
 
Last edited:

EvanK

VCFed Founder
Joined
Aug 14, 2003
Messages
1,017
Location
New Jersey
Update -- line 30 still works rock-solid with a delay of FOR W=1 TO 1 ... not a typo! But when I remove the delay the problem returns. So, that single speck of delay is all that's needed. Good to know for future programs.
 

KC9UDX

Space Commander
Joined
Jan 27, 2014
Messages
7,468
Location
Lutenblag
That reminds me of something that I meant to mention, but failed to do so. How about giving the pots a shot of DeOxit, or similar?

That would clean up noise and dead spots, but not improve linearity.

Apparently though in this case (as in most) the amount of error in the joystick itself is within range of what's expected.

I was thinking about the crude way the Apple samples the pots, but didn't recall needing an additional software delay. But apparently that's the case, which is good to know.
 

roberttx

Veteran Member
Joined
Aug 6, 2015
Messages
1,130
Location
Texas
I was thinking about the crude way the Apple samples the pots, but didn't recall needing an additional software delay. But apparently that's the case, which is good to know.

Indeed it is. Now if Evan can only be persuaded to turn his game into a real life version of Robot Finds Kitten, we'll be all set.
 

EvanK

VCFed Founder
Joined
Aug 14, 2003
Messages
1,017
Location
New Jersey
Indeed it is. Now if Evan can only be persuaded to turn his game into a real life version of Robot Finds Kitten, we'll be all set.

I did see a stray at our museum campus last week and took to calling it Floppy Diskcat. :) (Other possibilities were Canon Cat, Cat 5, Catweasel, and Novaton Cat) ... but we certainly wouldn't let it in the museum, nor let the robot out!

As for the game version, I'll have to think about it .....
 

EvanK

VCFed Founder
Joined
Aug 14, 2003
Messages
1,017
Location
New Jersey
Dan R. aka "Ragooman" here on the forum showed me a way to make the joystick-controlled point stop flickering. Basically it keeps checking to see if you moved the joystick, and if not (if the coordinates are the same since last time it checked) then it doesn't redraw. It is easier on the eyes now: https://tinyurl.com/l5yzfc7

Ps. After making the video I changed the target point to be white instead of blue. Easier to see.
 
Last edited:

KC9UDX

Space Commander
Joined
Jan 27, 2014
Messages
7,468
Location
Lutenblag
It's little things like that which can be a real liability in BASIC.

Sooner or later you end up including small bits of machine language in your BASIC programs. Fortunately this is pretty trivial to do on the Apple.
 
Top