All About USB-C: Replying Low-Level PD

Last time, we configured the FUSB302 to receive USB PD messages, and successfully received a “capability advertisement” message from a USB-C PSU. Now we crack the PD specification open, parse the message, and then craft a reply that makes the PSU give us the highest voltage available.

How did the buffer contents look, again?

>>> b
b'\xe0\xa1a,\x91\x01\x08,\xd1\x02\x00\x13\xc1\x03\x00\xdc\xb0\x04\x00\xa5@\x06\x00<!\xdc\xc0H\xc6\xe7\xc6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

The zeroes at the end might look non-significant, and they indeed are not with 99.99% certainty – that said, don’t just discard the entire tail end; one of the bytes in the beginning encodes the length of the message. We’ll read those bytes first, and then read only exactly as much as we need, making sure we aren’t reading two messages and interpreting it as one, and that we’re not discarding zeroes that are part of the message.

Today, we will write code that parses messages right after reading them from the FIFO buffer – however, keep this message handy for reference, still; and if you don’t have the hardware, you can use it to try your hand at decoding nevertheless. If you wanna jump in, you can find today’s full code here!

Continue reading “All About USB-C: Replying Low-Level PD”

How To Roll Your Own Custom Object Detection Neural Network

Real-time object detection, which uses neural networks and deep learning to rapidly identify and tag objects of interest in a video feed, is a handy feature with great hacker potential. Happily, it’s also possible to make customized CNNs (convolutional neural networks) tailored for one’s own needs, and that process just got easier thanks to some new documentation for the Vizy “AI camera” by Charmed Labs.

Raspberry Pi-based Vizy camera

Charmed Labs has been making hacker-friendly machine vision devices for a long time, and the Vizy camera impressed us mightily when we checked it out last year. Out of the box, Vizy has a perfectly functional object detector application that runs locally on the device, and can detect and tag many common everyday objects in real time. But what if that default application doesn’t quite meet one’s project needs? Good news, because it’s possible to create a custom-trained CNN, and that process got a lot more accessible thanks to step-by-step examples of training a model to recognize hands doing rock-paper-scissors.

Person and cat with machine-generated tags identifying them
Default object detection works well, but sometimes one needs custom results.

The basic process is this: Start with a variety of images that show the item of interest. Then identify and label the item of interest in each photo. These photos (a “training set”) are then sent to Google Colab, which will be used to generate a neural network. The resulting CNN model can then be downloaded and used, to see how well it performs.

Of course things rarely work perfectly the first time around, so at this point it’s pretty common for some refinement to be needed to increase accuracy. Luckily there are a number of tools to help do this without creating a new model from scratch, so it’s just a matter of tweaking until things perform acceptably.

Google Colab is free and the resulting CNNs are implemented in the TensorFlow Lite framework, meaning it’s possible to use them elsewhere. So if custom object detection has been holding up a project idea of yours, this might be what gets you over that hump.

Two goniometers sit on a table. One is an open wooden box with a long piece of plywood along the bottom. A laser distance finder rests on the front edge and a printed angle scale has been attached to the back side of the box. To the right of this box is a much smaller goniometer made from an orange pipe cap with a small strip of paper serving as the angle scale inside the interior edge. It is attached to a wooden handle that looks vaguely like a V. A laser pointer can be inserted from the bottom where a hole has been drilled through the wood.

Goniometer Gives You An Edge At Knife Sharpening

Sometimes you absolutely, positively need to know the angle of the cutting edge on a knife. When you do, the best tool for the job is a laser goniometer, and [Felix Immler] shows us three different ways to build one. (YouTube)

The underlying principle of all three of these builds is to project reflected laser light off a knife blade onto a scale going from 0-45˚. [Immler] shows a basic demonstration of this concept with a hinge toward the beginning of the video (after the break). Blades with multiple bevels will reflect light to each of the appropriate points on the scale.

The simplest version of the tool is a printed PDF scale attached to a wooden box with a hole for the blade to pass through. The next uses a large pipe end cap and a drilled-out piece of wood to create a more manageable measuring tool. Finally, [Immler] worked with a friend to design a 3D printed goniometer with differently-sized adapters to fit a variety of laser pointers.

Now that you’re ready to precisely sharpen your blades, why not sharpen this guacamole bot or try making your own knife from raw ore?

Continue reading “Goniometer Gives You An Edge At Knife Sharpening”

3 Ways To DIY Custom CNC Dust Covers

Home shop machinists know dust shields are important for keeping swarf out of expensive linear rails and ball screws. [Petteri Aimonen] demonstrates three inexpensive ways to DIY some bellows-style dust covers. Such things can of course be purchased, but they’re priced at a premium and not always available in the size one needs.

A bellows-style dust cover ideally maximizes extension length while minimizing side wall distortion. It should hold its shape without external support.

The first method is to fold a suitable flat plastic or paper sheet into a bellows pattern. This method is all about the fold pattern, and thankfully, there’s no need to reinvent the wheel. [Petteri] used a fellow enthusiast’s bellows folding pattern generator which is, believe it or not, itself inspired by a remarkably comprehensive US Patent Number 6,054,194.

