Saturday, March 24, 2018

Addressing Issues with a Purchased Development Board

I bought the CAN32 development board from tindie because on paper it met all of the requirements that I wanted to make a datalogger for my electric motorcycle: a CAN bus interface, micro SD card for storing the data, WiFi for uploading the data from the SD card to a server, a 12v regulator that would allow the logger to be powered from the motorcycle, and Arduino example code for the CAN bus that was specific to the ESP32-Wroom module.

In reality, what I purchased was an unfinished and unvalidated prototype that had issues for all of the above features.
A preview of bad things to come.

Reaching Out to the Seller
Naturally one of the first things to try when dealing with these sorts of problems is to try asking the seller about it. In this case, the seller did not reply for over a month, and I had already figured the problems out for myself. Some of the items that I complained about in my initial review of the product were addressed, such as missing documentation on the product page.

CAN Bus
The example code for the CAN bus was very promising, and in fact there was nothing explicitly wrong with it. But I couldn't get any data to transmit or receive on the CAN bus. I could see that the data was present on the I/O pins for the ESP32 and that they were connected to the right pins on the transceiver. What didn't match the example was that this development board had the enable for the CAN transceiver connected to a pin on the ESP32 instead of wired to be permanently on (this was not mentioned anywhere on the product page at the time).

Micro SD Card Logging
One of the more simple tasks, this was impeded by two things. First, there was no documentation for which IO pin was used for the CS pin on the SD card (while this was not difficult to determine by using my multimeter to find which pin has continuity to the SD card, it did add 20-30 minutes of time spent searching around for the information and probing everything). The bigger issue that I discovered was that there were no pins on the ESP32 connected to the "card present" pin on the SD card holder. This isn't unfixable, but it's definitely something that I shouldn't have to do myself.

Incorrect Voltage at the 5v pin when powered from 12V
There were two issues that came up when powering the device from the 12v input. The first was that the voltage of the pin labeled "5v" was actually around 7v when the device was powered from 12v. This was quite alarming, as I was concerned that this might damage the USB-UART chip.

This turned out to be caused by too much leakage through the OR-ing diodes used to allow the board to run off of 12v or USB power.
The 5v pad that I was measuring was on the same net as the input for the CP2102 USB-Serial adapter, which means that it was seeing the 7v at the input. Normally, this would be enough to permanently damage the chip, but after observing that the voltage at the input for the chip did not vary much when the 12v input voltage was varied it seems that a zener diode internal to the chip was clamping the voltage and the OR'ing diode was providing enough current limit to prevent the chip from becoming damaged. Replacing the OR'ing diodes with ones with less leakage current solved the problem.


WiFi
Disclaimer: this problem was most likely caused by the diodes that I used to replace the original OR'ing diodes (mentioned above) and may not have happened with the original design. The diodes that were used as replacements were ones that were on-hand and aren't ideal. Since I have a work-around for this problem I may just opt to leave it as-is for now and do my own PCB with a better solution.
I started out trying a simple WiFi client example from Sparkfun, and found that when the board was powered only by USB that the microcontroller would brown out when attempting to use the WiFi:

Because the power inputs are diode OR'd between the USB and the 12v input, I was able to rule out my USB port as the source of the problem by using my lab power supply set to 5v. In both cases there was a large voltage drop on the output when the WiFi was used that would cause the microcontroller to reset:

The voltage regulator used has a dropout voltage between 1-1.3v according to the datasheet. The combination of insufficient capacitance near the regulator and the voltage drop across the OR-ing diodes causes the momentary dip in the output. Adjusting the voltage of the bench power supply to account for the additional drop gets rid of the problem:



Overheating Voltage Regulator
Because the WiFi would not work with USB power (see above), I was powering the board from 12v to test some code and noticed that the LDO voltage regulator was getting really hot. Using a thermal camera showed that the component temperature was exceeding 100 degrees Celcius(!) in room temperature ambient conditions. This is a classic case of a poor usage of an LDO regulator, not only because they generate a lot more heat than a switching regulator but because there was no copper plane for the part to use as a heat sink. The video below shows the vast difference between temperatures when the device is powered from USB and with 12v:


