Category Archives: General Electronics

Life is tough, but it’s tougher when you’re stupid…

Ok, maybe not stupid, but I did miss something pretty fundamental and I missed it early enough to waste a couple of days of development time. Also, there was a side quest through the quicksand that is Windows USB drivers.

As mentioned earlier, ESP-NOW is expected to fulfill a number of needs for my project. To recap, I have built a reliable target activating system applicable to several shooting sports I am involved in. It is reliable because it is electrically pretty simple, with some switches and relay providing the limited logic needed, a control box with said relays and switches and a battery and finally the connectors and cabling to hook it all up.

Removing those cables can be done with a wireless system that essentially doubles the built cost for the system. It would also be plenty reliable, but the cost is prohibitive, especially as I do intend to sell this system and I can’t make the price attractive and make a little money on it if I have to spend that much on the wireless technology.

The hardware for ESP-NOW is built in to microcontrollers that already support WiFi and are incredibly cheap. Furthermore, adding a microcontroller will let me replace a couple of other expensive parts while added even more features.

Of course, ya gotta get it working first.

I had easily set up two devices where one could messages to the other. I found an easy to follow YouTube tutorial for two way communication between two devices and chose that one to implement for the next step. The tutorial had a lot of symetry to it. Two ESP32 devices, each with an environmental sensor (temperature, humidity and pressure) and a tiny OLED display. The environmental data from each device was displayed on the other. The sketches are identical on both devices other than the manual entry of each devices peer MAC address, the device it is sending data to. While some of the ESP-NOW tutorials included facilities to scan for peers and automatically record their MAC addresses, this one assumes you know the MAC address for each of your devices and even includes a super simple sketch to extract the mac of the board it runs on. I ran this sketch and recorded these MAC addresses in a notepad text file for later reference. The sketch requires the MAC address to be stored in an array variable and in the declarations area of the sketch, this array variable was created in this form…

… where you would substitute the MAC address octets of the peer device for 0xFF in each position. If you leave it all FF’s, it will work by broadcasting the data to all devices on the network and the ESP-NOW devices will actually listen. However, the receiving devices do not acknowledge receipt of the message, where as unicasting to a specific MAC address does. There are situations where broadcast is appropriate, but for my purposes, I’d rather have the acknowledgement.

In my notepad, I created this string of hex notation digits so that I could just copy and paste the MAC into any script I was working on.

I modified the sketch, simplified it, removing all the code to support the display and environmental sensor because I didn’t have those to connect to it. My sketch sent two bytes to each other. Eventually, my messages between units will also be just two bytes, on as a unit identifier, the other as a command or status. I could probably make that two nybbles and just send a single byte.

The trouble is that my devices would only send one way. I had intended one to be the Activator and one to be the Control Box. Under normal circumstances, the Control Box will send a command to the Activator to instruct it to trip immediately. The Activator will either periodically send a status or it will respond to a poll for status from the Control Box. In my case, however, communication was also only one direction. The sending unit did not have an acknowledgement and the receiving unit never received any messages. I did a few minor troubleshooting steps to ensure that my sketches were indeed identical other than the peer MAC addresses.

The next step was to swap out equipment. I was using one ESP32 for the Control Box, assuming I would want to add more features to that one eventually and they have more I/O pins. The Activator was a very inexpensive ESP8266 board and there was always a chance one might have a bad transmitter. When I started swapping boards and sketches around, the laptop would occasionally not drop the virtual comm port when a board was unplugged. It would sometimes take a reboot to clear this issue. I had two instances of the Arduino IDE running. Juggling two IDEs and two of about four available cards when sometimes the USB subsystem would basically stop responding and require a reboot to fix quickly grew tedious as hell. I reached a stopping point on the first day and had to drop it at least overnight.

The next day, I decided that, since I was fighting some weird issues, I would work with some ESP32 boards instead of the 8266’s. The libraries for ESP-NOW and WiFi are different between the two MCUs. It was just a variable wanted to eliminate. The situation was largely unchanged, including the USB virtual comm port issues. I had a new sympton there. Now sometimes, I could get two of the same virtual comm port number. A bit of research revealed that sometimes, the USB to serial chips on these boards will have the same serial number, at least as far as Windows Device Manager can tell, so it give them the same comm port. I could manually edit one of them to an unused port number and make them work, but the more I unplugged boards, the more often the entire subsystem would lock up. Reboots would take several minutes, then time out with an error “DRIVER POWER STATE FAILURE” and it would then reboot itself from the reboot process. It happened several times and took 5-10 minutes EACH TIME to complete a reboot. That was the clue I finally latched onto and worked on replacing the driver for the USB to serial chip on these boards, the Silicon Labs C210X series.

