After a few months of designing, prototyping and waiting for all the components to arrive, I finally had enough to build a working, install-able prototype of my Dual Battery Management system.
DBMS installed on Yuba
It is still a prototype, and like all prototypes is too big, too heavy and too expensive. I am not an electronic designer, and despite dabbling for over 50 years, I am still incompetent with most aspects. So this device uses pre-made off the shelf components. If I was to have a thousand made in a factory somewhere, it would be a single board in a tiny case.
Even when the components finally arrived, I was still adding ideas and concepts, the most recent being adding a power meter to aid testing and development. More about this in another post. But it did involve a rather large “shunt” – a device which copes with large ampages, has a very low resistance, and allows amps to be translated into millivolts for measurement.
As you can see, it is large, 130mm long, 30mm wide and 38mm high, and heavy (250g?). This spoiled my proposed layout even into the new larger case I am using.
Case half, end view
Case half, side view
This case is 140mm long, and its internal width is 108mm. It comes in two identical pieces, which slot into each other along the edges, and has two end plates which hold it all together. Not by design waterproof, but I can work on that.
So I spent many hours arranging and rearranging components until I was happy enough with the layout to commit to cutting and drilling stuff.
Basic layout of components
First in was the shunt. A fair chunk of the 130mm length was the plastic plinth. The case half comes with a slot for mounting printed circuit boards (PCBs) in. The actual internal width of the case is 110mm, but the “groove” consists of two ridges along the length of the case, about a 1mm high, one at 8mm and the other at 11mm from the bottom approximately. I very carefully cut the plinth to exactly 110mm wide, and then cuts slots in the ends to match the PCB groove. The shunt now slides into the case and is securely held by the PCB groove.
The two relays were fitted next. These have heat sink plates built into them, so are held securely to the base with 4mm countersunk setscrews and nuts, with a smear of thermal paste to make good contact with the case, just in case they get warm. As the are well overrated for the task, this is unlikely.
Next in is the DC-DC converter, from up to 50V to 5v 3a. This is required to power the Arduino microprocessor, yet to be fitted in this photo.
Finally, a rectifying diode (two diodes with a common cathode) was attached to a piece of heatsink, which was attached to the case with a 2.5mm set screw, and a smear of thermal paste, but again this is well over specified for the task, so it is not likely to get warm. Its purpose is to take power from both batteries without allowing the batteries to discharge through each other, but provide a voltage to the power supply regardless of which battery is attached, or if both are attached, whichever has the highest voltage.
At this point it looks quite nice, almost elegant!
High Voltage, high current wiring added
the next step was to drill the end plate and install the 3 main high voltage, high current wires. These feed the two batteries into the device, and feed power to the motor controller. The bottom two wires are the battery wires. The ground wire from each of these goes to the same end of the shunt, crimped into high current eye connectors, and bolted down very securely to the shunt (M8 bolt!). The live wire from each does to the positive connection of a relay, one to each relay. Again, high current eye connectors under the retaining screw of the relay.
The negative side of the outputs from the relays are both connected to the single live wire of the cable which goes to the motor controller. You can just see the red wire between the two relay terminals. The ground wire from the motor controller goes to the other end of the shunt. The motor controller gets power from whichever relay is turned on at the time, and the relays ensure there is no possibility of one battery discharging through the other (so long as only one relay is on at a time). The power returns from the motor controller, and passes through the shunt back to the batteries. The minuscule resistance in the shunt causes an equally minuscule voltage drop between the two ends of the shunt (50mV at 100A – so 5mV at the usual 10 amp usage while the motor is running).
Still looks pretty good, eh?
Low current wiring added
So here we have added most of the low current wiring. First of all wires are run from the positive connections on the output of each relay to the anodes of the rectifier diode. The cathode of the diode is connected to the input of the DC-DC converter. The negative of the DC-DC converter is connected to the battery end of the shunt, which is used as the common ground for the whole device.
The output from the DC -DC is 5V up to 3A, which is connected via a micro USB cable to a SparkFun ProMicro arduino clone (from now on called the arduino). This is tiny (30mm by 17mm) and I am using it without header pins, soldering directly to the board. The arduino and all its connections are shrink wrapped in clear tubing, and mounted to the top of the relay with a piece of double sided foam tape. The ProMicro does not have mounting holes.
There are minimal connections into and out of the Arduino. Firstly there are two inputs, which allow the arduino sense the voltage of each of the two attached batteries. Wires are attached directly to the positive side of the relays again, and are attached eventually to the analog A0 and A1 pins of the arduino. However, the battery voltages are in the rage 33-41V, and cannot be connected directly to the arduino, which operates at 5V maximum. To drop the voltage voltage splitters are used, these are simple a pair of resistors, 390k ohms (r1) and 30k ohms (r2) connected in series between the +ve from the battery and earth. A take off is taken from between the r1 and r2, which is connected to the analog inputs of the arduino. The splitter formula is
Vout = Vin (r2/(r1+r2)
or in this vase Vout = Vin * 30,000 /(30,000+390,000)
which works out to Vin/14, or 3V maximum with a 42V Vin.
The splitters are the lumpy red shrink wrapped wires running from the arduino up the side of the shunt.
The second set of connections is the output from the arduino, which is through digital pins D6 and D7.
These are set to high or low depending on the programming of the arduino. In this case, every 150,000 milliseconds, the arduino tests the voltages of the two batteries, and sets one of the two pins to high, and after a 20mS delay, sets the other to low.
D6 and D7 are connected to the positive side of the input end of the relays (the end at the bottom of the pictures, the thin orange and yellow wires). The negative terminals of the relay are connected to the GND pins of the arduino board.
The net result is that the relay for whichever battery has the highest voltage is switched on, and 20mS later the other is switched off. The slight delay allows the relays to do their job, but the time is not enough for the batteries to do any damage.
The last connection is a wire between the negative of one of the relay inputs to the common ground on the shunt, which is just an extra safeguard to make sure the arduino is connected to the common ground directly, not just through the DC-DC converter.
OK, one final connection …
In this picture an output cable to the Power meter has been added. This has three connections.
First is a positive connection, which as this provides the voltage for the voltage part of the meter, is connected to the positive wire of the motor controller, where it attaches to the -Ve connection of the relay output!
Second is a connection to the common ground at the bottom end of the shunt. This acts as the GND for the meter, as well as one of the ammeter connections.
Thirdly, a wire is connected to top end of the shunt. This is the other ammeter connection.
Fortunately, the Yuba Mundo has stacks of room, and as many 5mm lugs welded in to the frame as you could possibly want.
I chose to install it in front of the back wheel, behind the bottom bracket. This meant for easy, short cable runs.
The case comes with T slots down the side of the case, you can see them on top of the device above, and in the end view photo at the top of this post.
I got some 1/8″ set screws, and filed one side of the head so that the screws slid into the T-Slots, and were held secure when the nuts were tightened on them. 6 of these bolts, three in each side of the case attach the case to a piece of 3mm aluminium plate, 40mm wide, and 200mm long. Mounting holes and brackets to fit lugs on the frame were added, and the whole device is securely and neatly mounted onto the frame of the bike. Wires from the two batteries connect easily to the device, and the wire from the motor controller plugs in to its wire. The power meter wire is threaded around the bike, and connected to the power meter which is on a bracket in the centre of the handlebars.
At this stage the power meter is not waterproof, so will be taken off when used in rain, and the device itself needs a bit of waterproofing also, which it will need sooner rather than later, as it is not easily removed.
More to come on first rides, development of the software, the worth of the power meter, and plans for a data logger using the spare capacity of the arduino.