Conclusion
Tindie promotes itself as a marketplace for makers, which makes a lot of interesting and unique things available that wouldn't otherwise be for sale. However, there is a difference between a "maker" and an engineer, and some degree of caution must be taken when deciding if a product created by a "maker" actually does what they say it can do. I spent a lot of time at the beginning looking for problems in my code when things weren't working because I assumed that the hardware had already been validated. This highlights the importance of doing your own testing and characterization of components and parts when you are going to use them in a design, even when it is just for a personal project.

Saturday, March 17, 2018

DIY Heatshrink Cable Lug Covers

I wanted a way to make cable lugs a bit more touch safe. While it is best practice not to have live cable lugs waving about loose, accidents can happen to the best of us, and a bit of forethought for potential accidents can go a long way.
My solution involves using a hollow punch to put a circular hole in a piece of heat shrink, and sealing one end of it with an impulse sealer (typically used for sealing plastic bags). Sealing one end of the heatshrink beforehand makes it easy to put the cable lug in position and have the holes line up.
If needed, after the heatshrink is applied a knife or good wire cutters can be used to remove additional material from the bottom side of the lug to allow for a proper connection.

Easy RPM Display Add-on to the Mill

The milling machine that was given to us didn't have a display for the RPM, but it did have a rectangular cutout in the front panel for a feature that isn't in use on this model. $20 for an off-the-shelf panel mount tachometer and a 3d printed bracket later and the mill is one more feature closer to the final setup.



Removing a broken headphone jack connector from an iPad

My boss came to me at the end of a workday and asked if I might be able to help remove a headphone connector that had been broken off inside his son's iPad.
Removing it turned out to be pretty simple (gently soldered a wire to the top part and pulled on the wire).The connector came out in two pieces, which I found interesting. Fortunately after the top part was removed I was able to pull on the bottom piece with tweezers and extract it that way.

Weatherproofing a Motorcycle Dash Camera System

I bought a two camera system for my motorcycle to record what was going on in front and behind my motorcycle as a record in the event of an accident, but I wanted to check to see how well protected it would be against water ingress.
Unfortunately, while there was adequate strain relief on the wires, there was no sealing on the enclosure or protective coating on the PCB to prevent water damage.

I applied some brush-on conformal coating to the board before closing the box again and mounting it on my motorcycle. Conformal coating is a good option here because it is easy to selectively apply it to the board while avoiding areas like the microphone and the micro SD card connector (which would be much more difficult to do with a potting material). I also don't have to worry about dealing with CTE mismatch with a conformal coating in the same way that I would with a potting material.

The camera resolution could be better, but the framerate is acceptable and much better than not having anything. Below is a test clip from the evening that I installed it, the night quality could also be better and the audio is terrible (warning before trying to play the video). The timestamp is also incorrect as I hadn't set the time yet.

Fixing the wiring on my 3D printer

I've been reasonably happy with my Solidoodle Press 3d printer, but the wiring harness was not built with any strain relief on the extruder head, which eventually led to a wire for the extruder stepper motor to fail.
Fortunately, I was able to come up with a relatively non-invasive solution by making a bracket to attach some plastic cable drag chain to the head. I did have to re-do the wiring to the head to extend the length out, but the result should be much more durable.

New Workshop Tool: a Free Milling Machine (!)

One of the mechanical engineers I work with was moving and was kind enough to offer his K&F MD-40 milling machine to me and my friends for free as long as we came and took it off his hands for him!
It turns out that moving a "desktop" mill onto a cart is arguably harder than moving a full size mill around, but we figured it out after a few hours.

My friend Ben has put in a lot of time cleaning it up and making it usable, and I've been helping by re-organizing the garage to accommodate the "new" mill

Flea Market Wrench Restoration

I found this beauty of a wrench for $2 at the infamous flea market at De Anza college in the bay area.

It was pretty crusty when I found it, but with a little love with some steel wool it cleaned up pretty well:

A fine addition to my growing wrench collection.

New Phone Holder for Project Pics

Put together a pretty nice clamping arm setup for holding smartphones/cameras for taking pictures/videos of projects. Nobody sold the exact thing that I wanted, so I ordered three separate things from Amazon and put them together. Hopefully this will mean better project pictures in the future!

Items used:
CAMVATE Universal C-Clamp
CAMVATE 360 degree 1/4" Articulating Magic Arm Mount
Vastar Universal Smartphone Tripod Adapter