Electronics > Projects, Designs, and Technical Stuff
Raspberry Pi breakout board - Did I do it right?
(1/2) > >>
ryanmills:
Mostly a lurker here just learning as I go. I'm working on a controller for a simple arcade style game. The controller is basically a breakout board for a Raspberry Pi 4. I have found some conflicting information on driving an NPN with a Pi GPIO and selecting a correct base resistor. For the NPN and LEDs under "LED Tree" I could be driving most of them at once I wanted to keep the draw as low as possible on the 3v output of the Pi. The NPN's are driving either a single or dual super bright 10mm LED. The current limiting resistor for the LED will likely change because the LEDs are going into a light pipe but are likely still too bright. Not sure if the 10k base resistor is too high? The NPN is a MMBT3904-TP. And im giving the NPN a hFE of 150 to 200 based on the datasheet curve and draw I'm expecting.

If anyone has a moment I could use a sanity check just to see if anything looks grossly out of place or wrong. Note the isolation on the on the distance sensor input is because its over a very long run of a wire and I have had issues in the past. Just want to be safe. The SSR used is overkill but I have hundreds of them on hand. I don't have a lot of experience with this so any suggestions for improvements are welcome.
jhpadjustable:
Curves aren't really guarantees, so I pulled up my datasheet for Fairchild/ON Semi 3904s, which claims the dc current gain at 10mA and 1.0V Vce is at least 100. ON doesn't mention gain bins, so I'll go with the worst case of 100. 3.3 - 0.65 - 0.05V of fudge for rounding = 2.6V / 10k = 260µA * 100 = 26mA Ic. With a 10mA load, you could double the base resistor, if you really wanted to, and if you aren't one of those people who keeps a reel of 10k resistors around in case of emergency like I do, and you don't want to leave margin for later adjustment.

Personally, I'd use a MOSFET. Curves aren't really guarantees, but with a small, common MOSFET like the 2N7002, typically you could pass up to (approximately) 60mA at 25°C with essentially zero static gate current. According to some random bloke on Stack Exchange, pi GPIO output current should be limited to no more than 16mA instantaneous current per pin, so 3.3 / 0.016 = 206 ohms gate resistance, in isolation. However, total GPIO output current should also be limited to no more than 50mA in total, including your optoisolators and everything else, so, just in case you switch all those LEDs on or off at once, I'd limit all the gate/GPIO currents to 1mA peak by placing 3.3k resistors in series with all those gates. The 165ns RC time constant is negligible in the case of visual LEDs.
teksturi:
You must have 4k monitor because this is wild to look with 13" HD screen  :-DD I have to zoom in and zoom out or take the time to scroll to next part. Maybe you could tider this design a lot. Now one title letter is even bigger than resistor. Also normally inputs are left and outputs are in right. So try that and you see how much better schematic will look. Example move solenoids outputs right part of schematic and rotate them so gpio input is left and connector is faced right. Try to fit everything in space between J1 - Raspberry connector. Also name that connector also.

Why do you need so expensive ssr to basically just level shift 5v to 3.3v? It is also kinda of expensive. Same thing with relay driver. Can't you just use transistor or mosfet to drive.

Good in this schematic is that you have good titles in every sections. Nice divisions to sections. Gnd are always down. Good job.

These are just small things and you can make or not make these. I'm no expert ether and I have made my knowledge with Youtube. I have watched Robert Feranec videos and of course Daves videos.
ryanmills:

--- Quote from: jhpadjustable on October 04, 2019, 01:27:11 am ---Curves aren't really guarantees, so I pulled up my datasheet for Fairchild/ON Semi 3904s, which claims the dc current gain at 10mA and 1.0V Vce is at least 100. ON doesn't mention gain bins, so I'll go with the worst case of 100. 3.3 - 0.65 - 0.05V of fudge for rounding = 2.6V / 10k = 260µA * 100 = 26mA Ic. With a 10mA load, you could double the base resistor, if you really wanted to, and if you aren't one of those people who keeps a reel of 10k resistors around in case of emergency like I do, and you don't want to leave margin for later adjustment.

