geaz / simplyRetro-Z5

A 3D printed, five inch retro gaming handheld.
Other
131 stars 13 forks source link

Help using Helder's RetroPSU with the shutdown circuit #14

Closed DoomyDoomer closed 4 years ago

DoomyDoomer commented 4 years ago

This isn't really an issue but more of a help request. I'm trying to apply your shutdown circuit to Helder's RetroPSU, which is similar to Adafruits PowerBoost 1000c. It has an EN pin that functions just like the PowerBoost. The problem I'm running into is once the "power" button is pressed, the system halts at "reboot: System halted", meaning it's ready to be rebooted/shutdown but the circuit doesn't seem to send the EN pin to ground to shut down the boost. If I short EN to GND manually, it shuts down. I've triple checked the circuit and I've wired it correctly. The Pi is running on RetroPie with SPI on and your other config.txt values. I manually installed WiringPi as well since it's a dependency on the retropower application. Any help you can offer is appreciated.

geaz commented 4 years ago

May I ask which distribution you are using? Because it sounds like the GPIO 7 pin is not set to LOW on system shutdown. The powering circuit requires the "dtoverlay" gpio-poweroff which not every distribution has included.

DoomyDoomer commented 4 years ago

I'm running RetroPie 4.14.98-v7+

geaz commented 4 years ago

As far as I know it should be included. Can you check the voltage of GPIO 7 on a running system and a halted one (not powered off)?

DoomyDoomer commented 4 years ago

3.3v when the system is running and like 6mv when halted, so it appears to be running correctly. I'm stumped.

geaz commented 4 years ago

Are you sure the ground <-> enable pin connection is correct? Correct resistors, too? If the GPIO 7 is running correctly and your system keeps running on the initial button press, it seems like the ground <-> enable pin is somehow not working as it should.

DoomyDoomer commented 4 years ago

I think you're right. I'm not sure why I'm having this issue just by looking at the circuit I've built but I'll continue to test. I did bring up the issue to Helder, the maker of the RetroPSU and he put together OSH Park circuit of your Schematic: https://oshpark.com/shared_projects/AFSBND5u This might help people who don't want to mess with stripboard/perfboard :)

geaz commented 4 years ago

Thats pretty cool, thanks for the link! I hope you will find the "bug" :)

DoomyDoomer commented 4 years ago

No problem! Like you, Helder is a huge help with these circuits. I do have one other quick question around the amount of Diodes on your circuit. Usually I see two diodes on circuits such as this. Is the the third diode to reduce the amount of voltage going through to Pin 19?

geaz commented 4 years ago

Exactly, the third diode (resulting in two diodes in series) drops the voltage to a usable one for pin 19.

DoomyDoomer commented 4 years ago

After looking over everything several times and making sure all connections are correct to the best of my ability, I'm still not able to power down the boost with the long press of the button. At this point, I wonder if you could take a look at my circuit and let me know if what I've done is correct or not. It's such a simple circuit so I'm struggling to find what is the problem. I appreciate all of your help so far.

My Circuit from the front Top Yellow wire is EN, Bottom is CPIO 7, Green is GPIO 19

Circuit from the back

Circuit back diagram to help explain all the mess

RetroPSU showing BAT+, EN, 5v PWR, and GND wired to the circuit

Pi connections SDA and SDL pins are for a separate battery monitoring script. Pin 7 wire goes to pwr circuit

My boot config.txt config.txt

My start script for retropower

The "retropower" app is in /usr/bin/ with the proper permissions and does start at boot. It is started at boot by an init.d script called "startRetropower" shown above.

Please let me know if you need anymore information and I appreciate all your help.

geaz commented 4 years ago

As far as I can see it looks fine. Two questions:

  1. By "not able to power down the boost with the long press" you mean, the system gets halted (shutdown is initiated by the retroPower tool), but the power does not get disabled, right?
  2. Did you measure with a multimeter, if your enable pin and the GPIO 7 has a working connection? (Just in case: measure the resistance - it should be ~0 Ohm - otherwise the connection is not working).
DoomyDoomer commented 4 years ago
  1. Exactly. It shutsdown the pi but halts at the terminal waiting to be physically turned off.
  2. Do you mean I should measure by taking one lead and putting it on my EN and the other on Pin 7 when the system is in "halt" state? If so, when I do this I don't see any reading on my multimeter.
