element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
element14 presents
  • Challenges & Projects
  • More
element14 presents
element14 presents Forum My Retropie Portable Build
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join element14 presents to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 12 replies
  • Subscribers 109 subscribers
  • Views 2307 views
  • Users 0 members are here
  • portable pi
  • 7 inch touchscreen display
  • li-po charging
  • retropie
Related

My Retropie Portable Build

celcius1
celcius1 over 6 years ago

Hey Guys,

 

I've decided to discuss my Retropie Handheld build, I would love feedback if it is constructive, now I had a 7" RPi touchscreen lying around, and decided to build it into a Retropie portable, now power requirements, had to be considered, now Powerboost chargers from adafruit wont cut it with the current feed needed for the RPi 3B+, so for the Power source, I'm using 4 LiPo cells, with a capacity of 4000mAh, wired as two packs, so i have two packs with an output voltage of 7.2v and then in parallel so I have a battery capacity of 8000mAh.  I also cant use Adafruit stuff as there are no local stockists of the modules here in Adelaide.

 

But with the charging circuit I've modified one I found for charging 4 cells that uses an ATMega328P, the changes I'm making is for charging 2 cells even though I'm using 4, I am assuming I can treat the two packs of two cells as two cells to the circuit.  The other change is to add a means to switch from battery power to PSU when it is plugged in for charging. and load share between the pi and battery, the power from the PSU or battery then goes into a Buck Converter, (https://www.altronics.com.au/p/z6334-dc-dc-buck-module-3-40v-input/), so I can give the Pi and screen upto 2.5A at 5v.  Also I'll be adding a means to the battery charging circuit if a low battery condition is detected, so that it can signal the RPi to shutdown if the voltage drops below a set threshold.

 

Now the reason for building my own charging interface is because here in Australia we don't have much in the way of standard modules, even ones with the power requirements of the RPi 3B+, plus I prefer a bigger handheld screen.

 

This is the reference I am using for building my own version of the charging circuit https://www.microfarad.de/li-charger/ this site is quite informative, and will help in customising this circuit for my requirements.

 

For the buttons I am going to use a basic key matrix, and take a page from the TBHS project where they did this, as its a good proven method of input.

 

The batteries I am using https://www.altronics.com.au/p/s4761-26650-lithium-ion-3.6V-4000mah-rechargeable-battery/

Controller I am using for charging https://www.altronics.com.au/p/z6222-sparkfun-dev-11113-pro-mini-328-5v-16mhz/

Plugpack for External power and Charging https://www.altronics.com.au/p/m8936b-powertran-12v-dc-2a-fixed-2.1mm-tip-appliance-plugpack/

 

I value constructive feedback of my project.

 

I also forgot to add, once I get the handheld working, I'm going to look at expanding it so I can plug 2600 cartridges directly into it, as I have been working on a 2600 cartridge interface. running into a few hurdles, so focusing on something a little easier image

 

Regards

 

Paul

 

P.S. I'm umming and rring about actually recording this on video and doing a video of project.

  • Sign in to reply
  • Cancel

Top Replies

  • celcius1
    celcius1 over 6 years ago +2
    After speaking with my battery supplier, I've decided to go with 18650 Li-Ion cells, with 3 cells per bank, giving a battery voltage of 10.8V and battery life of approx 7hrs. as when the handheld is on…
  • shabaz
    shabaz over 5 years ago in reply to celcius1 +2
    Hi Paul, There are other ways to design keyboard circuits that reduce the need for so many parts, you've got 37 parts here not including the buttons. These can be reduced to 2 parts, like two MCP23017…
  • celcius1
    celcius1 over 5 years ago +1
    It's been awhile since working on this, I've made a few changes since I originally started. Change 1 I'm using a different 7inch screen, that is driven by a HDMI and usb for power and Touch https://www…
  • celcius1
    celcius1 over 5 years ago +1
    Also with the battery component, I've done more research, and are working on integrating a battery balancing system in the charging circuit, and have decided to go with a 18v battery pack as when I did…
  • shabaz
    shabaz over 5 years ago +1
    Hi Paul, Connecting parallel/series batteries can be high-risk, you've not mentioned if the latest battery pack is self-assembled. The original one you mentioned was not (the one that was going to be 4…
  • celcius1
    celcius1 over 5 years ago in reply to shabaz +1
    Hi Shabaz, The battery packs are being professionally made of 4 cells each behind each hand hold, total of 8 cells, at 14.8v, they will have to sets of wires on it one for pack connection and the other…
  • celcius1
    celcius1 over 5 years ago +1
    So I have got most the schematic drawn up for the button matrix, I still have a number of items to put on the schematic most importantly a logic level shifter as the shift registers are logic level 5v…
  • celcius1
    celcius1 over 5 years ago in reply to shabaz +1
    Hi Shabaz, Thanks for the suggestion I'll make a change to my schematic, I'm reading up on the chip now, trying to find the SPI commands, as I've started coding the source file to read the button states…
  • shabaz
    shabaz over 5 years ago in reply to celcius1 +1
    Hi Paul, I've not coded using the library you're using or for this device, so cannot help much here. It may be instead worthwhile using a GPIO library (such as wiringPi or some other one, I don't know…
  • celcius1
    celcius1 over 5 years ago in reply to shabaz +1
    Hi Shabaz, I Redesigned my Key Matrix, and re wrote my code. I'm using 74HC165 now, which are proper input shift registers or PISO registers, don't need to use protection diodes on the pins, and the IC…
Parents
  • celcius1
    celcius1 over 5 years ago

    It's been awhile since working on this, I've made a few changes since I originally started.

     

    Change 1 I'm using a different 7inch screen, that is driven by a HDMI and usb for power and Touch https://www.altronics.com.au/p/z6514-7-inches-lcd-touchscreen-800x480-for-raspberry-pi/

    Change 2 I've switched to a RPi Zero, its taking up room in my drawer bought it over a year ago , and have yet to use it, so decided on using it in my retro pie portable.

     

    For my button input, I'm using a button matrix designed using the 74HC595 shift register which will allow me to use 4 GPIO to read a number of buttons, thanks to the 595's ability to stack an extra 8 bit shift register and add more input.  I'm going to use 4 shift registers to give me up to 32 button inputs, but the problem I have is trying to assign the key matrix, I was thinking of writing a *.c file like this https://github.com/annem/ADXL362_RaspPi/blob/master/ADXL362_RaspPi.c obviously mine will be spec'd for the shift registers.  But how would I go about building this into a keyboard driver, so I can use a key matrix assignment that Ben heck used on the retro pie build he did in episode 322 and 328.  I'm still relatively new to writing low level code on the RPi but I'd appreciate the help if it comes.

     

    Now the reason why I choose to go with 32 inputs, on my key input device on my hand held I'll only connect approx 12 to 16 inputs, I'm also building a desktop Retro Pie and wanted to make sure I could have the one driver for doing both single and two player control connections.

     

    So the way I have designed the button matrix is as follows, a single bit is loaded on to the shift register, and then is shifted through the entire 32 outputs, each of the outputs is connected to the MOSI line of the SPI bus, if a button is pressed, a logic 1 is sent to the input on the bus at that specific position.  So multiple buttons can be registered, so when the button matrix is read into the pi it is a 32bit number.

     

    Then all I need to do is figure out how to analyse the number most likely via a lookup table or something to confirm which button is pressed, I assume this data analysis is done within the driver.

     

    But I need to try and work out an appropriate polling period, as I'm looking to use a SPI clock of 6.25Mhz which would give me a clock pulse of interval of 160ns, so no where near the lower limit of 25ns for the clock input to register valid data (lowest limit is 20ns want to have a buffer).  But what would be an appropriate poll time, 1 millisecond?  I'd appreciate input on this.  If my math is correct, with a clock pulse of 160ns, and approximately 36 clock cycles to read the input states, that means I need  6 microseconds to read the data in, then I have to decide on a wait period and do another read.

     

    As a friend of mine told me polling is better and easier to debug, versus using an interrupt.  And also cause my method of input is similar to a NES controller, they used a polling method to read the shift register data, so that appears to be the best method to read the button states.

     

    I'll post a partial schematic of the button matrix in due course.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • celcius1
    celcius1 over 5 years ago

    It's been awhile since working on this, I've made a few changes since I originally started.

     

    Change 1 I'm using a different 7inch screen, that is driven by a HDMI and usb for power and Touch https://www.altronics.com.au/p/z6514-7-inches-lcd-touchscreen-800x480-for-raspberry-pi/

    Change 2 I've switched to a RPi Zero, its taking up room in my drawer bought it over a year ago , and have yet to use it, so decided on using it in my retro pie portable.

     

    For my button input, I'm using a button matrix designed using the 74HC595 shift register which will allow me to use 4 GPIO to read a number of buttons, thanks to the 595's ability to stack an extra 8 bit shift register and add more input.  I'm going to use 4 shift registers to give me up to 32 button inputs, but the problem I have is trying to assign the key matrix, I was thinking of writing a *.c file like this https://github.com/annem/ADXL362_RaspPi/blob/master/ADXL362_RaspPi.c obviously mine will be spec'd for the shift registers.  But how would I go about building this into a keyboard driver, so I can use a key matrix assignment that Ben heck used on the retro pie build he did in episode 322 and 328.  I'm still relatively new to writing low level code on the RPi but I'd appreciate the help if it comes.

     

    Now the reason why I choose to go with 32 inputs, on my key input device on my hand held I'll only connect approx 12 to 16 inputs, I'm also building a desktop Retro Pie and wanted to make sure I could have the one driver for doing both single and two player control connections.

     

    So the way I have designed the button matrix is as follows, a single bit is loaded on to the shift register, and then is shifted through the entire 32 outputs, each of the outputs is connected to the MOSI line of the SPI bus, if a button is pressed, a logic 1 is sent to the input on the bus at that specific position.  So multiple buttons can be registered, so when the button matrix is read into the pi it is a 32bit number.

     

    Then all I need to do is figure out how to analyse the number most likely via a lookup table or something to confirm which button is pressed, I assume this data analysis is done within the driver.

     

    But I need to try and work out an appropriate polling period, as I'm looking to use a SPI clock of 6.25Mhz which would give me a clock pulse of interval of 160ns, so no where near the lower limit of 25ns for the clock input to register valid data (lowest limit is 20ns want to have a buffer).  But what would be an appropriate poll time, 1 millisecond?  I'd appreciate input on this.  If my math is correct, with a clock pulse of 160ns, and approximately 36 clock cycles to read the input states, that means I need  6 microseconds to read the data in, then I have to decide on a wait period and do another read.

     

    As a friend of mine told me polling is better and easier to debug, versus using an interrupt.  And also cause my method of input is similar to a NES controller, they used a polling method to read the shift register data, so that appears to be the best method to read the button states.

     

    I'll post a partial schematic of the button matrix in due course.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube