BBC joystick on PC (ANH01)

discuss both original and modern hardware for the bbc micro/electron
Post Reply
Alexkyriak
Posts: 10
Joined: Thu Nov 05, 2020 7:50 am
Contact:

BBC joystick on PC (ANH01)

Post by Alexkyriak »

Hi all, I have a set of analogue BBC joystick controllers type ANH01. I'd like to see if I can connect these to a PC and be used as an analogue control input. Is anyone able to advise how this can be achieved? Having looked around on the net I can't seem to find any product or bespoke solution. Any ideas anyone? Much appreciated :D
User avatar
tricky
Posts: 7706
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: BBC joystick on PC (ANH01)

Post by tricky »

It would require some re-wiring, which might have to be in the joystick!
You would also need something like the old sound cards with analogue input.
User avatar
1024MAK
Posts: 12788
Joined: Mon Apr 18, 2011 5:46 pm
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: BBC joystick on PC (ANH01)

Post by 1024MAK »

The analogue type joysticks used with BBC machines are a different type to that used on PCs / PC game cards.

The BBC system reads a 'steady' analogue voltage from the centre (moving contact) pin of a potentiometer (variable resistor)(three wire circuit). This arrangement creates a variable voltage between the positive reference voltage and 0V/GND. Inside the BBC there is a real analogue to digital converter that converts this voltage value to a digital number.

PC type joysticks instead use the potentiometer (variable resistor) in the joystick to form part of a timing circuit, where the variable resistance (two wire connection) determines how quickly a capacitor is charged or discharged. Hence the voltage is always changing. The system then times how long it takes for the state of charge on the capacitor to change. When the system reads the joystick position it does this again and again. This system is far cheaper, as there is no analogue to digital converter chip.

So internal wiring changes would be required, and this assumes that the values of the potentiometers are not too far from the required values.

Mark
Artemis
Posts: 47
Joined: Wed May 20, 2020 3:54 pm
Contact:

Re: BBC joystick on PC (ANH01)

Post by Artemis »

I have successfully used a BBC joystick (volt mace 14b) on a pc using an Arduino. The Arduino Leonardo series support being used as a usb HID. There are joystick, keyboard and mouse libraries that provide support for whatever combination of devices you wish.

I used the joystick and keyboard libraries to make use of all the buttons in the Voltmace and play Elite in BeebEm. I also tried the joystick in Elite Dangerous, but the control is not as fine as modern joysticks.

I can fish out the design and code tomorrow if you are interested.
Alexkyriak
Posts: 10
Joined: Thu Nov 05, 2020 7:50 am
Contact:

Re: BBC joystick on PC (ANH01)

Post by Alexkyriak »

Thanks all for the replies, very much appreciated. Also, it’s very interesting reading on the differences between the joystick types and the methodologies. Elite Dangerous is exactly why I wanted to try this! In addition to use on beebem of course.

I have tinkered once with arduino to make a button and analogue thumb stick input so Artemis yes would be very interested to see how you achieved this. Many thanks all 🙂
Artemis
Posts: 47
Joined: Wed May 20, 2020 3:54 pm
Contact:

Re: BBC joystick on PC (ANH01)

Post by Artemis »

OK, this Arduino project requires an ATMega32u4 chip, I used a Leonardo, there are other smaller Arduino boards that you could use.

I have attached two files, to have them open in the Arduino code editor change the extensions to .ino. The Delta14B file will implement a 12 button 2 axis joystick. The Delta14B-EliteKeypad file implements a 2 axis 1 button joystick, and scans the button matrix to press and release the chosen keys, which are held in the char keys[] array. (\0) means not used.

You will need two libraries in order to compile the code:
Keyboard by Arduino v. 1.0.2, which can be installed using the Manage Libraries window.
Joystick library by Matthew Heironimus, version 2.0.7 from https://github.com/MHeironimus/ArduinoJoystickLibrary

You will need to make up a 15 way standard density D type female connector with fly leads (see the photo). The wiring I used is:
15W Pin- Arduino Pin
1 -
2 - Digital 8
3 - Digital 7
4 - Digital 2
5 - Digital 6
6 - Digital 3
7 - Analog 1
8 - GND
9 -
10 - Digital 4
11 -
12 -
13 - Digital 5
14 - +5V
15 - Analog 0