Personally, I'd use a MOSFET. Curves aren't really guarantees, but with a small, common MOSFET like the 2N7002, typically you could pass up to (approximately) 60mA at 25°C with essentially zero static gate current. According to some random bloke on Stack Exchange, pi GPIO output current should be limited to no more than 16mA instantaneous current per pin, so 3.3 / 0.016 = 206 ohms gate resistance, in isolation. However, total GPIO output current should also be limited to no more than 50mA in total, including your optoisolators and everything else, so, just in case you switch all those LEDs on or off at once, I'd limit all the gate/GPIO currents to 1mA peak by placing 3.3k resistors in series with all those gates. The 165ns RC time constant is negligible in the case of visual LEDs.

--- End quote ---

Thank you, I'm open to any ideas to improve the design. To clarify are you saying add 3.3ks on all the GPIO's like the opto's? And I will have to take a peek at MOSFET's. I still have time to make chances. I just went with the NPN because I had seen it implemented that way in a relay board I had lying around.



--- Quote from: teksturi on October 04, 2019, 04:39:43 am ---You must have 4k monitor because this is wild to look with 13" HD screen  :-DD I have to zoom in and zoom out or take the time to scroll to next part. Maybe you could tider this design a lot. Now one title letter is even bigger than resistor. Also normally inputs are left and outputs are in right. So try that and you see how much better schematic will look. Example move solenoids outputs right part of schematic and rotate them so gpio input is left and connector is faced right. Try to fit everything in space between J1 - Raspberry connector. Also name that connector also.

Why do you need so expensive ssr to basically just level shift 5v to 3.3v? It is also kinda of expensive. Same thing with relay driver. Can't you just use transistor or mosfet to drive.

Good in this schematic is that you have good titles in every sections. Nice divisions to sections. Gnd are always down. Good job.

These are just small things and you can make or not make these. I'm no expert ether and I have made my knowledge with Youtube. I have watched Robert Feranec videos and of course Daves videos.

--- End quote ---

Ha, sorry I knew the comment about size was coming. I am on very large screens and did not want to post multiple photos nor mash it all too close. I will try to scale it a bit better next time.

SSR's are just because I have a ton left over. But it is a little more than a level shift. The Pi has a max of 50ma and a max of 18ma per GPIO. Also on the input I have had issues with long runs of wire basically acting like antennas. But those SSR's are seriously overkill and will be replaced with something more appropriate once the prototype works.

And thank you for the pointers on the layout. I agree I should have ordered the input and outputs differently. I was just watching dave's hour and half schematic fix to see any little things I might be doing wrong.
jhpadjustable:

--- Quote from: ryanmills on October 04, 2019, 05:32:22 am ---Thank you, I'm open to any ideas to improve the design. To clarify are you saying add 3.3ks on all the GPIO's like the opto's? And I will have to take a peek at MOSFET's. I still have time to make chances. I just went with the NPN because I had seen it implemented that way in a relay board I had lying around.

--- End quote ---
Keep in mind the concept of margin. Avoid running components at 100% power when you can. Here, that means to avoid getting close to the 16/50 output limits. I'd opt for 1/30 mainly because SoC GPIOs are on the delicate side and I don't want to get into the weeds on advanced GPIO configuration like drive strengths. I'm sure Adafruit has written a ton on the subject of care and feeding of GPIOs, in case you want something to binge-read this weekend.

The 3.3k only applies to the gates of the MOSFETs. The NPN transistors are fine with 10k resistors on the base. Both need current limiters on their control terminals, but for different reasons. The LED outputs are good enough as drawn.

Oh, and one more thing: put diodes across your mechanical relay coils (in reverse, cathode goes to + side) to keep the turn-off current spikes down. Then it will be safe to replace the SSRs with transistors just like you did for the LEDs. In that case, reduce their base resistor just as you and I calculated before.
Navigation
Message Index
Next page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod