Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: mini outrun arcade built from scratch wheel question  (Read 2047 times)

0 Members and 1 Guest are viewing this topic.

oatcakeandy

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 9
  • Last login:December 21, 2023, 05:29:26 pm
  • I want to build my own arcade controls!
mini outrun arcade built from scratch wheel question
« on: April 06, 2023, 10:11:48 am »
Hi all, i watched a vid the other day from a user down below who moded a mini racer to play outrun, this got me thinking of my next scale project, either a scale sitdown or standup Outrun cab, i have already done pacman, dragons lair and i have the woodworking / 3d printing skills down but i'm struggling to get my head around making the  steering wheel electronics . i have seen potentiometers, rotary encoders, pico boards, but i conna get me head how to connect this to the raspberry pi i'll be using and also getting Retropie to interpret the signals. Am i over thinking things ?
is it as easy as connecting up a pot/encoder to a zero delay board and switching it into analogue mode ? or even hacking a 360 controller and replacing the thumb controllers with pots??
ANY help would be very much appreciated.

Thanks

Andy

PL1

  • Global Moderator
  • Trade Count: (+1)
  • Full Member
  • *****
  • Online Online
  • Posts: 9399
  • Last login:Today at 05:03:17 pm
  • Designated spam hunter
Re: mini outrun arcade built from scratch wheel question
« Reply #1 on: April 06, 2023, 12:40:23 pm »
Hi all, i watched a vid the other day from a user down below who moded a mini racer to play outrun
I'm guessing you're referring to MrThunderwing's mini build in the Driving & Racing sub-forum.

http://forum.arcadecontrols.com/index.php/topic,167412.0.html



this got me thinking of my next scale project, either a scale sitdown or standup Outrun cab, i have already done pacman, dragons lair and i have the woodworking / 3d printing skills down but i'm struggling to get my head around making the  steering wheel electronics . i have seen potentiometers, rotary encoders, pico boards, but i conna get me head how to connect this to the raspberry pi i'll be using and also getting Retropie to interpret the signals. Am i over thinking things ?
is it as easy as connecting up a pot/encoder to a zero delay board and switching it into analogue mode ? or even hacking a 360 controller and replacing the thumb controllers with pots??
In MrThunderwing's case, he used a ZD encoder he already had with the leaf switches on the PCB for steering.
- Makes sense that he used the leaf switches since the cab, wheel, and PCB were designed around them and there's a limited range of motion with the wheel so a potentiometer or rotary encoder is not as good a choice.



In your case, I'd recommend using an Arduino Pro Micro instead of an analog-capable ZD or hacking a 360 controller.
- Low cost.
- Plenty of input ports.
- Avoids possible problem with switching the ZD to analog mode -- not sure if the ZD stays in analog mode after power loss.   :dunno
- Smaller than the ZD encoder.
- Plugs into USB on the RasPi.
- Firmwares are available for switches (HID keyboard or HID gamepad), rotary encoders (HID mouse or HID mouse/keyboard composite), or potentiometers (HID analog gamepad) so the Pro Micro will work with whatever input type you choose to use.


Scott
« Last Edit: April 06, 2023, 12:58:29 pm by PL1 »

oatcakeandy

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 9
  • Last login:December 21, 2023, 05:29:26 pm
  • I want to build my own arcade controls!
Re: mini outrun arcade built from scratch wheel question
« Reply #2 on: April 06, 2023, 12:54:47 pm »
Brilliant mate, thanks.
i'll have a look at that now

Andy

PL1

  • Global Moderator
  • Trade Count: (+1)
  • Full Member
  • *****
  • Online Online
  • Posts: 9399
  • Last login:Today at 05:03:17 pm
  • Designated spam hunter
Re: mini outrun arcade built from scratch wheel question
« Reply #3 on: April 06, 2023, 12:59:36 pm »
Forgot to mention that you could avoid the Pro Micro, ZD, or 360 gamepad hack if you wire the PCB shown above directly to the RasPi GPIO pins and you know how to configure those pins as inputs.


Scott

oatcakeandy

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 9
  • Last login:December 21, 2023, 05:29:26 pm
  • I want to build my own arcade controls!
Re: mini outrun arcade built from scratch wheel question
« Reply #4 on: April 06, 2023, 05:03:45 pm »
am i right in thinking once the pro micro has been programmed i can connect it via usb to the raspberry pi and it would recognise it as an input device or would it be better to output to the gpio pins on the pi ?

thanks

Andy

PL1

  • Global Moderator
  • Trade Count: (+1)
  • Full Member
  • *****
  • Online Online
  • Posts: 9399
  • Last login:Today at 05:03:17 pm
  • Designated spam hunter
Re: mini outrun arcade built from scratch wheel question
« Reply #5 on: April 06, 2023, 06:19:32 pm »
am i right in thinking once the pro micro has been programmed i can connect it via usb to the raspberry pi and it would recognise it as an input device
Yes, if you use the right sketch/firmware.

The "HID" description I used earlier stands for "Human Interface Devices".
- When you plug a HID into your computer, the computer sees it as a keyboard, mouse, gamepad, or composite device. (i.e. keyboard + mouse, two gamepads, etc.)

The Leonardo series of Arduinos, which includes the Pro Micro, are designed to be easily used as a HID that works with the default drivers in your Linux or Windows operating system.

would it be better to output to the gpio pins on the pi ?
Pro:
- You don't need the Pro Micro to act as the encoder.

Con:
- You need to know how to use the GPIO pins as inputs.  I know it can be done, but can't help you much with the process and/or code.
- Not sure how much lag, if any, you'll have with this setup.   :dunno

Based on the questions you're asking, it would probably be easier for you to use the Pro Micro approach.


Scott

oatcakeandy

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 9
  • Last login:December 21, 2023, 05:29:26 pm
  • I want to build my own arcade controls!
Re: mini outrun arcade built from scratch wheel question
« Reply #6 on: April 07, 2023, 01:52:07 pm »
Thanks for the help mate..I'll let you know how I get on and hopefully show the final build.

oatcakeandy

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 9
  • Last login:December 21, 2023, 05:29:26 pm
  • I want to build my own arcade controls!
Re: mini outrun arcade built from scratch wheel question
« Reply #7 on: April 14, 2023, 06:07:47 am »
hi, me again.
im struggling with some of the code still.
i've amended some code i found on the net which had what i was looking for, pretty straightforward, nothing too complicated, i can get a pc to recognise the board and all inputs respond as should, however when its plugged into an rpi400 ( i have found that the board will only get recognised on usb3 input and an rpi400 is all i have at the minute) and go through the controller setup the buttons are accepted but not the potentiometer, sometimes only get Axis0- but never Axis 0+.
i then run Jstest-gtk which again sees all inputs and responds to the pot as should.
Any help would be most appreciated, i feel im going in circles.

this is the code i have been using....


//Arduino Joystick 2.0 Library, by MHeironimus (https://github.com/MHeironimus)
//Beginners Guide, by Daniel Cantore
//Example Code (Oct 2020), with in-depth commenting

//Initial Definitions and Setup
//Libary Inclusion
#include <Joystick.h>

//Define and Allocate Input Pins to memorable names
#define joyX A0
#define joyButton1 2
#define joyButton2 3
#define joyButton3 4
#define joyButton4 5
#define joyButton5 8
#define joyButton6 7

//Initializing Axis as Integers, at a 0 default value
int xAxis_ = 0;

//Setting up Buttons
//Updating a static variable gives greater stability than reading directly from the digital pin.
//Giving Default Values to the Buttons for later use
  int lastButton1State = 0;
  int lastButton2State = 0;
  int lastButton3State = 0;
  int lastButton4State = 0;
  int lastButton5State = 0;
  int lastButton6State = 0;

//Defining the Joystick
//The Joystick is defined in the following setup:
//Joystick(Joystick HID ID, Joystick Type, Button Count, Hat Switch Count, Include X, Include Y, Include Z, Include Rx, Include Ry, Include Rz, Include Rudder, Include Throttle, Include Accelerator, Include Brake, Include Steering
//Joystick HID ID: A Hex value identifier for HID Device Recognition (default: 0x03). DO NOT USE 0x01 or 0x02
//Joystick type: Define the type of joystick from the types supported. Types: DEFAULT Joystick (0x04 or JOYSTICK_TYPE_JOYSTICK), Gamepad (0x05 or JOYSTICK_TYPE_GAMEPAD), Multi-Axis Controller (0x08 or JOYSTICK_TYPE_MULTI_AXIS)
//Button Count: Number of Buttons shown to HID system (default: 32)
//Hat Switch Count: Number of Hat Switches, max 2. (default:2)
//Include X Axis: Determines whether the X axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Y Axis: Determines whether the Y axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Z Axis: Determines whether the Z axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Rx Axis: Determines whether the X Rotational axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Ry Axis: Determines whether the Y Rotational axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Rz Axis: Determines whether the Z Rotational axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Rudder: Determines whether a Rudder axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Throttle: Determines whether a Throttle axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Accelerator: Determines whether an Accelerator axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Brake: Determines whether a Brake axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Steering: Determines whether a Steering axis is avalible for used by the HID system, defined as a bool value (default:true)

Joystick_ Joystick(0x12, JOYSTICK_TYPE_JOYSTICK, 6, 0,true,false,false,false,false,false,false,false,false,false,false);

//Set Auto Send State
//Enables Auto Sending, allowing the controller to send information to the HID system, rather than waiting to be asked.
const bool initAutoSendState = true;

