Electrics, part 2 of ∞

29 Jan 2016


Boat (27) 
Not the Boat (12) 


Recent articles

25 Apr 2017

Ubuntu 16.10 LXC host on ZFS Root, with EFI and Time Machine

Still completely unrelated to boats, but I needed somewhere to put this. Here is a blow-by-blow guide to installing a minimal Ubuntu 16.10 to a ZFS root, booted from EFI, which as used as a LXC host to act as an Apple "Time Machine" destination.
mike 25 Apr 2017 at 17:20
14 Mar 2017

How to connect any serial device to the internet

A completely generic script that will proxy serial devices over HTTP, turning USB-things into internet-things.
mike 14 Mar 2017 at 23:00

Power switching

I've had this installed for about a year now and it's working very well, so I'm finally prepared to go public - while there are a few changes I would make, the system works. I've previously outlined the broad design goals. This one will focus on the implementation.

I wanted every circuit to be switchable manually or from a computer, and to be able to monitor current through each circuit. This means the following decisions.

  1. With two control points, the physical position of the switch cannot show its state. So you have to have a light next to the switch to show whether its on.
  2. This implies either a normal toggle switch, and you ignore the position, or you use a momentary pushbutton which has no visual "state". Pushbuttons are cheaper, smaller, have longer MTBF, and can come with an integrated LED.
  3. Are you switching power directly or indirectly? If directly the power for the circuit runs through the switch: the power for the fridge runs from the bus bar, through the switch to the fridge. If indirect the switch sends a control signal to a switchboard located elsewhere, which switches power to the device.

Direct switching looks simpler until you try to wire it: you have a lot of bulky cabling to route to your switchboard. If you want circuits to be electronically switchable, you need relays wired in too. And the most likely point of failure is the switch or the connections, which is carrying a high current.

By contrast, indirect switching means you can use simple, low-current buttons, which means smaller wires, a simpler install and less chance of cocking it up. It makes remote-switching easier: you only have one "switch" (typically a relay or MOSFET), but with two control signals. The downside is you need some sort of microcontroller.

Switching and distribution

Four distribution boards mounted on busbars. Wiring will be tidied up before splash! I went through a lot of designs before I found one I'm really happy with. I have four "carrier boards, each with six switchable circuits built around the Infineon Profet (BTS6133 and BTS5231). This is a high-side MOSFET designed for automotive systems, and it has a lot of advantages:

  1. It has been tested against fairly rigourous automotive environments and standards.
  2. Very low Rdson means they can handle high current loads.
  3. Consumes negligable power, unlike a relay, and is considerably less prone to failure.
  4. It's a high-side switch, so you never have a line energised to 12V but with ground disconnected.
  5. It reports current passing through the device when activated.
  6. Integrated current reporting can be combined with a microcontroller to act as a fuse.

The distribution boards are screwed directly to bus bars connected to the battery - there are six of these circuits per boards, four with 10A capacity and 2 with 1.8A. Connections are heatshrink rings for the negative pole and heatshrink 6.3mm Faston Tabs for positive - these are rated to 20A. I don't understand the preference for ring terminals over tabs in marine use, as being able to disconnect something without a screwdriver looks like a useful feature to me.

Each distribution board is connected to a daughterboard behind the switch panel, which relays information on the switches and LEDs back to the carrier board. There are only four wires between the boards: power, ground and two control lines to control 6 buttons and 8 two-color LEDs. Wired directly this would require at least 23 wires.

The carrier board is also connected to the computer via USB, but is independent: the computer doesn't have to be running, and I can disconnect one board without affecting the others.

Each Profet is connected to a microcontroller which monitors the current output by each device (on ADC2) at 14kHz, and cuts the circuit if it goes above a configurable level by pulling TRIG2 low. I can reset the circuit electronically: There are no physical fuses, excepting the 100A main battery fuse.

Is it safe? You should hope so, as chances are this is how things are done in your car. There's a paper on the topic here which seems to think so. The Profet needs an active signal to turn it on, and the MCU watchdog ensures it won't hang in the "on" position.

The constant monitoring means I can fuse based on average current over time. Fuses are normally oversized to allow for a brief inrush current when the device is turned on, but it's average current over time that's going to heat the wire, and the fuse is there to protect the wire. Plus I'm never going to be fiddling about with fuses in a cramped space, and "fat fingers" are the number one cause of failure in any system.

Anyway, that's mostly detail for the inspector that will be inevitably assigned by the insurance company before I launch, and to whom I will need to justify my wiring ratsnest. Hi Mr Inspector! Satisified now?

For kicks I also calibrated each circuit with a current sink. This turned out to be very necessary, as the BTS6133 Profet is designed for about 8A of load, and showed a lot of variation in output when carrying just 200mA. The variation was consistant, so calibration removed it to a point - although under about 200mA I couldn't get any sort of accuracy.

The switch daughterboard

The foamboard surround epoxied into place. The gaps will be filled and sanded back Lasercut acrylic board and foamboard surrounds. The circuit labels changed in the second iteration I had my design lasercut out of 5mm black acrylic, which means I could engrave the switch labels. I fitted into a space made for it next to the companionway. I made a surround out of 5mm foamboard and epoxied this into place, then fed the wires I'd need through conduit to the box.

The wiring between here and the distribution boards was simple - a USB cable, and four wires carrying control signal and power to each of the daughterboards that control the switches.

Wiring hell. 22 buttons, 8 LEDs, 2xUSB, 1xEthernet, 1x12V power, 1xAC power, 1xLCD.<br/>Note four daugherboards and a USB hub in background, and board providing dedicated GPS for the VHF

The wiring of the panel to the daugterboards was not so simple!

Each of the 20 buttons has four wires, two for the switch and two for the LED. I couldn't find the buttons I wanted so I ordered a custom run from a company I found on Alibaba, Daier. This was a pleasantly painless experience: my 40 x IP65 22mm momentary buttons with a bidirectional LED (green or red depending on polarity) were only a few dollars a piece.

I only wanted to wire this once so went a bit to town on the board. I have a PIR motion sensor (for the alarm), indication LEDS for everything I might want to know about - I tried to find a brown LED for the "holding tank full" alert, but they don't make them apparently. There are two USB ports for charging phones, an ethernet socket (it's an IT thing), a 12V socket and a 13A mains socket, suitably isolated from the DC wiring. I also put in a small circuit board with a 16x2 LCD and a rotary encoder, which connects to the main computer via USB. The dial adjustments are relayed to the computer, which controls the screen directly so can show anything I want. Normally it's a clock, but through this simple interface I can control the whole boat, monitor power, position, speed, wind, tank level - any data the computer has access to. It's a useful backup to the main MFD display I've yet to design.

Please excuse my skanky gloves in the video, it's winter and there's no heating in the shed, where (as you can see from the display) it's a balmy 7° and 1023mB. The wiring is a mess and everything is covered in dust - it's a pigsty, but scrubs up nicely.

And here's a provisional view of what that MFD might look like

Price estimates

That's tricky to do as the boards evolved over time, but I can give some ballpark figures from memory

  • Bus bars: four strips of copper, tapped and tinned: about £70. The "big ticket" item. You can just see these behind the boards in the first photo.
  • Bus bar supports: two, 3D printed - about £30 including shipping, probably can be done cheaper. Barely visible at the very top of the first photo.
  • PCB boards: $12 each for the main boards, plus about $6 each for the switch boards
  • PCB components: the main items (Profets and CPU) came to about £17 - that's for two CPUs, one for the main board and one for the switchboard, and four profets. The remaining items were pretty cheap, a mixed back of small mosfets, resistors, capacitors, LEDs and connectors. Call it £22 per pair of boards (main board and switchboard)
  • Fuse panel: laser cut from acrylic, about £25 I think. More if you keep getting the size of the sockets wrong, like I did
  • The switchboard buttons: don't recall exactly, but I think about $100 for 40
  • There are other items - 6-core cable, lots of heatshrink ring and 6.3mm spade connectors, acrylic spray to waterproof the PCBs, M4 machine screws and locking washers to secure the ring terminals to the PCBs, USB cables and a hub to connect these to the computer, and some M6 copper bolts threaded through the bus bars to connect the heavy cable from the battery. No pricing on these, but nothing was outrageously expensive. Except for the crimping tool for the Molex KK connectors I have standardized on. Now that was expensive, but worthwhile if you're doing hundreds.

All up, including a generous rounding error but not including the time and all the false starts I made to get here - which were considerable - that's about £360 all up for 24 switched circuits - about USD$550.