That is an easy download, but of course by now, things weren’t going to go easy. Eventually, I discovered that there were three separate sets of Silicon Labs drivers installed on my laptop. I presume there was some subtle difference between some of the ESP boards I have plugged into this laptop and each installed it’s own ‘most recent’ drivers. I deleted them all and installed the fresh download from Silicon Labs, dated in 2023. This seemed to settle down the USB traumas.

Of course, they would still only communicate in one direction.

Now that I felt like I could trust the USB stuff, I added some code to print the device’s MAC address and peer MAC address during the setup() function. It never printed. I added other tag prints to show where in setup execution was. Those never printed. It was like it was skipping the setup() function. Google again.

Eventually, I found some references to the serial port/driver being slow to come up at boot timer or after an upload. One solution was to use a while loop to wait until the serial system was active. That didn’t help, either. Finally, one suggestion was to literally wait for 5 seconds before executing the Serial.begin() function and that finally worked! It was kludgy and needed only for sanity checking while developing, but it worked. The two MAC addresses printed out.

Since I copied and pasted the information into my notepad file, I have no idea how one of those MAC addresses was wrong and more importantly, how a C got changed to a D. They are adjacent keys, but good grief.

It can easily be argued that fixing the USB driver thing definitely needed to be done, but because of that distraction and the slow start on the USB serial port connected to it, troubleshooting a friggin’ TYPO took two days.

ESP-HOW

In my last post, I went over some mile high view details of ESP-NOW and my plan to replace the largely analog control scheme for my target activator system with some microcontroller boards running ESP32 and ESP8266 chips. That these systems can provide wireless communications for far less than the cheapest alternative that I had found thus far. However, in making that jump, there are many other advantages, some of which feed from one another, but all rooting in using the MCU boards to control the system.

The control box primarily becomes just more control-y, able to leverage MCU features in the activator and trigger devices. The control box will have user friendly lights to indicate whether the activator has been reset and the trigger is ready. With an arming feature, it will be able to ignore trigger inputs during stage reset. With wireless triggers, there is no need to choose an input polarity. Once a later version is configured with a display, more sophisticated features, such as sequencing multiple activators from one trigger or battery charge level from remote devices.

The activator benefits in several ways, where using an MCU introduces cascading improvements. Immediately, I realized that a big problem will be that the activator will now need an internal battery. Since the MCU can take over the timer relay’s one function, that relay can come out, leaving more room for the MCU and a battery. I don’t need a connector for the wire, but I will need a power switch and the external antenna.

I was watching a YouTube video about multitasking MCUs. One of my favorite videos on the subject involved adding more things that were happening at the same time, first a blinking LED, then an LED that fades in, then a button that lights and LED and finally a servo that sweeps, with all of these running simultaneously. BTW, all of that revolves around programming the various delays needed without using the built in delay() function because the MCU can do nothing else while that particular delay is running.

Wait a second, ‘servo’? Epiphany! I can replace the 12 volt lock motor with a suitably strong servo; I don’t need to protect the lock motor if there is no lock motor to protect. Oh, and any servo will be a LOT smaller than the lock motor, so now I have more room for the battery. Oh, and the lock motor was the only reason I was going to need a 12 volt battery, so now I can use a smaller battery, like a 7.4 volt RC car battery, which are made to be easy to swap out and charge.

Hardly mentioned thus far is that the trigger devices can be remote and wireless. There is a good argument for keeping the hardwired connector for certain triggers that don’t really need to be automated. On the other hand, a wireless trigger appliance that hardwired triggers can plug into makes all triggers look alike to the controller software.

The short version (I know, I’m not good at telling the short version of anything) of implementing ESP-NOW is that there are quite a few serviceable example sketches showing how to set it up and get it working between almost any number of devices. The examples tend to show unidirectional commuications, with one or more transmitting devices paired with one or more receiving devices. At minimum in my application, I need for the control box to receive from a trigger device and send to an activator device. The control box really needs to be able to communicate in either direction. Taken a bit farther, an activator needs to be able to send it’s status and a trigger might need to be able to receive a command, so from the ground, I need to deploy them as bidirectional.

At this point, however, I am pretty happy to have unidirectional communications that is responsive. In the little video below, the window on the left is the ESP32-S3-Box set up a the sender. I have a button push set up to trigger it sending it’s data, in this case the number ’25’. On the right is the D1 Mini Pro set up to print any data it receives as soon as it receives it.

This video is not particularly easy to see the details, but I think you can tell that there is only a tiny delay between when the S3-Box senses the button and when the D1 Mini displays the received data.

Interestingly, the button press needs work. No matter how debounced the button is, it somehow sends the data twice per button closure and once upon button release. None of the logic in place *should* do that, but it does. I suspect it will be because the example code scans for all slave devices and puts them in an array. The button press triggers a loop which counts through the list of slaves and sends the data to each. I am guessing that something in that loop is to blame for the multiple sends. I don’t want to completely eliminate the loop because a near future version needs to e able to sequence through several activtors. Plus, my button press might not be perfectly well executed. Maybe it isn’t as debounced as it should be.

My first implementation of the wireless setup will actually have the units hard coded to eliminate such issues until I am ready to tackle them. I don’t need to be fighting on multiple fronts.

The activator software really doesn’t need to do much for a successful version 1.0. Receive the activate command, operate the servo as required to release the physical device, then sense whether the physical device has been reset or not.

Once I had really decided to go with the MCU route, the primary trigger device that I have been thinking about is a ESP-NOW equipped photobeam sensor. Like the activator, version 1.0 of the trigger doesn’t need to do just a gob of stuff, just send a signal to the controller when triggered. Everything after that is gravy.

There is one potential problem. The photobeam I *have* requires 12 volts and all the alternatives that work in the same basic way, with the emitter and detector in one device that points to a retroreflector on the other side of the detection area, also all start at 12 volts. This means that the trigger device will either have to have a different battery than the control box and activator, or I need to get 12 volts from somewhere.

There are boost voltage converters that use switching power supply technology to boost voltage. Of course, there is no free lunch, so a boost converter draws the same amount of power it converts. To supply 12V at 1A would take 1.6A from a 7.4V battery, plus a little to account for efficiency loss. Happily, the photobeam draws 40mA or less and, at this point, I’m not sure how much the D1 Mini Pro pulls, but I’d bet I can probably use one and a 7.4V battery and be just fine. I guess we will find out.

Longer term the the data protocol I develop should include the activator and trigger devices sending a periodical status packet. This will be used as a general keep alive communication, but the structure of status message will include a device ID that the user assigns, a bit or two to identify that type of device it is and other status information, like battery condition and whether the activator needs to be reset. I have 250 bytes to play with, but one or two bytes should suffice.

ESP Soon

Ok, *they* call it ESP-Now… or ESPNOW… or maybe it’s ESP-now…

Point is….

Espressif makes some chips now and then. Maybe a bunch of them. Chances are pretty good that if you have something in your house that does WiFi, especially if it is an IoT thing, it likely has an Espressif chip at the heart of it.

My gateway into ESP was the ESPHome platform in Home Assistant. I have a couple of ESP8266 based boards gathering and reporting information back to my Home Assistant. One is a pretty simple temperature sensor that reports the outside temperature, or at least the temperature *just* outside of the garage door. The other has two active inputs, a temperature sensor that tells the approximate ambient temperature around my water system, which consists of a a bunch of overcomplicated plumbing in my garage, and the water flow rate and total consumption for the house, based on what a flow sensor equipped water meter is willing to share. This unit also has two inputs that I have not yet connected that are detailed in the other blog post.

To the point, I am at least somewhat familiar with the ESP8266 based Wemos D1 Mini board. This is a 1 x 1.5 inch board with the surprisingly powerful ESP8266 microcontroller on board. ESPHome hides a lot of the ugly details from you, but the ESP8266 is a general purpose microcontroller with built in WiFi support and a handful of general purpose IO pins. It is essentially a single core version of the ESP32 with a little less I/O and a (only) 80MHz clock.

Remember ESP-NOW? This is a post about ESP-NOW….

ESP-NOW is, to paraphrase the documentation somewhat, a hijack of the typical WiFi TCP/IP stack. ESP-NOW uses the hardware of the MCU’s WiFi facilities, but at a not the whole stack. It lives and communicates at layer 2 of the OSI model. It is a peer to peer protocol, with no need of a WiFi router, DHCP or any of that sort of thing.

This protocol leverages the ‘action frames’ element of the 802.11 standard. This subprotocol is generic, but often networking gear of any given brand uses this protocol to communicate between themselves. For example, action frames are how access points in the same SSID pass your roaming device between different access points, with vendor specific data passed as action frames.

This protocol comes with some limitations, such as a limit of 250 bytes per packet. For most such purposes, 250 bytes is way more than needed most of the time. I need to pass only one or two bytes as my payload.

If you want to skip a bunch of background and exposition, you can scroll down to the big Espressif logo.

I was killing the usual time on YouTube when, based I’m certain on browsing habits that include ESP8266 stuff, they presented a couple of ESP-NOW basic configuration guides. My application has been begging for a wireless connectivity method and here it is, dropped in my lap and almost perfect for my needs.

Without getting too detailed, I am building a system which needs a controller that can see an initiating action and trigger the activation of some hardware. Specifically, I am a competitive pistol shooter. The main sport I am involved with includes scenarios wherein you may have to address targets that are moving or may have non-threat targets moving in front of them. Historically, these moving targets have been triggered by simple mechanical means, such as stepping on something that will trigger a spring loaded device to yank a cord/cable in order to activate the moving target. At this point, I have a working and reliable system that operates electrically. It has been used at several matches for a little over 300 activations, with no mechanical or electrical failures. So long as it is reset between stages, it just works.

I have build a version 2.0 of the same device, with almost identical mechanics, but with a four conductor connectors and cabling for reasons detailed below.

This unit has only been to one match, but except for the occasional failure of the humans to reset it, it performed perfectly.

The issue is, of course, everyone wants just a little more out of it, including me. I mentioned “So long as it is reset between stages…” and that is a fairly common issue. Failure of stage equipment to activate results in a mandatory reshoot for that competitor, which costs everybody time.

For example, a given competitor decides to be the one who resets the device. When that competitor is coming up in the rotation, generally for at least two competitors before him, he is not actively resetting the stage. If nobody notices at first, the activator doesn’t get reset.

When the next competitor goes, whatever is supposed to trigger the activator doesn’t seem to do anything, so that competitor is commanded to stop and reload to make a new attempt. Once this kind of thing is happening, it tends to snowball into two or three competitors in a row having some kind of problem and the root cause is that people didn’t notice that the activator was not reset.

Another, though lesser, issue is when resetting the stage and someone *has* reset the activator, but someone accidentally walks through the triggering area and prematurely sets off the moving target.

Let’s list our grievances…

  1. Nobody notices that the activator has not been reset.
  2. It is clumsy or impossible to guard certain kinds of triggers from activating while the stage is being scored and reset.
  3. I haven’t mentioned yet that everyone wants this to be wireless, too
  4. Ultimately, it would be great if the activator could reset itself.

I added the extra wiring to the activator with the intent to have a switch inside the unit that is closed whenever the unit has been tripped and thus turn on a big red light at the controller whenever it needs to be reset. While I haven’t actually figured out the best switch arrangement yet, the idea is otherwise fairly trivial to accomplish.

Triggering the activator wirelessly is something I have experimented with. The best analog solution I found for that is a wireless system intended to operate a gate from a remote button. The receiver is relatively small and can be powered by 12V. The remote is a typical handheld door opener button, but would be pretty easy to modify to attach to the control box as it currently operates. The bad news is that this wireless set is about the same cost as my build cost for an entire system, essentially doubling what I would need to charge for it in a finished product.

However, and I’m sure the reader is tired of all this exposition by this point, I do have a solution.

For reliability reasons, I did not first pursue microcontroller automation of this system. The more that can go wrong, the more you have to work to prevent it. I wanted the physical hardware to be solid, but I have always known that it could be more feature rich under MCU control. I have seen a couple of activators controlled by a Raspberry Pi. I love my RPi for all the things it is good at. In my opinion, they are extreme mass overkill for controlling small things, primarily because they are general purpose computers, running an operating system that is really designed for human interaction. In the match where a device was operated by a Pi, the stage it was on was almost thrown out due to reliability issues. The comparitive simplicity of an MCU board removes a lot of potential issues arrising from a more complicated controller.

On the other hand, I have seen quite a few stages, particularly at the national level, with activators controlled by actual industrial control hardware. They are designed specifically for control of industrial equipment where tolerance for failure is minimal. They are priced accordingly. When I started looking at making my device, a suitable industrial controller started at about $300, which is about how much I’d like my entire device to sell for.

My analog system is very reliable; it’s just switches and relays, with almost nothing to break, but adding or changing features requires literally rewiring it. An industrial controller would also be reliable and much more flexible, but is notoriously expensive. The MCU occupies the space between them.

I can replace a lot of relatively inflexible hardwired relays and switches with an MCU and thanks to Espressif’s ESP-NOW protocol, they can communicate wirelessly. It took several days of working through some details, but the decision had enabled several other decisions and almost all of them result in savings of time and cost.

For example, the activator itself is fairly simple mechcanically. There is a car door lock motor that, when powered up by the current control box, it simply pulls on a metal sear, releasing a spring loaded rod that supplies the yank required to activate almost every imaginable moving target. This lock motor has one troublesome characteristic, namely that leaving power applied to it will eventually damage the little motor inside of it. To mitigate this, I use a timer relay. The timer relay is powered by the same activation power from the control box, however it is set to throw it’s contacts after about a half second and those contacts are wired to remove power from the lock motor to protect it. When power is removed, the relay resets. Ironically, this timer relay is the single most expensive part of the activator, including the steel box and frame, and for the MCU board I will be using, I could buy four of them for the cost of one timer relay.

The current control box is quite literally two relays, a switch and a battery. One relay is just to buffer the input trigger so that the full power going to the acivator doesn’t have to flow through the triggering device, also most of the triggers in current use could probably handle it.

The other relay is to invert the trigger input. For example, the ‘dead man switch’ trigger is a hand held switch that the competitor holds and presses to ‘arm’ the system. When they release the button, it triggers the activator. In the sport rules, you are limited in what you can *require* a competitor to do once the timer has been started, but before the timer, you can require them to hold something, for example.

The switch is a three position switch to select whether the input is inverted or not, with the center position used to disable the system.

The battery powers it all. I chose a 12 volt lithium ion battery pack that has a power switch and a barrel connector. In my original testing of the lock mechanism, I used a second timer relay configured in pulse generator mode, set to trip once every 30 seconds and wired at a trigger to the system. Once that was running, I left it on the workbench overnight. The next morning, about 6 hours later, it was still running. In 6 hours, the relay (both relays, technically) and lock motor had cycled about 720 times. The battery was between 40% and 60% charged. This is far and away long enough for a long day at a major match. During the entire time of this protoyping project, I have recharged that battery about 5 times and never was it completely flat when I started charging it.

The latest update to the control box just upgraded the connectors to 4 pin connectors and added power to the trigger input so that the control box could also power the photobeam trigger.

By changing these switches and relays out to a couple of MCUs, I will risk added complexity, particular as I need to write the software for them, but there is a LOT to be gained. The big ones are wireless communications, easier to add sophisicated features and overall lower build cost.

There are GOBS of companies making MCU boards and many of them are clones of each other. The specific controller I have chosen for the activator is commonly called the D1 Mini Pro. I have used the D1 Mini clone in my home automation pursuits. The primary difference between the standard and Pro variant is that the Pro offers an external antenna connector, a requirement for a device that needs to communicate wirelessly but still be enclosed in a steel box. For the immediate upgrad needs, the control box could also use this same board, but for the long term, the control box will probably have something with a display for eventual features I hope to add. I’m starting off with an Esperrif ESP32-S3-Box because it has a display and a couple of buttons on the front of it and I already had it, purchased for some home automation pursuits.

This post is already too long, so I am going to cover my development, implementation and more detailed design philosophy in the next one.

Let It Slide

My older brother did a fair bit of high school math and science work assisted by a slide rule. I was too young at the time to understand the nuances of this remarkable tool. By the time I was in high school, the pocket calculator was the norm, if any calculation assistance was allowed at all. I recall my chemistry teacher encouraged us to use a calculator in his class because “this is hard enough without messing up the arithmetic”.

Between an undetermined number of calculators of various complexity and more recently, the entire internet full of specific purpose calculators, I never had cause to acquire or learn about the slide rule. I am at a point in my life (an age?) where such mechanical devices are fascinating.

A couple of years ago, I was watching something on YouTube and the subject of sliderules came up. Shown in that video was a sliderule configuration that I found quite compelling, the circular slide rule. Specifically, the Russian KL-1. Turns out they are not stupid expensive and a bit of eBay shopping revealed one from the early 70’s for a price I was willing to pay.

A slide rule is, at it’s most basic, a device inscribed with markings spaced according to a logarithmic scale. Logarithms are their own subject and there is much more to it than this, but the layman can think of logaritms as a numeric series where each next major number is a multiple of the previous, such as 1, 10, 100, 1000, etc where each mark is 10 times the previous mark.

We use computers to calculate logarithms these days, but hundreds of years ago, math and science practicioners generated books full of logarithms so that they could be looked up in a table rather than calculated each time it was needed. John Napier, a Scottish polymath, is credited with introducing the use of logarithms to simplify other calculations. In 1614. So, not yesterday.

One of the most helpful properties of logarithms is that the logs of any two numbers added together will equal the log of those same two numbers multiplied together.

This has the effect of simplifying multiplication problems down to addition, though you need some way to know the logarithms.

For our purposes, b is 10, so we are working with base 10 logarithms.

The log of x plus the log of y equals the log of x times y.

For simplicity, lets use 2 and 3 for x and y.

Log(2) + Log(3) = Log(6)

Now, Log(2) = 0.30102999 and Log(3) = 0.47712125. Those added together is 0.77815125. Since we are using base 10, 10 to the power of 0.77815125 turns out to be….. 6!

The scales on our slide rule gives us an easy way to add those two scary small numbers because someone else marked the scale in logarithmic intervals, forming a lookup table of sorts.

For the moment, let’s focus on the C and D scales, shown by the green arrow. These are identical log base 10 scales. Logarithms for numbers less than 1 are negative numbers, so the scale starts at 1, shown by the red arrow. 2 is shown by the yellow arrow, 3 by blue and 4 by purple.

Next, lets say that our scale is some arbitrary number of units long. It doesn’t matter what units unless you are actually making a slide rule, which I want to do now. 🙂 As luck would have it, the slide rule in this picture has the L scale, which shows the actual numeric value of of the log shown in scales C and D. The L scale is linear, beginning at 0 and proceeding evenly to the right. For our purposes, we can consider the L scale to be a ruler.

Log 2 is 0.30102999. The distance from the red arrow to the yellow arrow on the L scale is 0.3 or so.

Log 3 is 0.47712125. The distance from the red arrow to the blue arrow is 0.47 or so.

Log 4 is 0.60205999. The distance from the red arrow to the purple arrow is 0.6 or so.

By itself, that seems maybe obvious. But what this means is that we can represent the logs of our various numbers by the physical distance they are from 1.

2 x 3 = 6

log(2) + log (3) = ?

0.30102999 + 0.47712125 = 0.77815125

Find 0.77815125 on the L scale (no arrow shown) and it is [drumroll] …. 6! 6ish, anyway, because we are really only able to see 0.775ish on the scale.

This reveals what people accustomed to the instant precision of electronic calculators may find challenging about slide rules. In practiced hands, they are very fast, but not super precise. However, they give an answer that is almost always going to be close enough for most purposes. If someone needs to figure out how many degrees 1/7th of a circle is so they can cut a wooden circle into 7 pieces, 360 / 7 = a hair less thatn 51.5 is close enough for a saw.

Multiplication on the sliderule shown is accomplished by sliding the inner movable scale until the multiplier on C scale lines up with the 1 on the D scale, then move the cursor (the clear slide with the line across it) to the multiplicant on the D scale, then read the result on the C scale.

I don’t have a classic slide rule, but I found a wonderful site with slide rule simulations.

The arrow on the left shows the multiplier 3 lined up with 1 on the D scale. The arrow on the right shows the cursor lined up with the multiplicant 2 on the D scale and the answer 6 revealed on the C scale.

Doing larger multidigit numbers can be done with fractional distances. 30 x 20 = 600 for example. Using 3.0 (times 10 in your head) and 2.0 (times 10 in your head) = 6.0 (times 100 in your head; 10 x 10). If you need large numbers with high precision, just use paper to do long form multiplication and use the slide rule to do the arithmetic in each step.

33 x 21 = 690-something-between-0-and-5. It’s 693 precisely.

Nothing says that the scales need to engraved on something straight. Enter the KL-1.

There are many other circular slide rules and even other models that emulate a pocket watch like this one does. In this case, this side has what is essentially the C/D scale printed on a movable face and two cursors. One cursor is fixed, here aligned with the 1 and the knob which turns the face. The other cursor is the red hand, which is moved with the other knob.

The procedure is slightly different, but still works under the exact same principles. The outer scale is essentially A scale in typical slide rule parlance. Turn the face until the multiplier aligns with the fixed cursor, 3.9 or 39 in this case.

Note that the inner scale is labeled C and the written instructions say it is to be used for basical calculation. If I use the inner scale, the multiplication math still works, but the outer scale has more divisions and is thus is more precise. The inner scale become more important used in division and square root calculations, covered a little later. The A and C scales correlate. The A scale numbers are the squares of the C scale numbers. I have NO understanding how this helps with division. I have much to learn.

The hand is rotated to 1 on the scale. These two steps are equivalent to sliding the scale to line up the mulipler on the C scale with 1 on the D scale.

Then the scale is rotated until the multiplicant, 2.1 or 21 here, is aligned with the red hand. The result is read at the fixed cursor, a hair less than 8.25 or 825. The precise answer is 8.19 or 819

The other side of the KL-1. Interestingly, written instructions call this side 1. It has three scales and another red hand cursor. The scales don’t move, but the hand does. The outer scale is the inverse of the inner C scale on side 2 and is called the DI scale. The other two are the S and T scales, used for sine and tangent trigonometry functions that I don’t yet know how to use. Note that the T scale is a 630 degree spiral. I have much to learn.

Division is similar in that Log (x) minus Log (y) = Log (x/y). The procedure for division is similar to multiplication.

Rotate the outer scale to put the dividend under the fixed cursor, 16 in this example.

Rotate the red cursor to the divisor on the inner scale, 2 in this case.

Rotate the inner scale to put the dividend, 16, under the red cursor. The quotient result, 8, is read on the inner scale under the fixed cursor.

125 / 65 = ?

Put 125 in the outer scale under the fixed cursor and 65 in the inner scale under the red cursor.

Rotate the scale to put the outer scale 125 under the red cursor and read the quotient from the inner scale under the fixed cursor. 125 / 65 = 1.92. The precise answer is 1.92307692, but I think 1.92 is definitely close enough.

The markings on the inner scale show greater precision (0.12 per division) for values between 1 and 2, slightly less from 2 to 6 (0.25 per division) and even less from 6 to 10 (0.5 per division). This might be due to the range of expected results. The closer to 1, the more precision needed. However, I think it is really a horological artifact. The divisions are physically similar in size, but the logarithmic intervals are progressively smaller as the values go up. The lines are all about the same size in degrees of arc, but this is simply room for more divisions between 1 and 2 than there is between 6 and 10.

Decapping Integrated Circuits

TL;DR: I am hoping to fix a broken USB drive….

For purely scientific interest, I have been interested in chip decapping for a while. Decapping is slightly archaic because only the larger integrated circuits tend to be made with actual removable caps these days.

Instead, ICs are FAR more commonly cast into epoxy and often glass reinforced epoxy.

There are a couple of destructive ways to decap epoxy chips. Sometimes you can literal just break the package and expose all or part of the silicon die with all the interesting bits therein, but that is really random. You can also use pretty extreme heat to soften the epoxy enough to peel it off the die.

The most effective way, and one which leaves at least a chance that the chip may still operate is to use heated 70% nitric acid to *dissolve* the epoxy. This is really effective and pretty hazardous, so requires good preparation and a not insignificant list of supplies, not the least of which is the 70% nitric acid. As I am writing this, a couple of online sources sell it to individuals for about $50 for a 100ml bottle (a little less that 1/2 cup Imperial) plus a $40 HazMat fee from the shipper. You need borosilicate glass (Pyrex is a brand name of borosilicate glass) because nitric acid will react with regular soda class. There are a lot of YouTube videos on the subject. I may tackle it for scientific purposes in the future, whenever I feel like dropping a hundred bucks on a half cup of evil juice.

What brings this whole subject to light is that a) I have had a physically damaged USB drive for many years and b) I have seen a few videos lately where talented individuals have used a fiber laser to vaporize the epoxy off of an SD card to expose the factory test connections in order to recover data on that card.

Now, I don’t have a spiffy fiber laser, but I do have an xTool D1 that I have been using for a variety of cutting and engraving projects. Surprisingly, as of this writing, the laser does not have it’s own blog category. Must fix.

This USB drive was in a laptop that was dropped. Instantly, it stopped working correctly. It would kinda work, showing a drive letter in Windows, but every attempt to interact with it would produce either an error or a bunch of nothing. For example, drive E: is there, with zero bytes in use, zero bytes available, etc. The card does mount, but there appears to be a disconnect between the controller and the actual storage within the device.

So, disassembly revealed that under all that plastic was a single tiny module, completely potted in epoxy, with a visible crack across it’s width.

On the other side of this module is the 4 pin USB connector on what is pretty obviously a printed circuit board. I suspect the entire device is a small board with naked chip dies attached and the whole thing potted in epoxy. All the plastic physical packaging is just to position and protect this little module. I should mention that this is a PNY brand device and it’s been long enough that I don’t remember the capacity, but it’s likely a 16MB or maybe 32MB. It’s not big by today’s standards.

This device was dropped quite some time ago, maybe 2012 or so. I think if I ever gain access, I’ll be able to realistically time stamp it, but I’m jumping WAY ahead. During those intervening years, I have occasionally tried to access the data. Mostly, I have tried to reflex the crack enough to make contact with whatever conductors were broken by the crack, which is generally my assumption as to what is broken. Maybe the PC board cracked in the right place to deny power to the storage chips, but not the controller. I don’t recall the specific utilities I used, but at least two of them were able to verify that the controller was responding, but that it could not see the storage.

So, back to the xTool D1. My particular device is a 10W blue diode laser that will cut up to about 10mm thick plywood, but it’s much happier with thinner stuff than that. I have cut everything from copier paper to acrylic to EVA foam and, with a little experimentation with the speed and power settings, it has performed wonderfully.

I didn’t want to just blindly charge into attempting to cut away the epoxy in my lobotomized USB drive, so I found a known dead circuit board and started eroding the epoxy on a couple of it’s onboard chips. I happened to pick the dead wireless link device that I had replaced earlier this year.

I set the xTool to ‘fill’ a 11mm square and positioned the laser over the left-most chip shown in the picture above. I played with various speed and power settings until I had an idea how it would chew it away.

I am not sure if it is specifically ash or if the laser burns away everything except the glass reinforcement, but a pass or two of the laser leaves a gray/white layer and the laser seems to no longer have much affect. Maybe if I had more than 10 watts to work with, it would be simpler.

After chipping and scraping away some layers of epoxy off of that chip, I decided that I had nothing left to lose by starting with those settings and seeing how it did with the USB drive module.

For the first pass, of COURSE I didn’t have the chip lined up perfectly, so it left a millimeter or so of chip untouched on the righthand side. I readjusted and ran the fill again. I noticed that the material was less “reactive”, it tended to reflect blue light rather than glow with a bright white burning color. I removed the module and used the corner of a single edge razor blade to chip away the gray/white ash layer.

If I was very careful, I could remove fairly large chips of this ash material. After a couple of passes, it looked like this:

Note a few specifics… I think rectangle in the upper left may be a capacitor being exposed. I hope the laser does not damage it.

Next, edges of the crack seem to erode quicker, leaving a trough that follows the crack. This may be a localized thermal effect.

Finally, you can definitely detect the 0.05mm spacing I chose to fill in the pattern. My experiments with the old wireless system chips showed that the default 0.1mm spacing was pretty crude at this level, but it *was* twice as fast to run. 🙂

I ran the pattern a few more times and exposed the mother lode:

A bundle of bond wires, apparently all broken by the crack in the module.

It is good news because I am now confident I have found the problem. It is bad news because instead of maybe one or two broken power traces on the PC board, I have (I think 29) broken wires that fit roughly into a 3mm space.

I am *planning* to attempt to use fine solder paste and rework gun heat to solder bridge between the broken ends, somehow *not* also bridging the tiny 0.01mm gap between wires. I may make an attempt first to see if it will work at the current depth I have burned away with the laser. If not, I will need to tweak some laser values and try it again….

Is the Write Speed the Right Speed?

I have been aware that SD cards, and particularly MicroSD cards, can have read and write speed limitations, however, I only recently have had two separate issues that turn out to have been due to slow write speeds.

Though I didn’t realize it at the time, write speed was likely the issue that caused some videos taken by my little DJI Mavic Mini to fail. I started it recording and flew around for a while. Later, the video was only about a minute long; I had definitely intended to record more than that. I now think the slow SD card write speed caused the high resolution video to simply overwhelm the card and the camera just shut off. I presume there was no notice, but I will look for some kind of on screen warning in the future.

I also had troubles with a recent astrophotography capture. I was getting 100 subs of 30 seconds each. The length of the capture doesn’t affect the size of the file, but when you are going to capture for nearly an hour, you don’t want to wait any longer between shots than necessary. Most DSLR cameras will capture to an internal buffer then write that image to the memory card between pictures. Generally, the write time of the camera is hidden from the user because we tend to take a picture or two then put the camera down while we wait for something else to take a picture of to come around. However, with astrophotograhy, you are taking dozens or even hundreds of long exposures in a row. In the example above, I had the camera set to pause for two seconds between exposures. That pause time accounts for nearly four minutes in the whole capture process. I noticed that a little while into the capture, the busy light was staying lit past the time for the for the next picture to take. Because the intervalometer just sends a 1 second signal to the camera and the camera was using it’s internal shutter timer, when this busy event would happen, the camera miss a shutter event, which would then allow it to catch up on the write process then sit idle while the 31 or so second wait on the intervalometer would time out. It would then capture 5 or 6 images before the write busy would add up enough for it to miss another shutter event. So, my 100 captures would have turned out to be 90 or so without intervention.

I changed the delay between shots on the intervalometer to 5 seconds instead of two. This helped it get to 10 or 12 shots before the camera was busy and missed a shutter event. I set it to 8 seconds for the remaining 40-50 shots, the busy light did not miss any more shots.

Had the 8 second delay been in place for the entire 100 shots, it would have added 14 minutes to the entire process. It’s not like that is a huge part of one’s life, but after you capture 100 lights, then you need to capture 30-50 darks at the same shutter speed and 30-50 flats. The flats will be at a shorter shutter speed, but that actually makes the write speed problem worse.

I found, not surprisingly, that a) the read and write speed on memory cards is rarely specified and b) when it is, write speed has a bigger affect on price than capacity. 64GB cards with 250MB/S write speed cost more than 128GB cards with 130MB/S write speed and c) anything slower than about 100MB/S will probably not show the spec and those will pretty much always be inexpensive.

To address both problems, I ordered four 64GB cards that specify 250MB/S read and 130MB/S write speed from B&H Photo.

By the time they had arrived, I found some somewhat questionable data that indicated that the write speed of the particular card I had used in both the DJI Mavic Mini and the EOS Rebel T6i probably has a write speed more along the line of 30MB/S. I found a simple disk benchmark program and tested the new and old cards.

The old card, as expected, was pretty slow:

The new card was much faster, exceeding the write spec, assuming they specify the best spec rather than the average:

No SD card does well with random reads and writes.

For perspective, here is the report on the 250G SSD in my laptop:

… and my Toshiba 2TB USB drive that I use for various archiving and backup tasks:

In practical terms, I set the camera to it’s fastest shutter time of 1/4000 second and set it to continuous shooting. Press and hold the shutter button, and with the new card, it takes 7 pictures at the max speed of 5 frames per second, then it slows down to about 1 per second. Release the shutter button and it takes about 5 seconds for the busy light to go out. With the old card, you still get the 7 shots buffered in the camera, but the catchup is more like 1shot every 2 seconds, then it takes nearly 10 seconds for the busy light to go out. This card should definitely be an improvement.