Jump to content
vitoco

USB adapter for CX controllers project. Ideas?

Recommended Posts

Hi!

 

I use Altirra to test the games I create, but I don't want to continue using the numeric keypad to emulate a joystick, or a mouse to emulate a paddle. I just want to use my original CX40 and CX30 controllers.

 

I know there are some adaptors out there, but I thought that it could be interesting to build one by myself using one of the small Arduinos compatibles I have at home, probably an ATmega32a4, which it can be used with the help of some libaries to manage the USB port and to build a gamepad HID.

 

As I want to use the same DB9 port to connect a joystick or a set of paddles, I got confused on how to read them from Altirra, because there is a conflict between the horizontal movement of the joystick and the horizontal movement of the paddle: the X axis of the gamepad is checked for both the linear value for a paddle and also for its trigger (left and right from the joystick).

 

I know I can map them differently and use POV axes for paddles, allowing all the pins to be read at the same time and map them to the selected (analog) sticks/buttons of the gamepad, and create a device profile in Altirra for all of them, but then I realized that it might not be compatible with other emulators.

 

Another idea that came into my mind was to manage only the pins for the connected controller and discard the others. It might be using a switch or just by detecting if paddles are connected and read only the related pins, and forcing to select for the right mapping in the emulator. Anyway, I don't know if there is a standard for paddles through a gamepad.

 

Which should be a good aproach to start this project? Is there a standard for paddles in emulators other than a mouse? Is there another project from where I could get some useful info?

 

Thanks in advance...

 

Share this post


Link to post
Share on other sites

There's PS1 adaptors as well as the ability to use XBox controllers so other emulators will tend to have support for them.

 

For my XBox One controller plugged into a USB port:

D-pad is seen as POV hat

Left analog seen as X/Y axis

Right analog seen as X/Y rotation

Bottom analog shoulder buttons seen as Z axis

Other buttons seen as numbered buttons.

 

I'd suggest for Atari controllers, see the stick directions as POV hat.

Also see stick left/right as seperate buttons since they're also fire for paddles.

See paddles as X/Y axis (would need to research existing convention since there are analog Atari sticks though we tend not to see them).

See stick fire button as a seperate button.

 

Maybe have DIPs or some means of changing the operating mode.

Other things you could also support/emulate:

- driving controller

- paddle emulating driving controller

- driving controller emulating paddle

- Atari ST mouse

- Amiga mouse

- ST/Amiga mouse emulating paddle

- 2600 keyboard controller

 

Share this post


Link to post
Share on other sites
On 5/30/2020 at 10:41 PM, Rybags said:

For my XBox One controller plugged into a USB port

Good idea. I'll check how other controls I have are seen by emulators.

 

I have only tried a standard GF USB control pad (G60305A), which it has two modes, and the sticks & buttons are presented differently on each mode.

 

On 5/30/2020 at 10:41 PM, Rybags said:

Maybe have DIPs or some means of changing the operating mode.

I thought about that, but I'm afraid I won't have enough pins in the ATmega32u4 module I'll use for this experiment: beetle badusb (diymore).

 

On 5/30/2020 at 10:41 PM, Rybags said:

Other things you could also support/emulate

I also have a CX80 track ball and a CX21 video touch pad. I'll think about this.

 

More hits or ideas?

 

On 5/30/2020 at 10:41 PM, Rybags said:

paddle emulating driving controller

😱 Poor paddle!!! It could better a trackball to emulate a driving controller.

 

On 5/30/2020 at 10:30 PM, ascrnet said:

emulate a normal joystick and Joy 2b+ with a micro arduino

Joy 2b+ is one reason not to detect paddles and disable joystick pins in the emulation. I guess that the same applies for CX21.

 

On 5/30/2020 at 10:30 PM, ascrnet said:

Here is a simple project, there is another way to leave it as a real pc joystick but you need to change the firmware of arduino

That's a nice project. It emulates a keyboard (WASD), not a gamepad, but it has interesting ideas inside it. Thanks!

 

Share this post


Link to post
Share on other sites

Mouse and trakball I think will be the same as the driving controller, though pin use and grey code sequence could be different.

But make or break for the non digital stuff is the DPI.  Too low and it's slow/cumbersome and too high makes it unusable.

Share this post


Link to post
Share on other sites

@ascrnet Which is the expected value from the PADDLE() function when buttons 2 and 3 are pressed in Joy2B+?

 

Edited by vitoco

Share this post


Link to post
Share on other sites
1 hour ago, vitoco said:

@ascrnet Which is the expected value from the PADDLE() function when buttons 2 and 3 are pressed in Joy2B+?

 

values 1 not pressed and 228 pressed for each paddle

 

Greetings

Share this post


Link to post
Share on other sites

I defined a special joystick HID with the following:

 

- 1 8-direction HAT (POV) for Joystick

- 8 buttons: STRIG(0), PTRIG(0), PTRIG(1), "reserved", and 4 bits for STICK(0)

- 2 analog axes for Paddles

 

All of this is working, and the stick is provided twice because the hat works with angular info (in degrees) and it is not possible to press both north and south at the same time. Then, the bits in the buttons 5 to 8 could be used to extend this adaptor for other type of devices that uses multiple bit combinations.

 

But I have some problems with the paddles... The data I capture is not linear, and I had to add a resistor in the circuit to read each of them through analog pins of the ATmega32u4. The problem is that I cannot find the best helper resistor for the circuit. Theory says something, but in the proto I get something different.

 

Is there someone with Arduino experience here? Have you played with pots? In particular, with pots that provides only 2 pins (like the paddles).

 

Share this post


Link to post
Share on other sites
3 hours ago, ascrnet said:

check this project there they do it with the paddles

 

https://www.hackster.io/dillon1337/transforming-atari-2600-controller-661443

:-o

The idea of that project was to build an hybrid between a joystick and a paddle with its own magnetic sensors, and put all of that inside a CX40 enclosure, which was modified to be able to change the stick with a knob for the desired control. BTW, at first, I though that it added a pot on top of the stick, in order to be used as a rotational joystick, but that was not the case. Anyway, that project was to provide a new controller for real Atari hardware, not for PCs with emulators.

 

My project goes in the other way: to provide a bridge for PCs with emulators to access original and unmodified controllers (because we always want to use them in real hardware when we have a chance).

 

But I got stuck with paddles. CX30 paddles uses a linear 1M ohm, and I have a pair in wich both controllers measure from 0 ohm at the full right position to around 800K ohm at the full left, with around 400K ohm in the middle of the way, confirmed that they behave in a linear way (under the 1000K ohm anyway).

 

Many experiments with pots in Arduino are very like this:

 

image.png.eb906f8d9fa301a36563999504c5a20a.png

 

You can see that the pot has 3 connections: 5V in one extreme, GND in the other extreme, and a the central connection to the analog pin. The main problem with Atari paddles is that the pot itself only has two connections of the above: 5V in one extreme and the central connection that goes to the POKEY chip, and there is no connection to the ground (GND). This pot configuration cannot be directly read by the Arduino, and I don't want to modify the paddles to be used in the PC... I just want stock paddles to be used with my adaptor.

 

Then, what can be done? Let's see how pots work in Arduino:

 

img7-300x232.jpg

 

This is the basics of a voltage divider, and the analog pin of the Arduino is getting a portion of the source voltage. Let's see the formula that applies here:

 

img2.jpg

 

When the point (2) in the diagram meets point (1), R1=0 and Vout=Vin*(R2/R2)=Vin. When the point (2) in the diagram meets point (3), R2=0 and Vout=Vin*(0/R1)=0. When the point (2) in the diagram is in the middle, R1=R2 and Vout=Vin*(R2/2*R2)=Vin/2. Totally linear, and that portion of the voltage (Vout/Vin) is converted to a 10 bits integer number (0 to 1023).

 

For the paddle, R1+R2=1M ohm, but only R1 can be seen through the paddle's connector. Then, how can I make the paddle work without GND connection at point (3)? Well, just add GND outside of the paddle with an additional resistor. I made something like this:

 

image.png.8499245f317237e0b6af1d1a67a6aaf9.png 

 

Now, R1+R2 won't be at a constant 1M omn as before, because R1 will be the variable value depending of the paddle current angle, and R2 won't be its complement but a constant. The problem is that Vout won't be linear, because denominator R1+R2 will be varying while the paddle knob moves.

 

In consecuence, Vout behaves logarithmically, and the analog pin digitizes that with a high resolution at one extreme of the knob turn and with low resolution at the other extreme. I tried to chop a range that behaves nearly lineal, but that happens in the side with low resolution (less than 228 different values in the range). The same happens when I try to apply a logarithmic transform to the value I got... some values are missing.

 

Now, I'm reading (and learning) more about electronics in order to solve this in the HW side. My latest HW project was about 30 years ago. Any help will be appreciated!!!

 

Disclaimer: I used some images from other sources and might be copyrighted by their authors.

 

Share this post


Link to post
Share on other sites

Hi Vitoco!

 

On 6/7/2020 at 8:47 PM, vitoco said:

 

Now, R1+R2 won't be at a constant 1M omn as before, because R1 will be the variable value depending of the paddle current angle, and R2 won't be its complement but a constant. The problem is that Vout won't be linear, because denominator R1+R2 will be varying while the paddle knob moves.

 

In consecuence, Vout behaves logarithmically, and the analog pin digitizes that with a high resolution at one extreme of the knob turn and with low resolution at the other extreme. I tried to chop a range that behaves nearly lineal, but that happens in the side with low resolution (less than 228 different values in the range). The same happens when I try to apply a logarithmic transform to the value I got... some values are missing.

 

Now, I'm reading (and learning) more about electronics in order to solve this in the HW side. My latest HW project was about 30 years ago. Any help will be appreciated!!!

 

Disclaimer: I used some images from other sources and might be copyrighted by their authors.

 

 

I'm slowly trying to read old forum messages - was very busy last weeks and it seems that other people are posting more than usual 😛

 

To read the resistance value of the pot you need to transform the resistance value to a voltage - for that you use a current source. See this ideal circuit:

 

image.png.4626243f6a98892f8fd9ad1332e0e7e9.png 

If you assume that there is no current to the Vout pin, the voltage is: Vout = I1 * R1. If you want the voltage at the arduino pin to be 3V when R1 is 1Mohm, you need a current of 3uA (3 micro-amps).

 

Now, for the difficult part, you need a current source!

 

Depending on the precision you want, you can go from using an OP-AMP (the most precise, but needs more components), to simply using a big resistor (super-easy, but not precise at all). A medium option is using a pair of transistors in what is called a Current Mirror:

 

image.png.3f8837e40670e2363a6b0408331147dd.png

 

Here, the current through R1 is always the same as the current through R4, and the current through R4 is calculated from the formula " I * R4 + 0.7V + I * R3 = 5V ", so that I = 4.3V/1010KOhm = 4.25uA. In fact, the output voltage will be Vout = (5V-0.7V)/(R4+R3) * R1.

 

R2 and R3 are only for stability, they can be replaced by a wire and the circuit will still work but will not be as precise.

 

Have Fun!

Share this post


Link to post
Share on other sites

As got extremely exponential readings in the Arduino Micro, I opened the paddle to get the 3 lines including GND and test it like in this:

 

On 6/7/2020 at 8:47 PM, vitoco said:

image.png.eb906f8d9fa301a36563999504c5a20a.png

 

Instead of direct soldering, I used a pair of alligator clips to hold the pot conectors, and a jumper wire as the third cable (I didn'h have another clip). The results: no linear reading as I suspected. It was still exponential.

 

I thought I might burn something inside the Micro, so I tried to compare the values to the readings from an Arduino Nano, but I accidentally touch the 5V pin with the jumper cable that was conected to GND and the Nano just shut down... forever! Argh! 😭

 

Now, I guess that both devices were damaged by my inexperience, and I have to suspend this project until I get new Arduinos.

 

In the meanwhile, I'll analyze dmsc's schemas in his previous post.

 

Share this post


Link to post
Share on other sites

Hi!

7 hours ago, vitoco said:

As got extremely exponential readings in the Arduino Micro, I opened the paddle to get the 3 lines including GND and test it like in this:

 

 

Instead of direct soldering, I used a pair of alligator clips to hold the pot conectors, and a jumper wire as the third cable (I didn'h have another clip). The results: no linear reading as I suspected. It was still exponential.

 

I thought I might burn something inside the Micro, so I tried to compare the values to the readings from an Arduino Nano, but I accidentally touch the 5V pin with the jumper cable that was conected to GND and the Nano just shut down... forever! Argh! 😭

 

Now, I guess that both devices were damaged by my inexperience, and I have to suspend this project until I get new Arduinos.

Well, here in Viña there are still a couple of open shops with Arduinos in stock 😛

 

But I found it strange that you managed to burn two Arduinos simply connecting the 5V to any input. And if you connected the 5V to GND, you could have blown a fuse or the regulator, so a repair could be simple.

 

7 hours ago, vitoco said:

zIn the meanwhile, I'll analyze dmsc's schemas in his previous post.

 

Well, the circuit can be very simple:

 

image.thumb.png.8530d7225bd01c072a89e038fdf45126.png

 

Have Fun!

 

Share this post


Link to post
Share on other sites

I had some free time to advance in my adapter, at the end I used Ardunino pro micro because I found a very good 3D case.

joy.thumb.png.5eedf1a71f12a9c1b5d04a5fba3976aa.png

 

I also used the ArduinoJoystickLibrary library to make Windows detect it as if it was a normal gamepad, for the moment I only made it for a standard joystick.

 

joy2.PNG.5baad77fdf89131158b256b7b88e011f.PNG

 

I was also checking the option to activate the paddles and I found this page that shows another connection idea.

 

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...