geaz commented 4 years ago
  1. Perfect, the retroPower application is doing it's work correctly. At least something :)
  2. You are able to measure it in a powered off state, too. And yes, one lead at the enable pin and the other one on GPIO 7. If you don't get any measures, it means, that the connection between these two points is not working.

You now could use the same method to measure each point in between to get the points where the connection is "lost" (maybe a not working soldering point?).

DoomyDoomer commented 4 years ago

Ok this is weird. I used a different multimeter for sanity check. When I have my PSU plugged in (load share) I get 10k ohm between EN and pin 7. If the USB power is removed from the PSU, it's reading as 8.89 and steadily dropping. This is during the halt state. It seems like it's holding a resistance but I could be saying that wrong.

One more thing: make sure to use the leads in the correct direction because of the diodes....

This was my problem when getting OL

geaz commented 4 years ago

Could you please also measure the ground <-> enable pin connection, too? I forgot, that this is the "most important" one for this defect characteristics.

DoomyDoomer commented 4 years ago

When I test continuity the system reboots unless I hold the leads to the pins, so connection is there ha! 0 ohm when testing resistances.

geaz commented 4 years ago

So it is "working", if you test with the leads? Did you measure it also in a powered off state?

DoomyDoomer commented 4 years ago

Right, because touching one lead to EN and another to GND disables the PSU (just like the powerboost). I don't know how I can test resistance without causing it to power off completely, or is that what you're looking for me to try? Again, thanks for continuing to try to help me.

geaz commented 4 years ago

Just don't turn it on. You don't need power to test resistance.

geaz commented 4 years ago

To summarize what we tested and worked until now:

  1. Connections between the following pins is working: GND <-> EN GND <-> GPIO 7 GPIO 7 <-> EN (otherwise powering on wouldn't work, if I think about it)
  2. GPIO 7 is HIGH during a running system and LOW during a halted system

The only thing what could be wrong are the resistors now (if I am not totally wrong). According to the color codes the resistors are fine (2x 10k and 1x 100k). Just to make sure, that they are working, did you test them with the multimeter? If the 100k resistor ist broken the circuit will not work (just one of many possibilities).

DoomyDoomer commented 4 years ago

I've tested resistance between GND and EN, all in the k ohms. I swapped out the 100k resistor and tested it's resistance when it was free and it was at 99.8k which I assume is in spec of 100k. I'm at a loss!

DoomyDoomer commented 4 years ago

Here's another question - with this circuit in place, shouldn't the Pi stay powered OFF until a button press? Because as soon as I toggle battery on, the pi boots as if it's getting direct power. That seems wrong.

geaz commented 4 years ago

What exactly do you mean with "toggle battery on"? the pi should stay off until the "power on" button (the switch in the circuit) gets pressed.

DoomyDoomer commented 4 years ago

I have a simple toggle switch on the BAT+ line before the PSU so I can quickly disconnect the battery if needed. It's just a safety feature and shouldn't impact the circuit at all. Ok, that's what I thought. See when I "connect" the battery to the PSU, the pi powers on without a button press.

geaz commented 4 years ago

That means that the EN Pin does not get pulled down to ground correctly. What causes the problem during shutdown, too. I can't tell you exactly what is wrong with this connection, but the PSU should be disabled, if EN is pulled down to ground correctly (like the power boost). I am 99% sure that this connection is the problem.

DoomyDoomer commented 4 years ago

That makes sense. The EN wire on the circuit goes to the middle extension rail which takes it to the 100k resistor (pull-down?) to GND until the button is pressed which pulls EN from GDN. This should keep the EN pin and GND pin connected and disable the PSU's 5v output. The EN wire through to the 100k resistor all tests fine on the continuity. This is very confusing. Did you have time to look over Helder's OSH Park circuit? if it looks ok to you, I think I might buy a few of those to rule out my circuit all together even though I can't find a single fault with it. I don't know what else to try at this point since all components are working correctly separately.

geaz commented 4 years ago

I looked at your pictures again and I have a question: Did you connect the circuit to the "Bat+" of the Retro PSU? I ask, because I see two wires on the BAT+ pin.

DoomyDoomer commented 4 years ago

That's correct because the RetroPSU doesn't have a pass through BAT pin like the PowerBoost. I just moved "PowerBoost BAT" wire to the 5v output of the RetroPSU. No change unfortunately. IMG_20200730_154258 IMG_20200730_154316

geaz commented 4 years ago

Hmm, was worth a try :) At this point I am just guessing...but could you try to disconnect GPIO 7 and test, if the power stays off as soon as you connect the battery?

