Your Arduino SAMD21 ADC Is Lying To You

One of the great things about the Arduino environment is that it covers a wide variety of hardware with a common interface. Importantly, this isn’t just about language, but also about abstracting away the gory details of the underlying silicon. The problem is, of course, that someone has to decode often cryptic datasheets to write that interface layer in the first place. In a recent blog post on omzlo.com, [Alain] explains how they found a bug in the Arduino SAMD21 analogRead() code which causes the output to be offset by between 25 mV and 57 mV. For a 12-bit ADC operating with a reference of 3.3 V, this represents a whopping error of up to 70 least-significant-bits!

Excerpt from the SAMD wiring_analog.c file in the Arduino Core repo.

While developing a shield that interfaces to 24 V systems, the development team noticed that the ADC readings on a SAMD21-based board were off by a consistent 35 mV; expanding their tests to a number of different analog pins and SAMD21 boards, they saw offsets between 25 mV and 57 mV. It seems like this offset was a known issue; Arduino actually provides code to calibrate the ADC on SAMD boards, which will “fix” the problem with software gain and offset factors, although this can reduce the range of the ADC slightly. Still, having to correct for this level of error on a microcontroller ADC in 2019 — or even 2015 when the code was written — seems really wrong.

After writing their own ADC read routine that produced errors of only between 1 mV and 5 mV (1 to 6 LSB), the team turned their attention to the Arduino code. That code disables the ADC between measurements, and when it is re-enabled for each measurement, the first result needs to be discarded. It turns out that the Arduino code doesn’t wait for the first, garbage, result to finish before starting the next one. That is enough to cause the observed offset issue.

It seems odd to us that such a bug would go unnoticed for so long, but we’ve all seen stranger things happen. There are instructions on the blog page on how to quickly test this bug. We didn’t have a SAMD21-based Arduino available for testing before press time, but if you’ve got one handy and can replicate these experiments to verify the results, definitely let us know in the comments section below.

If you don’t have an Arduino board with a SAMD21 uC, you can find out more about them here.

Sound Card ADCs For Electrocardiograms

Every few years, or so we’re told, [Scott] revisits the idea of building an electrocardiogram machine. This is just a small box with three electrodes. Attach them to your chest, and you get a neat readout of your heartbeat. This is a project that has been done to death, but [Scott]’s most recent implementation is fantastic. It’s cheap, relying on the almost absurd capability for analog to digital conversion found in every sound card, and the software is great. It’s the fit and finish that makes this project shine.

The hardware for this build is simply an AD8232, a chip designed to be the front end of any electrocardiogram. This is then simply connected to the microphone port of a sound card through a 1/8″ cable. For the exceptionally clever, there’s a version based on an op-amp. It’s an extraordinarily simple build, but as with all simple builds the real trick is in the software. That’s where this project really shines, with custom software with graphics, and enough information being displayed to actually tell you something.

We’ve seen a number of sound card ADCs being used for electrocardiograms in the past, including some from the Before Times; it makes sense, sound cards are the cheapest way to get a lot of analog data very quickly. You can check out [Scott]’s demo video out below.

Continue reading “Sound Card ADCs For Electrocardiograms”

Rebuilding The First Vocal Encryption System

Back in the early days of radio, it was quickly apparent that the technology would revolutionize warfare, but only if some way could be found to prevent enemies from hearing what was said. During World War II, the Allies put a considerable amount of effort into securing vocal transmissions, resulting in a system called SIGSALY – 50 tons of gear developed by Bell Laboratories with the help of Alan Turing that successfully secured communications between the likes of Churchill and Roosevelt during the war.

Now, a small piece of the SIGSALY system lives again, in the form of a period-faithful reproduction of the vocal quantizer used in the system. It’s the work of [Jon D. Paul], who undertook the build to better understand how the SIGSALY system worked. [Jon] also wanted to honor the original builders, who developed a surprisingly sophisticated system given the technology of the day.

SIGSALY was seriously Top Secret in the day, and most of the documentation was destroyed when the system was decommissioned. Working from scant information, [Jon] was able to recreate the quantizer from period parts, including five vintage VT-109/2051 thyratrons scrounged from eBay. The vacuum tubes are similar in operation to silicon-controlled rectifiers (SCRs) and form the core of the ADC, along with a resistor divider ladder network. Almost every component is period correct, and everything is housed in a nice acrylic case. It’s a beautiful piece of work and a great homage to a nearly forgotten piece of cryptographic history.

Interestingly, Bell Labs had a bit of a head start on the technology that went into SIGSALY, by virtue of their work on the first voice synthesizer in the 1930s.

Continue reading “Rebuilding The First Vocal Encryption System”

Brushless Motor Thrust Stand Provides Useful Data

When designing model aircraft of any shape or size, it’s useful to know the performance you can expect from the components chosen. For motors and propellers, this can be difficult. It’s always best to test them in combination. However, with the numbers of propeller and motor combinations possible, such data can be tough to come by. [Nikus] decided it would be easier to just do the testing in-house, and built a rig to do so.

The key component in this build is the strain gauge, which comes already laced up with an Arduino-compatible analog-digital converter module. Sourced for under $10 from Banggood, we can’t help but think that we’ve got it easy in 2018. A sturdy frame secures motor and propeller combination to the strain gauge assembly. An ATMEGA328 handles sending commands to the motor controller, reading the strain gauge results, and spitting out data to the LCD.

