Introduction: Pinebox Electronics Build
This instructable is continuing the prototyping and build of the custom power supply, power management, monitoring and interfacing electronics design for PInebox (a portable Raspberry PI computer)
It follows on from (and corrects some parts of) the PInebox design instructable, which shows the building blocks of this project.
Step 1: Build Preparation
At the end of the last instructable, I was waiting for the finished PCBs for four boards to come back from manufacture.
Note: A couple of minor errors crept in, due to not sending the final final revision :( Nothing major, but a couple of corrections to the silk screen positioning, and a "restriction" on running tracks through the middle of my solder-jumpers. I know there is solder-resist there, but it seems a bad idea.
Note: All other known errors/tweaks discussed below have been corrected in the schematics and PNGs attached to this instructable.
Before assembling the PCBs, the helper boards PCB need splitting into 9 mini PCBs, which is easier to do before populating the boards.
Cut along all the heavy white lines, starting with two horizontal full cuts, then all the vertical cuts, and tidy up the edges.
This will involve cutting through some tracks that cross the lines, but they are non-critical tracks that pass from board to board, and are designed to be chopped through. They only exist to appease Eagle's router.
I pre-formed all the leads for components to check all the footprints matched, and replaced some proto-typing parts (massive pots, parts on leads) with the correct pieces.
Step 2: Preparing for Testing
I mounted up all the split PCBs on a scrap piece of MDF for assembling and testing, using brass screws into pilot holes. This is so much more accessible than trying to do it inside the real wooden case!
"Tethered" interconnections wires will be left over-long, so that they can reach from board to board when spaced out like this, and trimmed later at the board-soldered end.
The Raspberry PI and two DC-DC converters will join these boards later, as shown in the last picture, from later in the testing process.
Step 3: Building Helper Boards
Let's get the smaller, easy bits out of the way.
All parts are mounted on the component side, but some cables will (later) be mounted from the reverse side of the board, depending on how the board is mounted in the case.
Note: I forgot to mark pin 1 of the connectors on the BACK of the board, as a number of these boards go face down in use. Corrected by adding a small "1" copper track next to pin 1.
The LED lengths need to be adjusted to match the switch height, plus case (wood) thickness so that they lie flush to the outer surface when mounted.
The power LED is bent across and in, to be closer to the power switch.
On PAD401-402 add a short wire tail, which will lead to the case-closed reed switch later.
These boards are mounted "face down" in the case in normal use.
LED lengths should be adjusted to match the case holes, so that the board can mount flat with the LEDs in the correct position, before soldering -- easiest to do this with the boards mounted in the box, with the LEDs loose.
The "rear" LEDs pass though two holes in the wooden case, and are slightly spaced off, the "front" LEDs press against a diffuser and are flat to the board.
LIRC (Infra Red control):
This board is also face down in use. The LED and IR receiver touch a glass window. The IR RX chip needs to be folded flat to the board as shown (I've since moved the pads down a little to make this fold less extreme!), and the capacitor in the top right corner needs to be folded flat to the board.
This board attaches to the side of the camera-spinner. A pair of 2-core "tails" will wire to the microswitches on the spinner to sense its direction.
Step 4: Adding Tethered Tails-sockets
All of the boards above have tethered "tails" attached, with molex crimped connectors terminating them. Later, after testing, the soldered ends will be shortened to get the correct lengths.
Clearly mark pin 1 on all sockets/plugs to avoid accidents!
The battery pack, speakers, power switch all need pairs of wires attaching, mostly to 2-pin sockets. The power switch was hard wired in the end.
And last, the camera-switching board was soldered to the dual microswitch on the camera spinner.
Step 5: Adding More Tethered Tails-sockets
Also, I put short connector tails on the two DC-DC converters. But these were set to the correct length in the first place, for mounting them next to the main PCBs.
For the 5V buck converter, I connected the VIn, and GND wires at the mini screw terminal, VOut is soldered to a track next to the positive side of the output capacitor. Also two additional wires pick off the voltage-adjust pin (yellow wire) and under-voltage-lockout/shutdown pin (orange wire) of the KIS3R33 module.
For the 29V boost converter, all leads were soldered to the board pads directly, no mods needed.
Both were protected/supported with a short length of heat-shrink sleeving, before the crimp connectors were fitted.
Step 6: Building Power Board 1
During this step it's important to use dummy loads (3 x 2 Watt 100R resistors) and indicator LEDs as a substitute for the PI, HDMIPI screen and USB hub! Otherwise, something expensive will get damaged ...
Board Mod 1: I eventually combined PAD105/PAD107 (two 5V rails) in parallel. This helps spread the load of the HDMPI screen and USB devices across both FETs, which are driven together anyway.
Board Mod 2: I also had to move the battery charger output to the other side of the isolation switch (from the original design) so that the boost converter would continue to power the CMOS rail when on external power with no batteries / isolated battery.
Mount the 5 surface mount FETs first, as they are very fiddly to locate correctly once other parts are around. Then fit all the other through-hole parts except IC101, IC102 -- just fit empty sockets for now.
Note: C102/C105 lay down off the edge of the board so they don't hit the PCB above. The D9 plug should be firmly bolted to the board before soldering, to reduce stress on the legs.
I included long wire leads for F101 (to check and record currents in line with the battery), and for ZD104,D109 (to check and adjust the over-voltage protection), R125 (to check and adjust the 5V to 5.3V lift mod), which is why these parts are missing in the pictures.
The long wires go to an adjacent breadboard with the missing parts on.
Long wire leads were also put on PAD103-104 (Pi Power) PAD105-106 (USB power) and PAD107-108 (HDMIPI screen power) to connect to three dummy loads/LEDs as mentioned above.
Step 7: Testing Power Board 1
There may seem a lot to adjust and test here, but it comes from a well-founded paranoia that just because something should work, it doesn't mean it will. Test and prove in sequence ... or switch on and hope, then wonder which part smoked first :)
Note: When fitting/removing ICs or connectors at any stage, turn off power sources, don't add and remove things "live!"
CMOS power supply
With a variable PSU (range 16-23V) connected in place of the battery, check the CMOS voltage rail is present (9-15V max).
5V rail adjust
Now connect the DC-DC buck converter to the board, and check that the 5V/1 (raw) and 5V/2 (Pi protected) rails are at 5.3V. Note: R125 was adjusted to 43K to bring this up.
Check that the 3V3 rail is present at C116, or pin 12 of CN110.
At this point 5v/3 (USB and HDMI PI) is not enabled, so won't be measurable. Nor will the "Power" LED on the keyboard come on, as it is cut off along with other loads, by the "power save" circuitry.
With the DC-DC buck converter disconnected, feed the external variable power supply at 4.9v directly into CN103 pin 1 (+5v in), and monitor the 5V/2 voltage line. Raising the power supply to about 5.6-6.0V should cause the 5V/2 line to cut out. Reducing the supply back down to 5.4 or below should re-instate the power.
If the voltage is not correct, adjust ZD104 up or down (4.7V, 5.1V, 5.6V) and remember that the extra diode D109 adds about 0.7V -- this can be replaced with a wire link if not needed.
Note: If the overvoltage is set TOO LOW it will falsely trigger when a heavy load comes off, causing the power supply to slightly overshoot. This happened during testing, hence changing ZD104!
Reconnect the buck converter.
Undervoltage - battery
Now with the external PSU connected as the battery, at 16.0V, drop the voltage slowly until the power goes off to check the battery UVLO operation, R114 should set this to be 14.4V. This is the voltage at which the battery pack is considered "dead" (0.9V/cell).
Now a charged battery pack can be connected to power it properly.
Undervoltage - external/switch over
Fit IC101, and connect the external PSU -- this time as an external power source, to the DC jack, at 12V
When the "external power" supply is on, lower the external voltage from 12V down to 8V and ensure that it switches over to running on batteries BEFORE the UVLO kicks in to say "external power is too low".
Otherwise power will drop out when external power fades away, due to the voltage being too low to work, yet high enough to still be detected as "external power". Accidentally discovered in testing, and fixed here :)
This lower UVLO limit of 8.8V should only ever be hit if the batteries are disconnected/failed and the external supply is too low.
To adjust the UVLO point, change R113, which is currently set for 8.8V, which was correct.
Note: To adjust the external voltage sensing, I changed R104 (to 4K3). This now detects about 10.4V as the minimum to consider external power as "good", previously it detected down to about 5V -- which is too low to work.
Now fit IC102
At first connection of the battery, the power switch will not work for at least 10-20 seconds. Thereafter, a short press should turn the power ON, further short presses should do nothing, and a long (at least 4 seconds?) press should force the power back off.
An external signal source is needed to check the software controlled power-off feature. I used a small 4047 based oscillator board (first seen in the design instructable) to inject a short low frequency tone into P21 CN110. After about 45-60 seconds, the power should go off. Otherwise, it can be tested later using the PI from software.
Step 8: Building Charger/pass Thru Board 2
Note: Due to a possible error in the Eagle TO220 footprint vs real life parts, the mounting hole for IC202 does not line up correctly. It would mean bending the legs at a hard 90 degrees next to the chip. So I filed the hole outwards 2-3mm to align it. Fortunately, this didn't hit the tracks next to the hole. These tracks have been moved in the current PCB designs, to allow space for this correction!
Mount IC202 first, and bolt the heatsink and insulator down before soldering it. The insulator prevents the whole heatsink being at +29V. The bolt also has an insulator around it (a "top hat" mount).
Fit all the parts except IC203 (socket only), and leave the soldered jumpers open for now.
TH202 has long legs, to space it away from the board and other components (I moved it further away in the current Eagle files). Sleeve these, and fold it almost flat to the board as shown
SK203/204/207 need tethered leads, overlong, with Molex crimp connectors at the other end to connect to board 1. These will be trimmed later (and soldered to the underside instead,to lead down to board 1).
Note: R207 is "in the air" because I wasn't sure if the value was right. It was, and got nailed down properly later ... R201-202 are "in the air" because they get warm, and so have remained there.
Step 9: Testing Charger/pass Thru Board 2
Note: When fitting ICs or connectors at any stage, turn off power sources, don't add and remove things "live!"
First make sure that the boost converter is producing 29.0V -- do this out of circuit, and with a low input voltage e.g. 5.0V -- then connect it to the board.
Board 1 and 2 need to be connected via the three interconnecting leads, and the probe thermistor must be connected to CN205 and attached (thermally) to the battery pack.
Fit IC203 and apply an external power supply of about 12V to board 1's DC jack.
Check current into battery
R201 (high current) and R202 (low current) adjust the charge into the battery. The current can be measured where F101 (on board 1) is not fitted, with a current meter in series.
The battery pack will probably start by "bulk" charging at the higher current, so you can check that 300mA is flowing INTO the battery. Bridge across CN205 (the thermistor connection) with a 10K resistor to make it go to trickle charging -- it will think the battery is hot when you do this. Current should drop to 60mA into the battery.
Temperature cutoff adjust
Note: I adjusted R205 for a better adjustment range on the pot.
Note: Despite previous descriptions and silk screen, turning VR201 CCW allows higher temperature here.
I used two thermometers to monitor ambient and battery temperatures, with VR201 turned all the way to CCW end.
After a period of charging where nothing much happens, the battery starts to warm up. When the battery pack was 13'C above ambient, I turned VR201 slowly clockwise until charging JUST stopped (and the "BCHG" LED went out).
In future, bulk charging will cut off when the batteries warm up by this amount.
Power for projects
Lastly, check the regenerated 5V appears at CN202 P2 and P4, and that the regenerated 3V3 appears at P1,P17. This will power external add on projects, instead of the PI doing it.
Step 10: Raspberry PI Mods Redux
This step was covered back in the design instructable with minor changes as mentioned here.
Five signals are picked off the Raspberry PI (Model B 2) and brought to an added five pin header socket on the PI:
- I2C clock and data (from the 40 pin header)
- The SD-card activity light (from the LED's other side: Not PP13 as previously hoped)
- The net-jack LEDs (for network activity lights)
You will also need to solder a pair of pins into the PI at the "run" pins located next to the DSI connector. The outer pin is "0v" and the inner pin is the "Run/Reset" line.
Similar (single) pins were added to the memory stick and wifi dongle, look back to the design instructable for details.
Step 11: Building Upper IO Board 3
Again fit the SMT chip first and check for shorts between pins, and check all pins connect where they should.
Fit all other parts, remembering the links LK302/LK303.
Leave out IC301, IC303 and IC304 (but fit sockets)
Make the flying lead to pick up essential signals from the Raspberry PI (I2C, Net LEDs, SD card LED) and from the modified memory stick/wifi dongle (activity LEDs). Again this lead will be shortened at the PCB end later, so make it over size.
This lead is constructed from the same type of turned-pin IC socket that the Raspberry PI pickup connector was made from. The single pins are just individual pins from the socket, pushed out and soldered on to the end of the wires. A small insulated sleeve protects/strengthens this join.
Make the 2-pin "reset" molex lead (this provides the common ground between this board and the PI, during testing).
Fit a 26 way IDC lead between board 3 and board 2.
Step 12: Testing Upper IO Board 3
Note: During this step, have the Raspberry PI/HDMI PI screen and USB peripherals (modified memory stick and wifi dongle) externally powered (e.g. a 5V USB adaptor), but connected by I2C and a common ground.
There will be things happening to power rails during testing that will be hard to test if the Raspberry PI actually loses power!
Note: When fitting ICs or connectors at any stage, turn off power sources, don't add and remove things "live!"
First check that 5V is present at Pin 8 of IC301 and that 3V3 is present at pin 1 of CN304
Connect up the Raspberry PI to the I2C/Reset/GND pins, and two flying leads (memstick, wifi) and power it up.
With the Raspberry PI booted and running, check the LED repeater works for the four green LEDs.
Note: I made some changes to the handling of the Net-Jack LEDs here (simply adding two 1K resistors in line, otherwise the input levels were wrong). This is why MOD pads were left on board 2 and 3, just in case of errors requiring extra parts!
When accessing the SD card, the "SD" LED should blink on in sympathy with the Pi's ACT LED.
When accessing the WiFi dongle, or when the Pi is probing for an access point, the "WF" LED should blink on at the same time as the WiFi dongle.
When accessing the mounted memory stick, the "MS" LED should blink on when the memory stick's LED blinks off (for active) -- note the reversed sense, hence the MsInvt SJ302 jumper being bridged on board 3!
When the net jack is disconnected (no LEDS at PI), or plugged in and idle (both LEDS at PI) then the "RJ" LED should be off, blinking on if there is network activity, e.g. "ping a-host.somewhere.com"
And to test the reset button, shut DOWN the Pi (with "sudo halt") but leave it powered up, and then press the reset button to wake it up. Don't use it to actually reset the Pi, unless you absolutely have to. If it works to wake it, it works to reset it!
Low Battery/Power Save
Time to set VR301 for the "low battery" point, this needs an external PSU to replace the battery, and of course disconnect the actual external supply (DC jack) so that the charger doesn't try to charge the PSU!
With an external power supply in place of the battery, range slowly from 20.0V down to 12.0V -- at some point the "Low Batt" LED should come on. This should be at 16.0V (1.0V/cell). Once it has tripped, you will need to raise the voltage at least 2.0V to clear this indication, due to hysteresis (R308).
Repeatedly adjust VR301 and drop the power supply down until crossing 16.0V trips "Low battery". At which point, raising the voltage to 18.0V (approximately) should clear the low battery setting.
It's important that this 2.0V window is there, to prevent this circuit oscillating: The battery voltage WILL rise when excess loads are shed. This is NOT a good enough reason to put the loads back on! Off! On! Off! ...
When the low battery LED comes on, the 5V/3 rail should go off as should most of the other LEDs for the keyboard panel, due to "power saving" mode.
Note: VR301 was also incorrectly marked up, it's "CCW is higher cutoff voltage"
Note: R129 adjusted and D110 added to make this work correctly -- with so many LEDs now pouring current into the switched ground line, it was obvious that Q111 wasn't biassed on enough before! This lead to the FETs not switching off properly!
Also check that shorting the "case-closed" wire tails (for the reed switch) causes the "power save" to activate, cutting LEDs off and removing the 5V/3 rail.
Connect up the front and rear flash boards.
Fit IC303 and IC304
On the Raspberry PI: Boot up and test you can see these i2c GPIO devices at all with "i2cdetect -y 1" which should show two devices at 0x4F (ADC/DAC) and 0x27 (DIO).
Using the test script "other-inputs" (attached at the last step), and with the external PSU still acting as a "battery", check the ADC range (from about 11.0V to 23.0V max) and record ADC values for these start-end voltages. They are used for software calibration later, to convert ADC readings to voltage. e.g. 54 = 14.53V, 170 = 22.90V
Now check that the "Low Battery" warning (which will engage, at the low end of this test) is correctly detected in the GPIO test script.
Then short out the "case closed" (reed switch) and check that it too is correctly detected.
Removing the external bench supply (fake battery), and replacing the real battery at this point, test that the internal-external power detection works when external power is provided.
Check that pressing the power button can be detected: Hint, don't hold it down for 4 seconds or more! Press it, run the script, release it.
Using the "flash" script, check that the flashes fire correctly (the test script turns on one, then the other), and reads back the camera direction switches.
And finally using "power-force-off" script, check that the power can be turned off from software, after a delay. Note this will put ALL of the power off, including the Pi's 5V rail so this is why the PI must be externally powered still!
The script sets the pin as output, high and low, slowly, and nothing should happen. Then it drives it fast. About 45-60 seconds later, the power should go out. Pin 3 of IC102 should go high as soon as the AC drive is detected, and when it falls back low, power is cut.
Step 13: Back to Testing Board 2: RS232
Now the PI is connected up, it's time to test the serial port. Configure the PI's serial port to be free for use by user programmes -- the linux kernel uses it otherwise! Then install and configure minicom (more on these steps in the software instructable).
A 40 way IDC lead is needed between the Raspberry PI and board 2 CN201 -- I used a long IDE hard drive lead.
Bridge the jumpers SJ201/SJ202 in the "Use 1-2" direction (not "Pass 2-3") to redirect the PI's IO pins into the MAX3232 chip.
Put a "loopback" wire between pin 11 and 12 of IC201 (which should still be missing) and check that characters sent from minicom are echoed back. This is looping back at 3V3 PI levels.
Without the wire, nothing should echo back. Note: that if you have "local echo on" in minicom, you will see characters without the wire, but you will see ttwwoo ooff eevveerryytthhiinngg with the wire fitted. This is normal, and shows it is working!
Then (with Raspberry PI turned back off!) fit IC201, and put a jumper wire either in CN106 (both pins shorted together) or the RS232 connector (Pin 2 to 3) and repeat the above loopback test. Now you are looping through on the RS232 side.
Step 14: Back to Testing Board 2/3: LIRC
This step assumes that you have LIRC modules and support installed and configured for GPIO 17/18, which is the current default, and that you have trained it with some remote controls. I already did this during prototyping, but will write it up properly in the software instructable.
With the PI turned off: Solder across SJ203 1-2, SJ204 1-2 to assign the GPIO 17/18 to my LIRC module, and also solder SJ205 2-3, SJ206 2-3 to pass on GPIO23/24 to the other 40-way connector.
Boot the Raspberry PI and check that LIRC is receiving pulses from the receiver, and that transmitted codes are leaving the IR leds and controlling devices.
Step 15: Power Tails
Now that everything seems to be working and adjusted, the dummy loads can be replaced with the real power tails to power the PI, display and USB hub. These are all slightly over-size too, and may need shortening later.
The micro-usb tails are made from a micro-usb to USB lead, cut to length. The screen (shield) is cut away, the green and white "data" pair folded back and a heatshrink sleeve slipped over to insulate it all.
The mini-DC jack tail is cut from the original PSU supplied for this USB hub. It has a tiny (1.0?) mm DC barrel jack.
Using this to power the PI (on 5V/2 - always on) HDMI PI (on 5V/3 - sometimes on), I checked the +5V rail at the PI, USB hub and HDMIPI when properly loaded. Slight extra drops are introduced due to the cables and micro-usb connectors.
5V/2: Raspberry PI (on-board) 5.08V
5V/3: USB Hub (output port) 5.30V, HDMI PI (on-board) 4.99V
Note: A capacitor C117 was added to the "power saving" feature to slightly slow this rail cutting in and out. The HDMI PI display "gulps" a sudden in-rush when powered up which was causing dropouts in the +5V/2 rail, making the PI power light blink, and sometimes even reboot. That wasn't expected, but is now fixed.
Step 16: Audio
Note: Among design, prototyping, and doing testing, I've changed the audio handling slightly.
Due to some limitations of the USB soundcard I'm using -- which I may change later -- I can't use the line in AND mic in. There is no way to switch between them in alsamixer, as the device only shows one input option. The device seems to sense in hardware that a stereo line-in is connected and overrides the mic, and yet still records in mono!
So for now :-
Device 0: Raspberry Pi Internal
Broadcom internal sound (at RPI jack): Ignored due to reduced quality.
This audio is also sent over the HDMI lead to the HDMI PI: The DAC there works well, so this is connected down to the in-built speakers and the rear "Headphone/line out" jack.
Device 1: USB Audio device
This only records in mono, despite stereo playback and a stereo line in connector.
This will only record from one input. If a mic is connected AND a line in, the line in overrides in hardware and alsamixer can't do a thing about it. So this is connected to the single electret mic in the computer's lid, and used to record in mono from that.
Line in jack: Idle, but connected through to the upper board pads, pending a bright idea or change of sound device!
Step 17: Attachments
Here we have :-
- A correct parts list for the custom electronics
- Full connector assignments/pinouts
- Eagle schematics/board layouts of version 1.03 (zip file)
- 600DPI PNGs of the top, bottom, silks, total board (zip file)
- 600DPI PNGs of the schematics (zip file)
- LTspice sims and plot settings/model files for LM339/4000 series (zip)
- GPIO test scripts (zip)
Step 18: Next ...
Next step is to finally fit all this into the case, and finish off the keyboard woodwork/back panel to match the PCBs.
Back to top level project
We have a be nice policy.
Please be positive and constructive.