Yet Another Pi Zero Portable!!
-
How did you use the microcontroller as a power switch?
Did you use a mosfet?
Can you please share the code?Also, I noticed you didn't use a power boost module or a regulator, can the screen run directly from the battery voltage which is under 5V?
Thank you
-
@pikgoggle i used a little board from DFRobot called uHex http://www.dfrobot.com/index.php?route=product/product&product_id=1266
it is basically an arduino, with a little MOSFET built in, and you can use its library to make it sleep/wake and when it is asleep, the 6 power ports are off. The code is a little basic at the moment, and is not without its flaws. the wake interrupt fires instantly, and the pi starts to boot before the code has chance to check for a long press. Also as soon as the board gets power, the pi will also start to boot, so if the battery protection kicks in, its hard to get it all to actually charge (gets stuck in a loop of charge/protect) I also planned on adding a neopixel in there, so i could get power metering, and adding connection to the pi to check for the pi being on/ and offering safe shut down. I did start adding that into the code, but never got to finishing it. You can have a butchers at it here https://drive.google.com/file/d/0B8-rbOfCiqw0MkRiYnFqbU1MWk0/view?usp=sharing
@senkun the post man came today!! Although i have some family moving in with me soon, so im not sure when i will have the time :(
-
@moosepr if you just want a power switch, if your mechanical switch can't handle the current, you can use this circuit:
http://www.falstad.com/circuit/circuitjs.html?cct=$+1+0.000005+10.20027730826997+50+5+43 s+160+112+224+112+0+1+false r+384+112+384+256+0+10000000 g+384+256+384+288+0 v+160+240+160+112+0+0+40+5+0+0+0.5 g+160+240+160+304+0 w+464+128+464+208+0 w+160+112+160+32+0 w+160+32+464+32+0 w+464+32+464+96+0 w+464+208+464+272+0 r+464+272+464+336+0+100 g+464+336+464+384+0 w+384+112+224+112+0 f+384+112+464+112+1+1.5+0.02 o+10+64+0+35+5+0.05+0+-1the PMOS transistor is used to drive the high current, while the mechanical switch only activates the gate with a low current.
The 100ohm resistance represents the load.
It can be done with NMOS too. -
@pikgoggle I will look at that, thanks
I think the problem i have with the uHex board is that the switching happens within the library, so you are not able to wake the board then decide if you want to activate the outputs or not. dfRobot claim that it can switch up to 2A
-
@moosepr I looked at the uhex schematic and the power switch is connected to PD7 of the Atmega328P.
It is the same pin as analog 1 (A1).
You can try setting the PORTD register by the following code:
// in setup, set pd7 to output
DDRD|=B10000000to turn off the power output use this:
//set pd7 low
PORTD&=B01111111when you ready to power on this will activate power:
//set pd7 high
PORTD|=B10000000I couldn't find in the library that PD7 is changed, so tell me if it works.
-
@moosepr said in Yet Another Pi Zero Portable!!:
the post man came today!! Although i have some family moving in with me soon, so im not sure when i will have the time :(
I love when Santa the postman brings toys! It's a quick desolder/solder job, 30 mins tops, use plenty of flux when you wipe! Do it now, haha I can't wait to see your panel stripped off the board! Just one thing to note, make sure you have a resistor to the backlight LED.
-
I just ordered one of those 2.2" displays from eBay. Were drivers for it already in the RetroPie image, or did you end up downloading them from somewhere else? Apologies for the noob question, I'm new to this hardware stuff.
-
@obsidianspider said in Yet Another Pi Zero Portable!!:
I just ordered one of those 2.2" displays from eBay. Were drivers for it already in the RetroPie image, or did you end up downloading them from somewhere else? Apologies for the noob question, I'm new to this hardware stuff.
Best bang for the buck generic screens. Besides the fixed SPI connections, the other GPIO connections (led, rst, dc, etc.) can be hooked up any which way you choose, so there really aren't any specific drivers built into the kernel. But Notro has drivers provided for some named brand screens which use the same controller, which would work if we dig through the overlay sources and check for the specified connections to hook up our screens accordingly. That sort of limits the flexibility.
I'm still playing about setting up my screen and seeing if I can get enough free pins for GPIO controls, or give up and use USB. And then will make my own dt blob specific for my setup. So in the meantime, we're using fbtft by manually loading the module.
Have a read here;
http://marcosgildavid.blogspot.tw/2014/02/getting-ili9341-spi-screen-working-on.html -
Thanks, that gives me something to look through while I wait the week or so that eBay says it will take for the screen to get here. I want to use this small screen to display an image of the game's art when I start a game with EmulationStation. (I saw in another post some info about using runcommand to run something when you start or exit a game.) I want the main game video to output to HDMI, so that's a whole other thing to figure out.
-
@obsidianspider the drivers for the screen are already included in RetroPie (as long as the screen uses the ili9341 driver). it basically uses the same screen as early adafruit 2.2" tft screens https://github.com/notro/fbtft/wiki/LCD-Modules#adafruit-22
If i remember right, you need to go into the raspiconfig, and enable spi, disable overscan, and enable device tree, then you should be able to run the command "sudo modprobe fbtft_device pitft22" to actually get the screen active (the backlight should light). You can test it with the command "con2fbmap 1 1" which should pop your terminal session onto the tft screen (run "con2fbmap 1 0" to get it back)
There is then an app you need to download and build which basically copies the output of the normal screen onto the tft. There is an adafruit guide here, https://learn.adafruit.com/running-opengl-based-games-and-emulators-on-adafruit-pitft-displays/pitft-setup basically replace the adafruit-28 with adafruit-22 and you should get somewhere near
@pikgoggle i will investigate that, i never thought to check the schematic to see whats actually connected where. Im planning on maybe making a custom PCB for it all, so i might replace the uHex with an atTiny85 and a MOSFET and do it all myself (if i ever get round to it)
@senkun thats one of the links i used too!!! Im having to sort the spare room and stuff, so time is very limited at the moment :( wont be forever though. I used the 'Adafruit -Retrogame' for the controls. https://learn.adafruit.com/running-opengl-based-games-and-emulators-on-adafruit-pitft-displays/adding-controls i figured i could squeeze about 14 gpio pins out of it, if you make sure you disable the I2C and serial, you can make use of those pins there
-
Thanks! This will help a lot.
-
@moosepr said in Yet Another Pi Zero Portable!!:
the drivers for the screen are already included in RetroPie (as long as the screen uses the ili9341 driver). it basically uses the same screen as early adafruit 2.2" tft screens https://github.com/notro/fbtft/wiki/LCD-Modules#adafruit-22
Haha. That's what I meant. "Notro has drivers provided for some named brand screens which use the same controller, which would work if we dig through the overlay sources and check for the specified connections to hook up our screens accordingly."
@obsidianspider Just make sure you hook up your screen accordingly to mimic the connections for that named brand screen.
-
@moosepr said in Yet Another Pi Zero Portable!!:
i figured i could squeeze about 14 gpio pins out of it, if you make sure you disable the I2C and serial, you can make use of those pins there
whoa 14 pins is good! More than enough including shoulder triggers. Looking at your pic, I see 4 for the Dpad, and a, b, x, y. What about start, select?
-
@senkun said in Yet Another Pi Zero Portable!!:
@obsidianspider Just make sure you hook up your screen accordingly to mimic the connections for that named brand screen.
Haha, yeah, I'll be sure to connect it with the Adafruit-style pins. There's a reason I'm doing all of this experimenting with my old Pi2 before I hook everything up to a new Pi3. I don't want to fry something, but this is all new to me, so I have a feeling there will be a few failures along the way.
-
@moosepr I still didn't understand how you power it with a lipo without a voltage booster?
lipo voltge is 3.7 to 4.2.
Do you power it with the 3.3V or 5V gpio pins of the pi zero? -
@pikgoggle said in Yet Another Pi Zero Portable!!:
I still didn't understand how you power it with a lipo without a voltage booster?
lipo voltge is 3.7 to 4.2.@senkun said in Yet Another Pi Zero Portable!!:
the Zer0 can and has been tested to boot from as low as 2.8V (very unsafe if Lipo) and run unless there are 5v usb peripherals.
The screen needs a strict 3.3V, which is provided by the zer0 which in turn is fed direct off a LiPo (from 4.2V ~ whatever safe cutoff is set). To be safe, the battery should at least have a protection circuit built in. @moosepr has a charger/protection circuit module in the mix.
-
@pikgoggle yeah like @senkun said, im piping the lipo straight into the 5v pin on the gpio header. This way it still goes through the 3.3v regulator, so the pi gets the 3.3v it needs. It even works for most USB devices, had an old wifi dongle working fine. It is going through a cheepo Chinese charge/protect board, just to make sure there is no damage to the battery if things get low.
I chose this method for simplicity, and to reduce power drain. Most boost converters are 90% efficient, but then if your boosting it (with a loss) just to regulate is down again (probably with another loss) then your just nailing battery power for no real reason.
@obsidianspider I like the wound of your project. If you are just using the tft screen as a second screen then things might actually be simpler for you than first thought!!!! As long as you have the modprobe command to get the screen fired up, all you need to do is use simple commands to send a simple command to throw an image at the screen. if you look here https://github.com/notro/fbtft/wiki/Framebuffer-use
the handhelds use the mirroring, but you can use the image or video options, to display something related to the game in use
-
@senkun im currently usnig 8 gpio your correct. I have start and select included in those 8 at the moment, it is the only way i can get in and out of games for now.
im currrently using only the right hand gpio pins for the buttons (6,13,19,26 & 12,16,20,21)
the screen is using standard pins (18,24,25,8,9,10,11)
so that leaves an extra pile of pins (2,3,4,5,14,15,17,22,27) which is more than enough for start, select, and 2 shoulder buttons
this is of course assuming that you dont want sound. have bought the I2A board from adafruit https://www.adafruit.com/product/3006 whic uses 3 pins (18,19,21) Now my tft board gets round pin 18 being used for the backlight (assuming you can stop the driver from attempting to use it) so 19,21 will need to be re-assigned differently for the buttons i already have. But then that will still leave plenty of room to play!!
-
@moosepr said in Yet Another Pi Zero Portable!!:
@obsidianspider I like the wound of your project. If you are just using the tft screen as a second screen then things might actually be simpler for you than first thought!!!! As long as you have the modprobe command to get the screen fired up, all you need to do is use simple commands to send a simple command to throw an image at the screen. if you look here https://github.com/notro/fbtft/wiki/Framebuffer-use
the handhelds use the mirroring, but you can use the image or video options, to display something related to the game in use
I'm hoping I can figure it out. I was inspired to use a second screen by this bartop, but he used a GLCD, not a full-on display. (More information in the comments on reddit.) The code he used to output a simple graphic and/or text looks a lot simpler. I'm going to need to figure out how to do some programming if I want the little slide show he did (I think I can do something like that with fim, but what I am not sure of how to do would be to also use text if I wanted to have the display show something else (scope creep). If I understand it correctly his second slide is an image with button text overlaid from an XML file.
What I'm planning is a Super Famicom with a Pi3 in it, and I wanted to have a game in it that did something, I wasn't sure what. I was originally going to do the "put the SD card in the cartridge" thing I've seen done a few times, but I decided I'm going to try to get it set up so when you select the game and it starts playing to display the game art on a cartridge inserted in the Super Famicom.
I measured up the $4 soccer game I bought on eBay to use as a donor and that 2.2" screen is just slightly taller than the label area, so it should fit nicely, and since so many Super Famicom cartridges seem to have that graphic area surrounded by a colored label, it should look right at home once I either paint the label area, or make up a new label.
…Of course, I can't try anything with the new screen until it actually gets here, so I'm hoping the shipping is quick!
-
not to revive a dead thread, but for anyone interested, here are a few updates on my little project.
Firstly, i have finally got round to testing my battery. it is 2500mah, so the 10 hour runtime means 250mah per hour of runtime. i think this is partly due to the lack of audio/usb hub/boost circuit.
Secondly, my little ili9431 adapter boards work!!! I have finally found the time to test, and although i have not tried it on a Pi, it works a treat with an esp8266 board, using a basic adafruit test sketch
The soldering is a little messy, and the only naked screen i had to hand was 2.8 inch, so had 18 pins rather than 14, so you just have some spare overhang
excuse the poor focus, my phone doesnt like the 0.8mm pitch pins
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.