Arzeon's simple Raspberry PI 3 wiring reference diagram (used in the emulation boy project)

Discussion in 'Raspberry Pi' started by Arzeon, Apr 16, 2018 at 8:55 PM.

  1. Arzeon .

    Joined:
    Apr 6, 2018
    Messages:
    8
    Likes Received:
    15
    Portables:
    1
    Hello everyone!
    After I finished The emulation boy project I created a diagram of the wiring of my portable, so I can use it as a simple reference in the future when needed. I think it might benefit other people who might want to make a similar portable. obviously this diagram is aimed at the newbies at portablizing like myself.

    The diagram is high res.
    The test pad pinout was provided by chedda from the sudomod forums.
    [​IMG]
    Please tell me if you notice any slipups.

    This is the pinout for the psp 1000 & 3000 analog sticks:
    [​IMG]
    This is the simple code for the teensy 2 mentioned in the diagram. If you aren't able to modify this code in case it doesn't work for you, I'd recommend studying some c++...
    Code:
    /* Buttons to USB Joystick Example
    
       You must select Joystick from the "Tools > USB Type" menu
    
       This example code is in the public domain.
       
       USE JOY.cpl to test your Teensy 2 code and button connections
    */
    
    #include <Bounce.h>
    
    // Create Bounce objects for each button.  The Bounce object
    // automatically deals with contact chatter or "bounce", and
    // it makes detecting changes very simple.
    Bounce button0 = Bounce(0, 10);
    Bounce button1 = Bounce(1, 10);  // 10 = 10 ms debounce time
    Bounce button2 = Bounce(2, 10);  // which is appropriate for
    Bounce button3 = Bounce(3, 10);  // most mechanical pushbuttons
    Bounce button4 = Bounce(4, 10);
    Bounce button5 = Bounce(5, 10);
    Bounce button6 = Bounce(6, 10);
    Bounce button7 = Bounce(7, 10);
    Bounce button8 = Bounce(8, 10);
    Bounce button9 = Bounce(9, 10);
    Bounce button13 = Bounce(13, 10);
    Bounce button14 = Bounce(14, 10);
    Bounce button15 = Bounce(15, 10);
    Bounce button16 = Bounce(16, 10);
    
    void setup() {
      // Configure the pins for input mode with pullup resistors.
      // The pushbuttons connect from each pin to ground.  When
      // the button is pressed, the pin reads LOW because the button
      // shorts it to ground.  When released, the pin reads HIGH
      // because the pullup resistor connects to +5 volts inside
      // the chip.  LOW for "on", and HIGH for "off" may seem
      // backwards, but using the on-chip pullup resistors is very
      // convenient.  The scheme is called "active low", and it's
      // very commonly used in electronics... so much that the chip
      // has built-in pullup resistors!
      pinMode(0, INPUT_PULLUP);
      pinMode(1, INPUT_PULLUP);
      pinMode(2, INPUT_PULLUP);
      pinMode(3, INPUT_PULLUP);
      pinMode(4, INPUT_PULLUP);
      pinMode(5, INPUT_PULLUP);
      pinMode(6, INPUT_PULLUP); 
      pinMode(7, INPUT_PULLUP);
      pinMode(8, INPUT_PULLUP);
      pinMode(9, INPUT_PULLUP);
      pinMode(13, INPUT_PULLUP);
      pinMode(14, INPUT_PULLUP);
      pinMode(15, INPUT_PULLUP);
      pinMode(16, INPUT_PULLUP);
    }
    
    void loop() {
      // Update all the buttons.  There should not be any long
      // delays in loop(), so this runs repetitively at a rate
      // faster than the buttons could be pressed and released.
      button0.update();
      button1.update();
      button2.update();
      button3.update();
      button4.update();
      button5.update();
      button6.update();
      button7.update();
      button8.update();
      button9.update();
      button13.update();
      button14.update();
      button15.update();
      button16.update();
    
      // Check each button for "falling" edge.
      // Update the Joystick buttons only upon changes.
      // falling = high (not pressed - voltage from pullup resistor)
      //           to low (pressed - button connects pin to ground)
      if (button0.fallingEdge()) {
        Joystick.button(1, 1);
      }
      if (button1.fallingEdge()) {
        Joystick.button(2, 1);
      }
      if (button2.fallingEdge()) {
        Joystick.button(3, 1);
      }
      if (button3.fallingEdge()) {
        Joystick.button(4, 1);
      }
      if (button4.fallingEdge()) {
        Joystick.button(5, 1);
      }
      if (button5.fallingEdge()) {
        Joystick.button(6, 1);
      }
      if (button6.fallingEdge()) {
        Joystick.button(7, 1);
      }
      if (button7.fallingEdge()) {
        Joystick.button(8, 1);
      }
      if (button8.fallingEdge()) {
        Joystick.button(9, 1);
      }
      if (button9.fallingEdge()) {
        Joystick.button(10, 1);
      }
      if (button13.fallingEdge()) {
        Joystick.button(11, 1);
      }
      if (button14.fallingEdge()) {
        Joystick.button(12, 1);
      }
      if (button15.fallingEdge()) {
        Joystick.button(13, 1);
      }
      if (button16.fallingEdge()) {
        Joystick.button(14, 1);
      }
    
      // Check each button for "rising" edge
      // Update the Joystick buttons only upon changes.
      // rising = low (pressed - button connects pin to ground)
      //          to high (not pressed - voltage from pullup resistor)
      if (button0.risingEdge()) {
        Joystick.button(1, 0);
      }
      if (button1.risingEdge()) {
        Joystick.button(2, 0);
      }
      if (button2.risingEdge()) {
        Joystick.button(3, 0);
      }
      if (button3.risingEdge()) {
        Joystick.button(4, 0);
      }
      if (button4.risingEdge()) {
        Joystick.button(5, 0);
      }
      if (button5.risingEdge()) {
        Joystick.button(6, 0);
      }
      if (button6.risingEdge()) {
        Joystick.button(7, 0);
      }
      if (button7.risingEdge()) {
        Joystick.button(8, 0);
      }
      if (button8.risingEdge()) {
        Joystick.button(9, 0);
      }
      if (button9.risingEdge()) {
        Joystick.button(10, 0);
      } 
       if (button13.risingEdge()) {
        Joystick.button(11, 0);
      }
      if (button14.risingEdge()) {
        Joystick.button(12, 0);
      }
      if (button15.risingEdge()) {
        Joystick.button(13, 0);
      }
      if (button16.risingEdge()) {
        Joystick.button(14, 0);
      }
     
      int rX = analogRead(3);//pin3       if Joystick X1 off center change 512 in (rX - 512) and eyeball using JOY.cpl
        rX = (rX - 512) * 1.8 + 512;
      if (rX > 1023)
        rX=1023; 
      if (rX < 0)
        rX = 0;
     
      int rY = analogRead(2);//pin2       if Joystick Y1 off center change 512 in (rY - 512) and eyeball using JOY.cpl
        rY = (rY - 512) * 1.8 + 512;
      if (rY > 1023)
        rY=1023;   
      if (rY < 0)
        rY = 0;
       /* rY=abs(1023-rY);*/
       
         int rZ = analogRead(1);//pin1    if Joystick X2 off center change 512 in (rZ - 512) and eyeball using JOY.cpl
        rZ = (rZ - 512) * 1.8 + 512;
      if (rZ > 1023)
        rZ=1023; 
      if (rZ < 0)
        rZ = 0;
     
      int rrZ = analogRead(0);//pin0      if Joystick Y2 off center change 512 in (rrZ - 512) and eyeball using JOY.cpl
        rrZ = (rrZ - 512) * 1.8 + 512;
      if (rrZ > 1023)
        rrZ=1023;   
      if (rrZ < 0)
        rrZ = 0;
       /* rY=abs(1023-rY);*/
      Joystick.X(rX);
      Joystick.Y(rY);
      Joystick.Z(rZ);
      Joystick.Zrotate(rrZ);
      /*rX=x1value
        rY=y1value
        1023=x1max
        0=x1min
        1023=y1max
        0=y1min*/
    /*Might help some people out
    Autocalibration of analog sticks (by Helder + wermy) M
      if (rZ > 0 && rZ > 1023) {
        rZ=1023;
      } else if (rZ < 0 && rZ < 0) {
       rZ=0 ;
      }
    
      if (rrZ > 0 && rrZ > 1023) {
        rrZ=1023;
      } else if (rrZ < 0 && rrZ < 0) {
         rrZ=0;
      }
    
      float x1sMax = abs(1023);
      if (rZ < 0) {
        x1sMax = abs(0);
      }
    
      float y1sMax = abs(1023);
      if (rrZ < 0) {
        y1sMax = abs(0);
      }
     
      /*if (x2Value > 0 && x2Value > x2Max) {
        x2Max = x2Value;
      } else if (x2Value < 0 && x2Value < x2Min) {
        x2Min = x2Value;
      }
    
      if (y2Value > 0 && y2Value > y2Max) {
        y2Max = y2Value;
      } else if (y2Value < 0 && y2Value < y2Min) {
        y2Min = y2Value;
      }
    
      float x2sMax = abs(x2Max);
      if (x2Value < 0) {
        x2sMax = abs(x2Min);
      }
    
      float y2sMax = abs(y2Max);
      if (y2Value < 0) {
        y2sMax = abs(y2Min);
      }
      int16_t x1Final = (((float)rX / x1sMax)*127);
      int16_t y1Final = (((float)rY/ y1sMax)*127);
      int16_t x2Final = (((float)x2Value / x2sMax)*127);
      int16_t y2Final = (((float)y2Value / y2sMax)*127);*/
     
    
    }
    
    
    I hope this helped out. Good luck and, happy tinkering!
     

    Attached Files:

    Stitches likes this.
  2. Ewhizz .

    Joined:
    Oct 16, 2017
    Messages:
    114
    Likes Received:
    1
    Great work mate! Few questions, is the audio powerful or ever crackely? Do you ever experience the under power (lightning bolt sign) when playing N64 or using Bluetooth?
    Thanks!
     
  3. Arzeon .

    Joined:
    Apr 6, 2018
    Messages:
    8
    Likes Received:
    15
    Portables:
    1
    It is indeed crackly. Although I'm sure it isn't because of the amp nor the speaker but the audio of the PI itself (I suspect it is power related). As for the under power sign. It only shows up when I download huge packages via the terminal and sometimes when I run ppsspp for a longer time or when the battery is simply depleted. It would help a lot if anyone could tell me the fix for those 2 issues.
     
  4. Ewhizz .

    Joined:
    Oct 16, 2017
    Messages:
    114
    Likes Received:
    1
    I'll look into the audio issue for you. As for the underpower I think it's cos the 1000C isn't powerful enough. It sounds as if it isn't too much of an issue tho if 90% of the time it isn't there . Also I am not the most knowledgeable in any of this stuff so I think getting second opinions would be best
     
    Arzeon likes this.
  5. Arzeon .

    Joined:
    Apr 6, 2018
    Messages:
    8
    Likes Received:
    15
    Portables:
    1
    Thanks! I'll ask around as well!
    As you said it isn't bad at all, for some reason N64, dreamcast and nds don't have any issues even though those emulators are quite heavy. OH! and thanks for helping me realise that my Bluetooth and wifi are enabled 24/7. I guess disabling those would reduce the power issues considerably!
     
    Last edited: Apr 16, 2018 at 11:49 PM
    Ewhizz likes this.
  6. Ewhizz .

    Joined:
    Oct 16, 2017
    Messages:
    114
    Likes Received:
    1
    No worries! You can use a USB sound card and run the sound through that as I believe the 3.5mm jack causes the issues but this will result in more current drawn which would not help with the underpower problem.
     

Share This Page

Loading...