Quantcast

Page 1 of 2 12 LastLast
Results 1 to 15 of 29

Thread: Wireless Gamepad

  1. #1
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    206
    Rep Power
    11

    Genesis Wireless Gamepad

    I am going to build my own wireless mega drive/genesis gamepad's using an Arduino Pro Mini and nRF24L01+ module with build-in battery charger. In this thread i will keep a log of my progress and if anyone would like to help out that would be great.

    I do have a working Wireless SNES controller prototype, just to give an indication of the state of my project. I started that project about 8 years ago when i had never heard of Arduino before and had to work with PIC basic , which made me abandon the project. Until a few weeks ago i found these really cheap Arduino Pro Mini's and nRF24L01+ modules. That combo cost me only about $8.30 for the gamepad and $11.52 for the receiver (not including the LiPo battery, charger and 3v3 power regulator, wires, hotglue, mini-usb connector, time)

    Yesterday i started a thread in the Insert Coin section but i think this is a better place since it's going to be technical
    Learning the genesis one bit at a time

  2. #2
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    206
    Rep Power
    11

    Default

    I just opened up one of my controllers to look around to see how everything could fit inside. It's amazing how much empty space there is inside this controller. At least i will have no problem fitting the parts inside as much as i had with the SNES controller. I have not yet decided if i am going to read the buttons through the IC or remove it and wire them directly to the Arduino pins. Removing the chip means a lot more work but it might save a few mAh's, but given the amount of space there is inside i could just fit a bigger battery. The other components can be placed almost anywhere i want, except where the IC and resitors are. It's a bit of a shame there is a big square hole where the wire used to go out, makes the LED look a bit out of place like it does not belong in there.












    Attached Images Attached Images
    Last edited by Archer; 03-09-2016 at 07:28 PM.
    Learning the genesis one bit at a time

  3. #3
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    206
    Rep Power
    11

    Default

    I have decided to read the buttons through the chip. It a very simple chip that should use only 80 uA according to the datasheet and can run on 3v3. If I understand the IC correctly I can even use the start button as a soft-power-on if it's in the right state, and that would be cool.
    I also think I found a solution for the LED and the square hole. The wire had this rubber strain relief that fits perfectly in the square hole and has a round inside. With a bit of force I managed to get the cable out and cut it to be a little shorter. And now this is what it looks like:

    gamepad_md_led_fitting.jpeg
    The red and green are from the charger LED's that shine through the RGB-led. I just could not wait to see that so i just used some scotch tape to keep the charger, battery and wires in place and took a few pictures Next thing I will do is figure out how to wire the controller IC to the Arduino. I will be using an unmodded gamepad for that and capture it's signals with a logic analyzer while it's being read by Sonic 1 on my Megadrive 2.
    Learning the genesis one bit at a time

  4. #4
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    206
    Rep Power
    11

    Default

    It's been a few days but i did some more digging into the Mega Drive Gamepad. i have run some Logic Analyzer tests and found that the 'select' line is toggled every 20ms, which makes sense for my 50hz PAL Mega Drive. The lines i expected to change during button presses are changing, and switch during select. Which takes only 6-7us. I still need to figure out if the buttons are read before or after the select line. I could look at my game project code from a few years ago how i did it.
    Learning the genesis one bit at a time

  5. #5
    Nameless One IvoSlash's Avatar
    Join Date
    Mar 2015
    Location
    Portugal
    Age
    33
    Posts
    56
    Rep Power
    7

    Default

    Looking great!
    Please keep sharing updates and pictures.
    It looks awesome!

    How do you link the IC and the transmitter? I dunno if this a silly question or not, as I don't understand a lot of electronics.
    SEGA, mais forte que tu!

  6. #6
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    206
    Rep Power
    11

    Default

    Quote Originally Posted by IvoSlash View Post
    Looking great!
    Please keep sharing updates and pictures.
    It looks awesome!

    How do you link the IC and the transmitter? I dunno if this a silly question or not, as I don't understand a lot of electronics.
    The IC on the controller PCB will be connected to the Arduino Mini Pro (the big blue board in my picture) with wires . The Arduino will connect to the same spots where the wires from the cable used to go to the controller PCB. You can take a look at my other thread that has pictures of a SNES controller to get an idea of how the components are connected. The current SNES firmware reads the buttons every 15ms and sends a packet if the button states have changed. And if there is no change for more than 1 second a packet is send to keep the receiver in sync, sort of. The MegaDrive controller firmware will not be much different except for the button_read() function.

    I hope that answers your question a bit. If you look at the last picture you see the upside down MegaDrive pad with the boards inside. Nothing is connected there since it was just a fitting test to see if there was enough space. The green board is a micro-usb breakout, but i might end up using a smaller one. The top left blue board is the battery charger and below that is a voltage regulator. As said the bigger blue one is an arduino mini pro (clone) and next the black board is the RF transceiver. All of this has to be fitted around the original PCB but since there is so much space I see no problem with that

    I think I might put together a prototype transmitter tonight, I guess I could post a picture of it if you are interested. It will just be a small breadboard with an arduino mini pro and a transmitter dangling on some wires though. And of course a cut extension cable connected to an unmodded MegaDrive gamepad. Reading the buttons is not that difficult so I might even be able to play a bit of 'wireless' sonic tonight
    Learning the genesis one bit at a time

  7. #7
    WCPO Agent Helder's Avatar
    Join Date
    Jun 2013
    Posts
    755
    Rep Power
    15

    Default

    Found some useful info for you and possibly most of the work done for you:
    http://jonthysell.com/2014/07/26/rea...-with-arduino/

  8. #8
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    206
    Rep Power
    11

    Default

    Quote Originally Posted by Helder View Post
    Found some useful info for you and possibly most of the work done for you:
    http://jonthysell.com/2014/07/26/rea...-with-arduino/
    That article has some very useful info on the button mapping and timing. I had found it before while doing research and was planning on using it already, but thanks for helping out.

    The Arduino code is not exactly what I need. What I do is simply read the states and send them out if they have changed. I don't need to know which exact button is pressed, only that it have changed since last time.

  9. #9
    Mega Driven Raging in the Streets cleeg's Avatar
    Join Date
    Oct 2010
    Location
    Outer Space 2
    Age
    42
    Posts
    3,418
    Rep Power
    73

    Default

    Nice work indeed.

  10. #10
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    206
    Rep Power
    11

    Default

    Quote Originally Posted by cleeg View Post
    Nice work indeed.
    Thanks, but the actual wireless controller still has to be build though.

    I have put together a second development transmitter on a breadboard. I first tested it with the SNES firmware I already had to test if all the wires were connected properly. Saved that project under a new name 'RFpad_MegaDrive_TX' and changed the SNES specific parts into MegaDrive specific parts. The gamepad reading function ended up really short:
    Code:
    unsigned short sega_md_read()
    {
      unsigned short data = 0;  
      
      digitalWrite(2, LOW);
      delayMicroseconds(2);
      data = PINC & 0x7F;
      
      digitalWrite(2, HIGH);
      delayMicroseconds(2);
      data += (PINC & 0x7F) << 8;
    
      return data;
    }
    It could be done faster if I replaced the digitalWrite() functions with direct port access like I did for the data. That website with the other project and the info turnout to be extremely valuable, it helped me out a lot with the correct pinout and what button data to get based on the state of the select line. The data that is returned by this function is what I would call 'native', since it can be used directly as is on the Megadrive receiver. I am thinking about a second mode called 'universal' that would map the buttons in a certain way so you can use gamepads from different systems. In other words you could play Mario with a megadrive pad or sonic with a SNES pad, a bit controversial maybe but I like that idea I want to do some input lag testing on real games. With the 240p test suite I get a result of 2-3 frames of lag but that might just be me or my old and tired controller responding to late.

    What kind of games would you recommend that require ultra fast response?
    Learning the genesis one bit at a time

  11. #11
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    206
    Rep Power
    11

    Default

    It looks like a big mess of wires but I thought I should just show what it looks like right now. And all that stuff needs to fit inside the controller

    20160323_075524-2.jpg

    20160323_075524-1.jpg

    20160323_075524-3.jpg
    Last edited by Archer; 03-23-2016 at 05:20 AM.
    Learning the genesis one bit at a time

  12. #12
    Wildside Expert
    Join Date
    Nov 2010
    Posts
    151
    Rep Power
    14

    Default

    Quote Originally Posted by Archer View Post
    Thanks, but the actual wireless controller still has to be build though.

    I have put together a second development transmitter on a breadboard. I first tested it with the SNES firmware I already had to test if all the wires were connected properly. Saved that project under a new name 'RFpad_MegaDrive_TX' and changed the SNES specific parts into MegaDrive specific parts. The gamepad reading function ended up really short:
    Code:
    unsigned short sega_md_read()
    {
      unsigned short data = 0;  
      
      digitalWrite(2, LOW);
      delayMicroseconds(2);
      data = PINC & 0x7F;
      
      digitalWrite(2, HIGH);
      delayMicroseconds(2);
      data += (PINC & 0x7F) << 8;
    
      return data;
    }
    It could be done faster if I replaced the digitalWrite() functions with direct port access like I did for the data. That website with the other project and the info turnout to be extremely valuable, it helped me out a lot with the correct pinout and what button data to get based on the state of the select line. The data that is returned by this function is what I would call 'native', since it can be used directly as is on the Megadrive receiver. I am thinking about a second mode called 'universal' that would map the buttons in a certain way so you can use gamepads from different systems. In other words you could play Mario with a megadrive pad or sonic with a SNES pad, a bit controversial maybe but I like that idea I want to do some input lag testing on real games. With the 240p test suite I get a result of 2-3 frames of lag but that might just be me or my old and tired controller responding to late.

    What kind of games would you recommend that require ultra fast response?

    Twitch games, like fighters. Super street fighter 2 would be a good test.

  13. #13
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    206
    Rep Power
    11

    Default

    Quote Originally Posted by rush6432 View Post
    Twitch games, like fighters. Super street fighter 2 would be a good test.
    Thanks, I will see if I can get some fighters. The game that comes near a fighter that I have is Golden Axe. I used to like mortal combat on the PC. Is the megadrive version just as good?

    A little update on my project for those that are interrested:
    I have put together a prototype receiver that is receiving the button states from the prototype controller. I want to use direct port access to write the button states tot the pins. I got it working when I know what I want, either set or clear a bit. It gets confusing now I dont know what I get. I can shift the bits I receive to the correct place I need them for the connected pins. But how do I change only those pins, and set or clear them with a single command?
    Learning the genesis one bit at a time

  14. #14
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    206
    Rep Power
    11

    Default

    Another update:

    It's kind of working but not fast enough. The thing is the 74hc157 inside the controller is a very simple dumb multiplexer that can switch it's output in less than 2ns!!!!! My Arduino simulation takes 1.5us to even respond to the pin change. But i am not giving up because I know this has been done before, and I found some neat tricks on this site: http://www.raphnet.net/programmation...d/index_en.php
    I was thinking about boosting the Arduino frequency up to 20Mhz but that means no standard arduino board will work, because they all run on 16mhz. But I think with the tricks from raphnet I might get it to work.
    Learning the genesis one bit at a time

  15. #15
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    206
    Rep Power
    11

    Default

    I have been able to get the simulation response down to about 0.625us, and in the process I somehow managed to break my wireless functionality. So to test if the mega drive is accepting the new improved response time I wrote a little sequence that just moves the cursor around the screen on the Game Genie menu:

    Code:
      while(1)
      {
        port0_right();
        port0_right();
        port0_down();
        port0_down();
    
        delay(500);
            
        port0_left();
        port0_up();
        port0_left();
        port0_up();
    
        delay(500);
      }


    Now I just need to fix my wireless code and I will be playing some sonic over the airwaves
    Learning the genesis one bit at a time

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •