Ed Nisley's Blog: Shop notes, electronics, firmware, machinery, 3D printing, laser cuttery, and curiosities. Contents: 100% human thinking, 0% AI slop.
The optoisolator carrying the Bafang controller’s LIGHT signal pulls Pin 2 down to turn the LED on constantly for night riding:
if (!Morser.continueSending())
if (digitalRead(PIN_LIGHTMODE) == HIGH)
Morser.startSending();
else
digitalWrite(PIN_OUTPUT,HIGH); // constantly turn on in headlight mode
That’s the entirety of the program’s loop() function, so there’s not much to the firmware.
Imagine that: a whole computer devoted to sampling an input bit a zillion times a second and persistently setting an output bit:
Tour Easy Running Light – Arduino view
The Morse output to the rear is now “s” rather than “i” for more blinkiness, but I doubt anybody will ever notice.
The next time I raise the hood on this thing, I’ll add a digital input to select FRONT or REAR mode to get me out of having to remember which hardware goes where.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The running lights have the same general structure as before and fit into the same front and rear holders:
Tour Easy Running Light – rear installed
I made the recess slightly deeper to provide a bit more protection to the lens:
Tour Easy Running Light – front installed
The lenses have a 10° beam angle, so a few more millimeters of sidewall doesn’t intercept much light.
The layout doodle grew a few more notes:
Tour Easy running light – housing dimensions
I had the good idea of boring the tube, knurling the rod, then epoxying the two together beforecutting the rod:
Tour Easy Running Light – heatsink curing
Which let the lathe hold them in perfect alignment during curing:
Tour Easy Running Light – heatsink plug alignment
The rod fits through the lathe spindle and I intended to use it as an arbor while turning the tube exterior, then cut the finished heatsink off flush.
Which really good idea lasted until the next morning, when I looked at the setup and immediately cut the rod flush with the tube. Because reasons, perhaps excess blood in my caffeine stream.
So I had to finish the heatsink on hard mode right up against the chuck:
Tour Easy Running Light – turning heatsink rebate
Flipping it around and gripping that little rebate to skim the OD down to 25 mm seemed fraught with peril, so I stabilized the open end with a chuck and plenty of oil; the live center was just too big around for the job.
After boring the PVC pipe to 23 mm ID, I made a pair of Delrin fixtures to simplify turning the exterior to 25 mm before parting it off:
Tour Easy Running Light – turning body OD
The PVC is so thin the Arduino’s LEDs shine right through:
Tour Easy Running Light – installed top view
The radioactive green endcap is ordinary laser-cut fluorescent edge-lit acrylic with sunlight through the garage door on the left. I used red acrylic for the taillight to encourage their separate identities.
The knockoff Arduino Nano fits on one side of the support plate:
Tour Easy Running Light – Arduino view
And the current regulator on the other:
Tour Easy Running Light – current regulator
Because these run from a dedicated 6.3 V step-down regulator, rather than the Bafang controller’s headlight output, the 2.0 Ω sense resistor sets the LED current to 0.8 V / 2.0 Ω = 400 mA, which is pretty close to the LED 1 W spec.
The white blob at the end of the two ribbon cable wires is the optoisolator pulling down a pin when the LIGHT signal is active, telling the firmware to stop the normal blink pattern and just turn the LED on all the time. This will come in handy if I ever do any night riding.
The LED is epoxied to the aluminum shell (with metal-filled JB Weld) and the whole affair never gets more than comfortably warm even with the LED running constantly.
I think they came out All Good™, despite various blunders along the way.
Having just finished another set of daytime running lights, we once again have a matched pair of Tour Easy recumbents:
Tour Easy Running Light – two tail lights
Although both ‘bents have Bafang 750 W motors with 48 V lithium batteries and both motor controllers have “light” outputs, they are different.
The controller on Mary’s bike (on the right) has a 6.3 V output that goes active when you press the 500C display’s + button for a few seconds. Those running lights simply use the light output for power, with a bit of tweakage to keep their current draw within the 500 mA limit.
The controller on my bike (on the left) has a 12 V output that goes active when I press-and-hold the headlight button on the DPC-18 display’s pad. Unlike the 500C, however, the DPC-18 dims its display when the lights are on, rendering it completely illegible in sunlight.
Because the running lights must operate with the headlight output inactive, a buck converter from a randomly named Amazon seller steps the 48 V battery down to 6.3 V. Note that the usual buck converters have a 36 V upper limit, so you want one with an LM2596HV regulator.
Because the regulator should be turned off when the motor controller is off, it must have a control input to enable / disable it; even if the regulator has the input pin, most boards don’t bring it out to a pad. The PCB I used has a SW input that must be low to enable the regulator, as shown in the middle doodle amid these scratches:
Tour Easy running light – buck converter SW control doodles
The SW pad on the PCB drives a voltage divider made from a 3.3 kΩ and a 10 kΩ resistor, with the regulator’s control (pin 5) looking at the junction. Running the numbers suggested a 220 kΩ resistor from the battery + terminal would provide enough current to hold the pin high, while not drawing more than a few hundred microamps, and a transistor could pull it low to turn the regulator on.
The DPC-18 display has a USB port to charge your phone on the go, so I hijacked that to get +5 V when the controller is turned on:
Tour Easy Running Light – Bafang DPC-18 USB plug
It’s a cut-down USB breakout board with two 24 AWG wires stripped from a ribbon cable soldered in place and coated with epoxy. The silicone port cover sticks out on the left; I eventually jammed it under the display panel in lieu of cutting it off.
Although I want the running lights on whenever the controller is on, It Would Be Nice™ to have a steady headlight / taillight in the unlikely event I ever ride after dark. With that in mind, the USB power pair joins another pair from the motor controller’s LIGHT connector (via a red 2-pin Juliet plug), so the firmware can tell when the headlights should be on, and the resulting 4-wire ribbon cable wanders off to the battery mounting plate:
Tour Easy running light – wire routing doodle
The connectors along the way are 4-pin JST-SM 2.5 mm, which are most certainly not watertight. We’re fortunate in being able to not ride in the rain whenever we want, so the connectors won’t be exposed to water very often.
The battery mounting plate has an aluminum casting with a small compartment, probably intended for a complete e-bike controller, that just barely holds the hardware required to produce the 6.3 V supply:
Tour Easy Running Light – Bafang battery base circuitry – detail
Yes, those exposed battery terminals with soldered-on wires got a silicone tape wrap. No, there are no fuses involved. The two steel brackets holding the main power cable in place came pre-bent and pre-drilled in a random piece of scrap harvested from some dead equipment; they’re screwed into pre-tapped holes intended for the six TO-220 style power transistors of the missing motor driver.
The perfboard in the upper left holds an optoisolator for the USB power → SW input and a pair of resistors for the LIGHT signal to the headlight and taillight:
Tour Easy running light – control doodles
The optoisolators come from an ancient surplus deal; the bag I thought contained unmarked SFH615 parts apparently got mixed with some unmarked SFH6106 parts with the opposite transistor pinout.
The sketched trimpot in the lower right was on the buck regulator board, where it stood just an itsy too tall to fit the space available. Given that I would never adjust it, I set it for 6.3 V, removed it, measured the resistances, substituted fixed resistors, and the board should produce 6.3-ish V forevermore.
The regulator sits atop heatsink tape on a brass sheet with more heatsink tape isolating it from the housing and two nylon screws holding the stack in place.
With the various cables soldered in place:
Tour Easy Running Light – Bafang battery base circuitry – wired
Clearing off the Electronics Bench unearthed the probes for my fancy Siglent SDM-3045 bench meter, which had been producing erratic readings. I isolated the problem to the red probe, which had an irregularly variable resistance ranging upward from a few ohms.
The probe being a non-repairable thing, I used the lathe to cut it apart and eventually found the problem:
Failed Siglent DMM probe
The probe tip on the right originally had no solder on it at all (*), with the curved part of the soldered wire fragment resting around it. The plastic pieces originally molded around the tip and wire applied enough force to hold them together, but the wire fragment fell out as I dismantled the probe.
Apparently the assembler didn’t get enough heat on the wire-to-tip joint to melt the solder on the probe tip, but the plastic shell got it past whatever QC might have happened between assembly and the shipping department.
A few years back, I refurbished all my failing alligator clips (using the Siglent meter and its test probes!) and no longer believe increasing my spend for such things will increase their quality. I’d love to be proven wrong, but the evidence is definitely stacking up the other way.
The SJCAM M50 camera gasket seems unable to cope with The New Normal weather conditions around here:
SJCAM M50 – screen condensation
I think this was probably another case of diurnal pumping, given the exceedingly hot days and cool nights in late July.
Plenty of water condensed on the bottom of the battery compartment cover:
SJCAM M50 – battery lid condensation
And inside the compartment around the AA cells:
SJCAM M50 – battery compartment condensation
Unlike the previous leak, the camera lens wasn’t involved, so I did not disassemble the case. I let the opened camera (without batteries) dry out in the hot hot sun for the rest of the day and it seemed fine by evening.
Keeping it out of full sunlight during the day definitely limits the locations I can use.
The four corner holes hold locating pins in the layered acrylic base:
SJCAM M20 Battery Replacement – case layers
Those pins got cut slightly shorter to fit in the battery holder; in this photo they’re serving to align the layers and adhesive sheets while I stacked them up.
The geometry is straightforward, with the outer perimeter matching the 3D printed battery holder:
SJCAM M20 Car-Mode Battery Hack – battery case
Cut one base and two wall layers from 3 mm (or a bit less) transparent acrylic, plus three adhesive sheets. I stuck adhesive on both sides of one wall layer, using the pins to align the adhesive, stuck the layer to the base, then topped it with the second wall layer, again using the alignment pins.
The motivation for transparent layered acrylic is being able to see the charge controller’s red and green status LEDs glowing inside the box. This probably isn’t required, but seemed like a Good Idea™ for the initial version.
With all that in hand, wire it up:
SJCAM M20 Battery Replacement – charger wiring
The USB charger PCB sits atop a layer of double-sided foam tape. After verifying that the circuitry worked, I globbed the wires in place with hot-melt glue to make it less rickety than the picture suggests.
The alert reader will have noticed the holes in the 3D printed NP-BX1 holder were drilled, not printed. In the unlikely event I need another case, the holes will automagically appear in the right place.
I haven’t yet peeled the protective paper off that top adhesive sheet to make a permanent assembly:
SJCAM M20 Battery Replacement – trial install
We use the car so infrequently that it’ll take a while to build up enough confidence to stick it together and stick it to the dashboard.
On the whole, it’s ugly but sufficient to the task.
A doodle with key dimensions, plus some ideas not surviving contact with reality:
SJCAM M20 Car-Mode Battery Hack – case doodle
I truly hope this entire effort is a waste of time.
The circuit board is the charge controller for the evicted high-voltage lithium pouch cell, but I started by connecting an ordinary lithium cell with a Schottky diode to the PCB’s battery terminals.
This worked about as poorly as you’d expect, because the lower battery voltage minus the forward drop of the diode minus whatever happens in the PCB put the final voltage below the camera’s instant low-battery shutdown.
The terminals connecting to the camera in the rectangular bump are soldered to the back of the PCB, but the whole affair snaps out of the battery case. Unsoldering the PCB from the terminals, gingerly soldering directly to them, and adding a bulk storage capacitor produced a better result:
SJCAM M20 Battery Replacement – circuitry
The cap stores just enough energy to keep the camera happy while writing to the Micro-SD card, although the LCD screen dims slightly during each pulse.
Cut a pad from a sheet of closed-cell foam that happened to be exactly the right thickness:
SJCAM M20 Battery Replacement – wrapper layout
The elaborate thing below the case is a cardboard pad atop the sticky side of a PSA non-PVC vinyl sheet, laser-cut to fit:
SJCAM M20 Battery Replacement – case wrapper top
The bottom view, showing the latch retaining the contact block:
SJCAM M20 Battery Replacement – case wrapper bottom
Admittedly, that’s the last iteration of the wrapper, starting with a hand-trimmed Kapton tape version and three paper versions to get the dimensions right before trying vinyl. Looks good to me!
The final geometry has a 0.5 mm radius on all the corners:
SJCAM M20 Car-Mode Battery Hack – battery wrapper
The fillets reduced (but did not eliminate) mechanical oscillations while slinging the laser gantry around those corners. If I don’t point them out, maybe nobody will notice.
The PSA vinyl is marginally thicker than the original plastic wrapper, so the battery fits very snugly into the camera. On the other paw, getting the swollen battery out required a major effort; this one should not get tighter.