On the Delta14B connector the keypad columns are on pins 2, 3 and 5; Rows are on pins 4, 6, 10 and 13. If you want to use different input pins on the Arduino then change the pin numbers in the code.
BBC to PC Joystick adapter.jpg
Attachments
Delta14B-EliteKeypad.txt
(3.51 KiB) Downloaded 40 times
Delta14B.txt
(2.21 KiB) Downloaded 50 times
Alexkyriak
Posts: 10
Joined: Thu Nov 05, 2020 7:50 am
Contact:

Re: BBC joystick on PC (ANH01)

Post by Alexkyriak »

Ah that’s brilliant Artemis, thank you so much. That looks to be within my skill set! Have made similar things before. Coding though, I don’t know that in any detail and will rely on the code you’ve provided. Will order a few parts and get cracking and will let you know! Sure to have some questions along the way. Cheers, very much appreciated. :)
Alexkyriak
Posts: 10
Joined: Thu Nov 05, 2020 7:50 am
Contact:

Re: BBC joystick on PC (ANH01)

Post by Alexkyriak »

Hi Artemis, so looking into this further now, a question. The BBC joystick volt mace 14b appears to be a single stick, whereas the ANH01 is a pair of analogue sticks connected to the same 15 port (and not all pins are used). So I am presuming that this may require a different wiring diagram and/or coding?

Image1234 by Alex Kyriak, on Flickr

ImageIMG_3603 by Alex Kyriak, on Flickr
Artemis
Posts: 47
Joined: Wed May 20, 2020 3:54 pm
Contact:

Re: BBC joystick on PC (ANH01)

Post by Artemis »

Hi, yes different wiring would be required, actually slightly simpler as you have only two buttons to handle even with the two extra analogue inputs.

The joystick library can create a number of devices, one of the supplied code examples creates four joysticks!

I will have a play over the weekend and do my best to come up with something that should work :D
Alexkyriak
Posts: 10
Joined: Thu Nov 05, 2020 7:50 am
Contact:

Re: BBC joystick on PC (ANH01)

Post by Alexkyriak »

Hi thanks Artemis that would be awesome. Much appreciated. I am assuming that it’s simply a case of determining which pins report the left stick (analogue plus one digital) and the others for right stick. I have never ‘reverse engineered’ a stick before so wouldn’t know how to go about this myself yet. Cheers :)

Edit: found this: https://deskthority.net/wiki/BBC_Micro_analogue_in
Artemis
Posts: 47
Joined: Wed May 20, 2020 3:54 pm
Contact:

Re: BBC joystick on PC (ANH01)

Post by Artemis »

Hi Alexkyriak

Yes, that page is a very good place to start as it shows the wiring for a pair of joysticks. The Acorn dual joysticks should be wired up just like that. Anyway I have come up with connector wiring and a program for the Arduino Leonardo that should work. I can't completely test it as I don't have two joysticks, but my voltmace joystick works fine as joystick 1 and the second joystick is just a mirror of the first so you should be OK.

Here's the wiring you will need ...
Wiring diagram.png
... and this program will give you two joystick devices (change extension to .ino)
DualJoysticks.c
(2.21 KiB) Downloaded 46 times
Once you have everything hooked up and programmed check functionality in Windows game controller settings, and you should be good to go!

Best of luck,
Artemis.
Alexkyriak
Posts: 10
Joined: Thu Nov 05, 2020 7:50 am
Contact:

Re: BBC joystick on PC (ANH01)

Post by Alexkyriak »

That’s amazing Artemis, thank you so much. Waiting for a dsub to arrive and I can get cracking.

One thing puzzles me is why I have three pins missing. See my photo above. I have examined the plug and it doesn’t look ‘broken’, the plastic there looks flush with three small circles where pins might go, but the plastic was molded without actual apertures - ie, it looks deliberate. When you look at it end on it’s the three left hand 'pins', as per the photo.

On your diagram it implies 1, 2, and 9 are not used but looks mirrored to my photo - unless it’s a diagram from the computer port perspective. The link I found implies all pins are used (I think) - unless this is simply showing the port on the bbc itself, in which case it make perfect sense.

Bit puzzled by this and don’t have a bbc to connect to to test the sticks right now to see how it was meant to operate originally.

Once again, really appreciate your help. Will keep you posted. :)

Alex
Artemis
Posts: 47
Joined: Wed May 20, 2020 3:54 pm
Contact:

Re: BBC joystick on PC (ANH01)

Post by Artemis »

The missing pins are extra +5v, 0v and the light pen strobe input to the 6845, not needed on the joystick so no pins were fitted when manufactured.