void setup() {
  //Initialize Buttons
  //Buttons set up between Digital Pin and Ground, following pin allocations from earlier on
  pinMode(joyButton1, INPUT_PULLUP);
  pinMode(joyButton2, INPUT_PULLUP);
  pinMode(joyButton3, INPUT_PULLUP);
  pinMode(joyButton4, INPUT_PULLUP);
  pinMode(joyButton5, INPUT_PULLUP);
  pinMode(joyButton6, INPUT_PULLUP);


  //Start Joystick - Needed to start the Joystick function libary
  Joystick.begin();
}

void loop() {
 
  //Axis Reading during Runtime
  //Setting Read functions for each axis and parsing correctly. The X axis will be used as an example for explanation

  //Reading the X Axis analog pin to the xAxis_ variable for processing
  xAxis_ = analogRead(joyX);
  //Mapping the X Axis data from a 0-1023 to 0-255 range for a smoother action
  xAxis_ = map(xAxis_,0,1023,0,255);
  //Set the Joystick X Axis value as the new, smoother, value
  Joystick.setXAxis(xAxis_);

 
  //Button Reading during Runtime
  //Setting Read functions for each button, using a state value for memory. Button 1 will be used as an example for explanation

  //Reading the current Button digital pin to the Current Button State for processing
 
  int currentButton1State = !digitalRead(joyButton1);
  //If loop - Check that the button has actually changed.
  if (currentButton1State != lastButton1State){
    //If the button has changed, set the specified HID button to the Current Button State
    Joystick.setButton(0, currentButton1State);
    //Update the Stored Button State
    lastButton1State = currentButton1State;
  }

    int currentButton2State = !digitalRead(joyButton2);
  if (currentButton2State != lastButton2State){
    Joystick.setButton(1, currentButton2State);
    lastButton2State = currentButton2State;
  }
    int currentButton3State = !digitalRead(joyButton3);
  if (currentButton3State != lastButton3State){
    Joystick.setButton(2, currentButton3State);
    lastButton3State = currentButton3State;
  }
  int currentButton4State = !digitalRead(joyButton4);
  if (currentButton4State != lastButton4State){
    Joystick.setButton(3, currentButton4State);
    lastButton4State = currentButton4State;
  }

    int currentButton5State = !digitalRead(joyButton5);
  if (currentButton5State != lastButton5State){
    Joystick.setButton(4, currentButton5State);
    lastButton5State = currentButton5State;
  }
    int currentButton6State = !digitalRead(joyButton6);
  if (currentButton6State != lastButton6State){
    Joystick.setButton(5, currentButton6State);
    lastButton6State = currentButton6State;
  }

//Pole Delay/Debounce
//To reduce unessecary processing, the frequency of the reading loop is delayed. The value(in ms) can be changed to match requirement
delay(10);
}


oatcakeandy

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 9
  • Last login:December 21, 2023, 05:29:26 pm
  • I want to build my own arcade controls!
Re: mini outrun arcade built from scratch wheel question
« Reply #8 on: April 14, 2023, 12:14:16 pm »
Quick update.

i've followed this site and got something cobbled together and working

https://www.instructables.com/Zero-Delay-USB-Encoder-True-Analog-Joystick-Modifi/

However, i'd still like to know why i conna get the arduino to work for future builds and my sanity

Andy.

MrThunderwing

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1054
  • Last login:Yesterday at 03:30:55 pm
  • As I pass, do I give you the ass or the crotch?
Re: mini outrun arcade built from scratch wheel question
« Reply #9 on: April 16, 2023, 07:27:13 am »
I'm keeping an eye on this thread, be interested to see how it all turns out 👍

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:March 22, 2024, 12:55:20 am
  • Is running at 15kHz
Re: mini outrun arcade built from scratch wheel question
« Reply #10 on: April 17, 2023, 01:49:44 am »
I would recommend using Daemonbite's USB arcade encoder code - https://github.com/MickGyver/DaemonBite-Arcade-Encoder

oatcakeandy

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 9
  • Last login:December 21, 2023, 05:29:26 pm
  • I want to build my own arcade controls!
Re: mini outrun arcade built from scratch wheel question
« Reply #11 on: April 20, 2023, 04:37:09 pm »
thanks, i've seen this one whilst trawling. i'll give it a go.


oatcakeandy

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 9
  • Last login:December 21, 2023, 05:29:26 pm
  • I want to build my own arcade controls!
Re: mini outrun arcade built from scratch wheel question
« Reply #12 on: June 23, 2023, 01:30:13 pm »
Me again. ive finally finished it. It's taken a while with work and a few days of getting out in the sun but i've finally got it working.
i used a moded zero delay encoder, I still couldn't get the arduino to work with Botocera or retropie only in a windows environment.
Its running the Cannonball version of Outrun and it plays really well if not extremely fiddly pressing the pedals with one hand and steering with the other.
think its turned out really well and now onto the next build.
Andy