The downside to this method is the thickness of the bellows when it is fully collapsed. The corners always contain the most material, because it is there that the material is folded upon itself, and this limits how close to the end of travel the CNC carriage can move with the bellows attached.

The second method is to cut a large number of C-shaped sections from fabric and sew them together to make bellows. This method collapses down well and holds its shape well, but the cutting and sewing it requires can be a barrier.

The final method — and the one [Petteri] found most useful — was to hack some IKEA window blinds. IKEA Schottis pleated blinds are inexpensive, with a slick finish on one side and polyester fabric.  The polyester is perfect for gluing. By cutting the material at a 45-degree angle into three sections and gluing them into a U-shape, one can create a serviceable bellows-style cover for a minimum of work.

Any of the explored methods can do the job, but [Petteri] has formulas to determine the maximum extensions and folded thicknesses of each method just in case one would like to see for themselves before choosing. And if a bellows-style cover isn’t your cup of tea, check out this method for turning a plastic strip into a spring-like tube that does the same job.

DIY Custom Earplugs For Pennies Per Pair

Hearing is one of our most precious senses, and yet many take their hearing for granted, exposing themselves to loud noises that do lasting damage. [Jonathan Levi] of The Next Level does no such thing, at least not anymore. He’s even gone so far as to have custom acrylic earplugs made, which he carried around for two years, finally had them tweaked to be perfect, and promptly lost them. Rather than shell out another $150-$200 for another pair, [Jonathan] decided to see if he could make some himself.

While it’s true that [Jonathan] got a head start by asking the earplug company for the STLs they created back when he was fitted, he goes through the ways that one could mold and then scan one’s ears at home for not a lot of money. There are even kits for squirting that quick-setting goo into your ear to get just the right shape. Once you’ve got the ear canal positives, some quick photogrammetry work with your phone camera and a lazy Susan should be enough to get a model going in Blender.

[Jonathan] had the good sense to label left and right on the 3D printed mold, and furthermore added some small 3D printed screws that are color-coded to help him keep them plugs straight, and give him something to grab on to when it’s time to take them out. Be sure to check out the build video after the break.

Continue reading “DIY Custom Earplugs For Pennies Per Pair”

Weatherproof Raspberry Pi Camera Enclosure, In A Pinch

The Raspberry Pi is the foundation of many IoT camera projects, but enclosures are often something left up to the user. [Mare] found that a serviceable outdoor enclosure could be made with a trip to the hardware store and inexpensive microscopy supplies.

A suitably-sized plastic junction box is a good starting point, but it takes more than that to make a functional enclosure.

The main component of the enclosure is a small plastic junction box, but it takes more than a box to make a functional outdoor enclosure. First of all, cable should be run into the box with the help of a cable fitting, and this fitting should be pointed toward the ground when the enclosure is mounted. This helps any moisture drip away with gravity, instead of pooling inconveniently.

All wire connections should be kept inside the enclosure, but if that’s not possible, we have seen outdoor-sealed wire junctions with the help of some 3D-printing and silicone sealant. That may help if cable splices are unavoidable.

The other main design concern is providing a window through which the camera can see. [Mare] found that the small Raspberry Pi camera board can be accommodated by drilling a hole into the side of the box, cleaning up the edges, and securing a cover slip  (or clover glass) to the outside with an adhesive. Cover slips are extremely thin pieces of glass used to make microscope slides; ridiculously cheap, and probably already in a citizen scientist’s parts bin. They are also fragile, but if the device doesn’t expect a lot of stress it will do the job nicely.

[Mare] uses the Raspberry Pi and camera as part of Telraam, an open-source project providing a fully-automated traffic counting service that keeps anonymized counts of vehicle, pedestrian, and bicycle activity. Usually such a device is mounted indoors and aimed at a window, but this enclosure method is an option should one need to mount a camera outdoors. There’s good value in using a Raspberry Pi as a DIY security camera, after all.

Make Your Own Pot And Encoder Knobs, Without Reinventing Them

Rotary potentiometers, switches, and encoders all share a basic design: adjustment is done via a shaft onto which a knob is attached, and knobs are sold separately. That doesn’t mean one knob fits all; there are actually a few different standards. But just because knobs are inexpensive and easily obtained doesn’t mean it’s not worth making your own.

A simple and effective indicator can be easily printed in a contrasting color.

Why bother 3D printing your own knobs instead of buying them? For one thing, making them means one can rest assured that every knob matches aesthetically. The ability to add custom or nonstandard markings are another bonus. Finally, there’s no need to re-invent the wheel, because [Tommy]’s guide to making your own knobs has it all figured out, with the OpenSCAD script to match.

By default, [Tommy]’s script will generate a knob with three shims (for interfacing to a splined shaft) when pot_knob(); is called. The number of shims can be adjusted by modifying potKnobDefaultShimCount. To give the knob a flat side (to interface with D-shafts), change flatted = false to flatted = true. And for adding a screw insert suitable for a set screw? Change tightenerDiameter = 0 from zero to the diameter desired.

The script is quite comprehensive and has sensible defaults, but it does require a bit of knowledge about OpenSCAD itself to use effectively. We have covered the basics of OpenSCAD in the past, and if you’re ready for a resource that will help you truly master it, here’s where to look.