When you make up the d sub connector follow the pin numbering, I just threw the diagram together and didn’t give much thought to what the back of the connector would look like #-o

EDIT: diagram looking at the back of the D-sub socket
Wiring diagram 2.png
Last edited by Artemis on Tue Nov 17, 2020 1:01 pm, edited 1 time in total.
User avatar
1024MAK
Posts: 12788
Joined: Mon Apr 18, 2011 5:46 pm
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: BBC joystick on PC (ANH01)

Post by 1024MAK »

15 way D plug PIN numbering
15 way D plug PIN numbering
Mark
Alexkyriak
Posts: 10
Joined: Thu Nov 05, 2020 7:50 am
Contact:

Re: BBC joystick on PC (ANH01)

Post by Alexkyriak »

Thanks both for the plug pin numbering and diagrams confirmation.
Alexkyriak
Posts: 10
Joined: Thu Nov 05, 2020 7:50 am
Contact:

Re: BBC joystick on PC (ANH01)

Post by Alexkyriak »

Hi Artemis, I have tried using the code file you so kindly provided, however I am getting this error message when compiling the sketch, and can't solve it. I am basically a total beginner with this, although I did set up something similar years ago.

Here is the error, any ideas you may be able to help me with? Many thanks. Am I supposed to input 0x03 and 0x04 somewhere?




DualJoysticks:6:20: error: 'JOYSTICK_TYPE_JOYSTICK' was not declared in this scope

JOYSTICK_TYPE_JOYSTICK,

^~~~~~~~~~~~~~~~~~~~~~

DualJoysticks:20:20: error: 'JOYSTICK_TYPE_JOYSTICK' was not declared in this scope

JOYSTICK_TYPE_JOYSTICK,

^~~~~~~~~~~~~~~~~~~~~~

exit status 1

'JOYSTICK_TYPE_JOYSTICK' was not declared in this scope
Artemis
Posts: 47
Joined: Wed May 20, 2020 3:54 pm
Contact:

Re: BBC joystick on PC (ANH01)

Post by Artemis »

Hi Alex,

A couple of things spring to mind, check that you have selected the correct model of Arduino in the Tools> Board menu. The other is make sure you have included the joystick library by loading it from the Sketch> Include Library> Add ZIP Library option.
Alexkyriak
Posts: 10
Joined: Thu Nov 05, 2020 7:50 am
Contact:

Re: BBC joystick on PC (ANH01)

Post by Alexkyriak »

Thanks Artemis, much appreciated. think I have correct board set, and added the library using the method you stated, now get this error when I try to Upload:



DualJoysticks:6:20: error: 'JOYSTICK_TYPE_JOYSTICK' was not declared in this scope

JOYSTICK_TYPE_JOYSTICK,

^~~~~~~~~~~~~~~~~~~~~~

DualJoysticks:20:20: error: 'JOYSTICK_TYPE_JOYSTICK' was not declared in this scope

JOYSTICK_TYPE_JOYSTICK,

^~~~~~~~~~~~~~~~~~~~~~

exit status 1

'JOYSTICK_TYPE_JOYSTICK' was not declared in this scope

Invalid library found in C:\Users\AlexKyriak\Documents\Arduino\libraries\libraries: no headers files (.h) found in C:\Users\AlexKyriak\Documents\Arduino\libraries\libraries



And I get this message when I try to verify/compile:



DualJoysticks:6:20: error: 'JOYSTICK_TYPE_JOYSTICK' was not declared in this scope

JOYSTICK_TYPE_JOYSTICK,

^~~~~~~~~~~~~~~~~~~~~~

DualJoysticks:20:20: error: 'JOYSTICK_TYPE_JOYSTICK' was not declared in this scope

JOYSTICK_TYPE_JOYSTICK,

^~~~~~~~~~~~~~~~~~~~~~

exit status 1

'JOYSTICK_TYPE_JOYSTICK' was not declared in this scope


Feels like I'm so close! Not sure how to solve this though. Do I need to edit the joystick.h file in some way?
Artemis
Posts: 47
Joined: Wed May 20, 2020 3:54 pm
Contact:

Re: BBC joystick on PC (ANH01)

Post by Artemis »

I think you should try and compile any of the examples that come with the joystick library, this should prove if your Arduino IDE is set up correctly.

On the File menu select Examples and then way down the bottom of the menu you should find Joystick listed and the examples are there. DrivingControllerTest is the first one. You don't need to upload it to your board, just see if it compiles without error.

If that works try creating a new Sketch and then pasting all the text from the code I supplied into the window, to replace the default void setup() and void loop(). Save this to a new location and then try to compile again.
Alexkyriak
Posts: 10
Joined: Thu Nov 05, 2020 7:50 am
Contact:

Re: BBC joystick on PC (ANH01)

Post by Alexkyriak »

Thanks, this return this error message. I think I have some other file incorrectly set up somewhere. Do I need a particular Joystick.h file, or do I have to amend this? Are these error messages generated because the example .ino file is asking for references in the joystick.h file?



Arduino: 1.8.13 (Windows 7), Board: "Arduino Leonardo"



DrivingControllerTest:11:20: error: 'JOYSTICK_DEFAULT_REPORT_ID' was not declared in this scope

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,

^~~~~~~~~~~~~~~~~~~~~~~~~~

DrivingControllerTest:12:3: error: 'JOYSTICK_TYPE_MULTI_AXIS' was not declared in this scope

JOYSTICK_TYPE_MULTI_AXIS, 4, 0,

^~~~~~~~~~~~~~~~~~~~~~~~

C:\Program Files (x86)\Arduino\examples\DrivingControllerTest\DrivingControllerTest.ino:12:3: note: suggested alternative: 'JOYSTICK_TYPE_JOYSTICK'

JOYSTICK_TYPE_MULTI_AXIS, 4, 0,

^~~~~~~~~~~~~~~~~~~~~~~~

JOYSTICK_TYPE_JOYSTICK

C:\Program Files (x86)\Arduino\examples\DrivingControllerTest\DrivingControllerTest.ino: In function 'void testAcceleratorBrake(int)':

DrivingControllerTest:71:12: error: 'class Joystick_' has no member named 'setAccelerator'

Joystick.setAccelerator(value);

^~~~~~~~~~~~~~

DrivingControllerTest:72:12: error: 'class Joystick_' has no member named 'setBrake'

Joystick.setBrake(260 - value);

^~~~~~~~

C:\Program Files (x86)\Arduino\examples\DrivingControllerTest\DrivingControllerTest.ino: In function 'void testSteering(int)':

DrivingControllerTest:78:14: error: 'class Joystick_' has no member named 'setSteering'

Joystick.setSteering(value);

^~~~~~~~~~~

DrivingControllerTest:80:14: error: 'class Joystick_' has no member named 'setSteering'

Joystick.setSteering(600 - value);

^~~~~~~~~~~

C:\Program Files (x86)\Arduino\examples\DrivingControllerTest\DrivingControllerTest.ino: In function 'void setup()':

DrivingControllerTest:86:12: error: 'class Joystick_' has no member named 'setAcceleratorRange'

Joystick.setAcceleratorRange(0, 260);

^~~~~~~~~~~~~~~~~~~

DrivingControllerTest:87:12: error: 'class Joystick_' has no member named 'setBrakeRange'

Joystick.setBrakeRange(0, 260);

^~~~~~~~~~~~~

DrivingControllerTest:88:12: error: 'class Joystick_' has no member named 'setSteeringRange'

Joystick.setSteeringRange(0, 300);

^~~~~~~~~~~~~~~~

Multiple libraries were found for "Joystick.h"

Used: C:\Users\AlexKyriak\Documents\Arduino\libraries\joystick

Not used: C:\Users\AlexKyriak\Documents\Arduino\libraries\ArduinoJoystickLibrary-master

exit status 1

'JOYSTICK_DEFAULT_REPORT_ID' was not declared in this scope



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Last edited by Alexkyriak on Sun Nov 29, 2020 12:46 pm, edited 1 time in total.
Artemis
Posts: 47
Joined: Wed May 20, 2020 3:54 pm
Contact:

Re: BBC joystick on PC (ANH01)

Post by Artemis »

I think I can see the problem, you have two joystick libraries loaded, the error message in your logging below shows the problem.
Multiple libraries were found for "Joystick.h"

Used: C:\Users\AlexKyriak\Documents\Arduino\libraries\joystick

Not used: C:\Users\AlexKyriak\Documents\Arduino\libraries\ArduinoJoystickLibrary-master
You need to remove the C:\Users\AlexKyriak\Documents\Arduino\libraries\joystick folder to get rid of the conflict, or move the folder elsewhere to a temporary folder, just not in the libraries folder.
Post Reply

Return to “8-bit acorn hardware”