DoomyDoomer commented 4 years ago

Powers right on LOL... So I'm talking with the creator of the PSU and he's telling me his EN is pulled high with a 10k resistor. I'm at this point beyond my knowledge level as to wether or not makes any difference to this circuit but I figured the more info I can provide the better.

Looks like the PB 1000c's EN pin goes to a 200k resistor: image

geaz commented 4 years ago

Ah I see. Switch the 100k with something >1k and <10k. Keep GPIO 7 disconnected and test, if it still powers on.

DoomyDoomer commented 4 years ago

Ok swapped in a 5.6k. GPIO pin 7 off, powers up and stays on. Connected pin 7 again and powered off with the switch, same outcome.

geaz commented 4 years ago

Did it automatically switched on with GPIO7 disconnected? Or did you have to press the switch?

DoomyDoomer commented 4 years ago

Automatically switched on :(

geaz commented 4 years ago

What the hell...I think we have to redesign the circuit a bit for the RetroPSU. It would not help you to order the OSHPark one.

I think the resistor has to be <5.6k, but I can't tell you how small exactly (I am also not an expert here :D - maybe try smaller ones until it stays powered off).

DoomyDoomer commented 4 years ago

My reaction exactly! haha I’m going to try smaller ones and see where I land. How will I know if I need to change the GPIO 7 resistor? Luckily I have a ton of resistors at my disposal.

geaz commented 4 years ago

Now that I think about it, the GPIO 7 resistor could maybe stay as it is. First try smaller resistors until the pi stays powered off with a connected battery. Then connect GPIO 7 and test, if everything works as intended.

geaz commented 4 years ago

One more thing you could test: Try to remove the resistor and add a bridge/jumper instead and check, if it stays off (just don't press the switch, otherwise you will short your PSU). Just want to make sure, that the connection is really working.

DoomyDoomer commented 4 years ago

It does indeed stay off if I bridge the connections. That said, I finally have some results. I’ve used 2.2k, 2k, 1.5k, 1k. 2.2k, Pi comes right on. 2.0k stays off BUT I can’t power the Pi on now with pin 7. I’m now going to stack up some values < 1k and see if I can get it to power back up.

DoomyDoomer commented 4 years ago

Well scratch that. 2k resistor keeps the pi down until a press of the tactile button. But get this, on long press shut down, the pi still stays halted and the PSU still remains live! Back to square one?

geaz commented 4 years ago

Just for my understanding: with 2k the pi stays powered off and on button press it powers on correctly, but the shutdown does still not work?

DoomyDoomer commented 4 years ago

Yes, exactly!

geaz commented 4 years ago

Ok, at least the powering on works as it should now :) I am again just guessing, but: It sounds like we don't get the EN Pin pulled down enough with the 2k resistor and that the remaining voltage on the GPIO 7 in the halted state is enough to keep it HIGH. Maybe we can fix this with a higher resistor at the GPIO 7 pin? Maybe 100k instead of 10k?

DoomyDoomer commented 4 years ago

That makes sense. 100k isn’t doing the trick but I’ll keep testing >. I almost thought it worked but it turned out I touched both ends of the resistor which powered down the Pi. Getting closer though.

geaz commented 4 years ago

Maybe you could also try to get smaller than 2k on the EN pin <-> gnd resistor. To do a "harder" pull to ground.

DoomyDoomer commented 4 years ago

Seems like nothing lower than 2k wants work and anything higher powers the Pi right on.

geaz commented 4 years ago

With "Seems like nothing lower than 2k wants work" you mean the powering on works as intended, but the powering off not?

DoomyDoomer commented 4 years ago

What I meant was, when I use a smaller than 2k resistor between EN and GND, the pi won't power on with a button press. 2k seemed to be the sweet spot.

geaz commented 4 years ago

Ok, did you try anything >100k on the GPIO 7 together with the 2k?

DoomyDoomer commented 4 years ago

Not yet but I plan to tomorrow. I feel like it's very close if I can just figure out the shutdown.