It’s a cheap and effective build that solves a tricky problem and would be a useful addition to the workshop for any serious modeler. We’ve seen other approaches in this area too, for those eager to graph their motor performance data. Video after the break.

[Thanks to Baldpower for the tip!]

Continue reading “Brushless Motor Thrust Stand Provides Useful Data”

Open Hardware Board For Robust USB Power Monitoring

We’ve all seen the little USB power meters that have become popular since nearly every portable device has adopted some variation of USB for charging. Placed between the power source and the device under test, they allow you to see voltage and current in real time. Perfect for determining how long you’ll be able to run a USB powered device on batteries, or finding out if a USB power supply has enough current to do the business.

[Jonas Persson] liked the idea of these cheap little gadgets, but wanted something a bit more scientific. His design, which he refers to as UPM, is essentially a “smart” version of those ubiquitous USB gadgets. Instead of just showing the data on a little LCD screen, it can now be viewed on the computer and analyzed. His little gadget even allows you to cut power to the device under test, potentially allowing for automated testing of things such as inrush current.

Essentially the UPM works in much the same way as the simple USB meters: one side of the device goes towards the upstream power source, and the device under test plugs into the other side. Between the two devices is a 16 bit ADC and differential amplifier which measures the voltage and current. There’s a header on the board which connects to the ADC if you wanted to connect the UPM to an external microcontroller or other data logging device.

But most likely you would be using the internal microcontroller to analyze the output of the ADC over I2C, which [Jonas] very cleverly connected to the upstream port with an integrated USB hub. One side of the hub goes off to the device being tested, and the other to the microcontroller. So the host device will see both the UPM’s integrated microcontroller and the target device at the same time. From there, you can use the ncurses user interface to monitor and control the device in real-time.

While the hardware looks more or less finished, [Jonas] has some more plans for the software side of UPM, including support for remote control and monitoring over TCP/IP as well as robust logging capabilities. This is definitely a very interesting project, and we’re excited to see it develop further.

In the past we’ve seen homebrew USB power meter builds, and even commercial offerings which boasted computer-based logging and analysis, so it was only a matter of time before somebody combined them into one.

An LED You Can Blow Out, With No Added Sensor

We’d seen it done with buttons, switches, gestures, capacitive touch, and IR remote, but never like this. [electron_plumber] made an LED that can be blown out like a candle, and amazingly it requires no added sensors. The project uses an Arduino to demonstrate turning a tiny LED on and off in response to being blown on, and the only components are the LED and a resistor.

[electron_plumber] used an 0402 LED and thin wires to maximize the temperature responses.
How is this done? [electron_plumber] uses an interesting property of diodes (which are the “D” in LED) to use the LED itself as a temperature sensor. A diode’s voltage drop depends on two things: the current that is being driven through the diode, and the temperature. If the current is held constant, then the forward voltage drop changes reliably in response to temperature. Turning the LED on warms it up and blowing on it cools it off, causing measurable changes in the voltage drop across the device. The change isn’t much — only a handful of millivolts — but the effect is consistent and can be measured. This is a principle [Elliot Williams] recently covered in depth: using diodes as temperature sensors.

It’s a clever demo with a two important details to make it work. The first is the LED itself; [electron_plumber] uses a tiny 0402 LED that is mounted on two wires in order to maximize the temperature change caused by blowing on it. The second is the method for detecting changes of only a few millivolts more reliably. By oversampling the Arduino’s ADC, an effectively higher resolution is obtained without adding any hardware or altering the voltage reference. Instead of reading the ADC once, the code reads the ADC 256 times and sums the readings. By working with the larger number, cumulative changes that would not register reliably on a single read can be captured and acted upon. More details are available from [electron_plumber]’s GitHub repository for LEDs as Sensors.

Embedded below is a video that is as wonderful as it is brief. It demonstrates the project in action, takes a “show, don’t tell” approach, and is no longer than it needs to be.

Continue reading “An LED You Can Blow Out, With No Added Sensor”

Thumbs Up For This Custom Atari 5200 Controller

It may be nearly 40 years old, but the Atari 5200 still inspires legions of fans to relive the 8-bit glory days of their youth. There was much to love about the game console, but the joystick-and-keypad controllers were not among its many charms. The joystick didn’t auto-center, the buttons were mushy, and the ergonomics were nonexistent.

Retro-aficionados need not suffer in silence, though, thanks to this replacement controller for the Atari 5200. [Scott Baker] didn’t want to settle for one of the commercial replacements or, horrors, an adapter for the old PC-style joystick, so he rolled his own. Working from the original Atari schematics, [Scott] devised a plan for using a readily available thumbstick controller as the basis for his build. The essential problem was how to adapt the 10k pots on the new joystick to work in an environment expecting 500k pots, which he solved using an analog to digital and back to analog approach. The ADCs on an ATtiny85 convert each joystick pot’s voltage to a digital value between 0 and 255, which is sent to a 100K digital potentiometer. A little fiddling with RC constants brings it back in line with what the console expects. The thumbstick and buttons live on a custom PCB – kudos to [Scott] for designing an ambidextrous board. The video below shows the design and the finished product in action.

[Scott] is on a bit of a 5200 kick these days; he just finished up a Raspberry Pi multi-cartridge for the venerable console. His controller should make retro-gameplay on the console a little easier on the hands.

Continue reading “Thumbs Up For This Custom Atari 5200 Controller”