Posts with «hackaday columns» label

Hackaday Links: September 11, 2022

Good news out of Mars from the little lunchbox that could — in the seven times that MOXIE has run since it arrived in February 2021, it has reached its target production of six grams of oxygen per hour, which is in line with the output of a modest tree here on Earth. The research team which includes MOXIE engineers report that although the solid oxide electrolysis machine has shown it can produce oxygen at almost any time or day of the Martian scale, they have not shown what MOXIE can do at dawn or dusk, when the temperature changes are substantial, but they say they have ‘an ace up (their) sleeve’ that will let them do that. We can’t wait to see what they mean.

In other, somewhat funnier space news — early last Sunday morning, the ESA’s Solar Orbiter was cruising by Venus as part of a gravity-assist maneuver to get the Orbiter closer to the Sun. Two days before the Orbiter was to reach its closest point to the spacious star, it spat a coronal mass ejection in the general direction of both Venus and the Orbiter (dibs on that band name), as if to say ‘boo’. Fortunately, the spacecraft is designed to withstand such slights, but the same cannot be said for Venus — these events have their way with Venus’ atmosphere, depleting it of gasses.

Is this not the most Hackaday-esque thing you’ve ever heard of? A solar-powered, Arduino-driven cockroach. Not a robot, an actual cockroach with a backpack. Why? Cyborg insects for urban search and rescue missions, obviously. We’d make some quip like ‘all it needs is a Nixie tube’, but in all seriousness, that would just weigh them down needlessly.

So anyway, here’s (an ‘Arduino guitar device’ playing) Wonderwall.

 

REMOTICON 2021 // Hal Rodriguez and Sahrye Cohen Combine Couture and Circuitry

[Hal Rodriguez] and [Sahrye Cohen] of Amped Atelier focus on creating interactive wearable garments with some fairly high standards. Every garment must be pretty, and has to either be controllable by the wearer, through a set of sensors, or even by the audience via Bluetooth. Among their past creations are a dress with color sensors and 3D-printed scales on the front that change color, and a flowing pantsuit designed for a dancer using an accelerometer to make light patterns based on her movements.

Conductive Melody — a wearable musical instrument that is the focus of [Sahrye] and [Hal]’s Remoticon 2021 talk — was created for a presentation at Beakerhead Festival, a multi-day STEAM-based gathering in Calgary. [Sahrye] and [Hal] truly joined forces for this one, because [Sahrye] is all about electronics and costuming, and [Hal] is into synths and electronic music. You can see the demo in the video after the break.

The dress’s form is inspired by classical instruments and the types of clothing that they in turn inspired, such as long, generous sleeves for harp players and pianists. So [Hal] and [Sahrye] dreamed up a dress with a single large playable sleeve that hangs down from the mid- and upper arm. The sleeve is covered with laser-cut conductive fabric curlicues that look like a baroque interpretation of harp strings. Play a note by touching one of these traces, and the lights on the front of the dress will move in sync with the music.

[Sahrye] started the dress portion of Conductive Melody with a sketch of the garment’s broad strokes, then painted a more final drawing with lots of detail. Then she made a muslin, which is kind of the breadboard version of a project in garment-making where thin cotton fabric is used to help visualize the end result. Once satisfied with the fit, [Sahrye] then made the final dress out of good fabric. And we mean really good fabric — silk, in this case. Because as [Sahrye] says, if you’re going to make a one-off, why not make as nicely as possible? We can totally get behind that.

[Sahrye] says she is always thinking about how a wearable will be worn, and how it will be washed or otherwise cared for. That sequined and semi-sheer section of the bodice hides the LEDs and their wiring quite well, while still being comfortable for the wearer.

Inside the sleeve is an MPRP121 capacitive touch sensor and an Arduino that controls the LEDs and sends the signals to a Raspberry Pi hidden among the ruffles in the back of the dress.

The Pi is running Piano Genie, which can turn eight inputs into an 88-key piano in real time. When no one is playing the sleeve, the lights have a standby mode of mellow yellows and whites that fade in and out slowly compared to the more upbeat rainbow of musical mode.

We love to see wearable projects — especially such fancy creations! — but we know how finicky they can be. Among the lessons learned by [Sahrye] and [Hal]: don’t make your conductive fabric traces too thin, and silver conductive materials may tarnish irreparably. We just hope they didn’t have to waste too much conductive fabric or that nice blue silk to find this out.

Hackaday Links: December 5, 2021

Sad news from Germany, with the recent passing of a legend in the crypto community: Mr. Goxx, the crypto-trading hamster. The rodent rose to fame in the crypto community for his trades, which were generated at random during his daily exercise routines — his exercise wheel being used like a roulette wheel to choose a currency, and a pair of tunnels determined whether the transaction would be a buy or sell. His trading career was short, having only started this past June, but he was up 20% over that time — that’s nothing to sneeze at. Our condolences to Mr. Goxx’s owners, and to the community which sprung up around the animal’s antics.

It might seem a little early to start planning which conferences you’d like to hit in 2022, but some require a little more lead time than others. One that you might not have heard of is DINACON, the Digital Naturalism Conference, which explores the intersection of technology and the natural world. The con is set for the entire month of July 2022 and will be held in Sri Lanka. It has a different structure than most cons, in that participants attend for a week or so on a rotating basis, much like a biology field station summer session. It sounds like a lot of fun, and the setting couldn’t be more idyllic.

If you haven’t already killed your holiday gift budget buying NFTs, here’s something you might want to consider: the Arduino Uno Mini Limited Edition. What makes it a Limited Edition, you ask? Practically, it’s the small footprint compared to the original Uno and the castellated edges, but there are a bunch of other extras. Each elegant black PCB with gold silk screening is individually numbered and comes in presentation-quality packaging. But the pièce de résistance, or perhaps we should say the cavallo di battaglia, is that each one comes with a hand-signed letter from the Arduino founders. They honestly look pretty sharp, and at $45, it’s really not a bad collector’s piece.

And finally, the YouTube algorithm giveth again, when this infrastructure gem popped up in our feed. You wouldn’t think there’d be much of interest to see in a water main repair, but you’d be wrong, especially when that main is 50′ (15 m) below the surface, and the repair location is 600′ (183 m) from the access hatch. Oh yeah, and the pipe is only 42″ (1 m) in diameter, and runs underneath a river. There’s just so much nope in this one, especially since the diver has to swim into a special turning elbow just to get pointed in the right direction; how he turns around to swim out is not worth thinking about. Fascinating tidbits include being able to see the gravel used to protect the pipe in the riverbed through the crack in the pipe, and learning that big water mains are not completely filled, at least judging by the small air space visible at the top of the pipe. Those with claustrophobia are probably best advised to avoid this one, but it’s still amazing to see how stuff like this is done.

Circuit VR: Arduino Virtually Meets Analog

There was a time when building electronics and building software were two distinct activities. These days, almost any significant electronic project will use a CPU somewhere, or — at least — could. Using a circuit simulator can get you part of the way and software simulators abound. But cosimulation — simulating both analog circuits and a running processor — is often only found in high-end simulation products. But I noticed the other day the feature quietly snuck into our favorite Web-based simulator, Falstad.

The classic simulator is on the left and the virtual Arduino is on the right.

Back in March, the main project added work from [Mark McGarry] to support AVR8js written by [Uri Shaked]. The end result is you can have the circuit simulator on the left of the screen and a Web-based Arduino IDE on the right side. But how does it work beyond the simple demo? We wanted to find out.

The screen looks promising. The familiar simulator is to the left and the Arduino IDE — sort of — is to the right. There’s serial output under the source code, but it doesn’t scroll very well, so if you output a lot of serial data, it is hard to read.

Nothing is Perfect

I love just about everything about the Falstad simulator and having an Arduino cosimulation is great. But there is one really important issue that may get resolved eventually. Normally when you draw a schematic you can save it as text or encoded in a link. If you click the link or import the text, everything is back to the way it was when you saved. I use that in a lot of Circuit VR posts so you can click on a circuit and see it live.

However, the simulator does not save the source code in the virtual Arduino. You have to do that yourself. That means if you have everything working, save your circuit, and close your browser you’ll have to recreate your Arduino code next time. Luckily, I tested this out before I lost any work. There should be a big red warning on the page, though.

What that means, though, is that I can’t give you a link to follow along with examples. Here’s what you can do:

  1. Have a look at the source code.
  2. Open the simulator.
  3. Copy the text from the top of the source code comments and paste it into the simulator (detailed instructions in the comments).

Just don’t forget to save your source code changes. If you make changes to the circuit, you’ll want to export them to text and copy them into the source code so you can save everything together.

An Example

Test schematic.

I wanted an easy example that showed the benefit of using cosimulation. I settled on looking at some alternatives for doing an analog to digital conversion using successive approximation. A virtual potentiometer provides an input voltage. There’s a comparator and a buffered PWM output. Here’s the schematic:

Input/Output

There are three interface points to the Arduino. The PWM output is set as an external voltage using the “Inputs and Sources” components (remember, the output from the Arduino is the input to the circuit). Conversely, the comparator output and the connection to the Arduino’s analog converter (A0) are labeled nodes from the “Output and Labels” menu. The names are significant, including the spaces.

The Code

In theory, the code is pretty simple. You guess a voltage and read the output of the comparator to see if you are right. There are two methods in the code and you can switch between them by setting the convert define to convert0 or convert1.

On every pass through the loop, the code calls one of the convert functions to manage the successive approximation process through a different algorithm. It also updates the PWM output on each pass.

The first approximation algorithm is very simple but not very efficient. It guesses each output voltage starting at 0 and moving up 1/255 V on each pass. When the comparator goes from false to true, you know the input voltage must be less than the current voltage but more than the previous voltage.

The second algorithm is smarter and works like a binary search. The first guess is 128/255. That voltage is either higher or lower than our target. If it is lower, we remember that the bit should be on and, either way, move to the next bit. In other words, the second test will be either 64/255 or 128/255 + Simulide64/255. Again, the new value is either high or low and will determine the state of the next bit.

The first algorithm could finish fast or it may have to count all the way to 255 to find the answer. The second algorithm always takes 8 measurements. There’s no way for the comparator to tell us our reference voltage is exactly equal to the input even if we could define what that means for an analog signal. So we have to measure each bit and decide if it should be on or off.

The output appears in the serial terminal. The first number is the result of the conversion and the second is the value from the built-in converter for the same voltage.

Voltage Reference

Generating the reference voltage is the key. It would be possible to use 8 output bits and an R2R network to generate an output voltage quickly, but that eats up a lot of pins. Instead, I used one pin to generate voltages using PWM. This isn’t as fast, of course, because you have to allow the RC filter time for the voltage to reach its desired value.

Pin 9 generates a PWM signal using a time-honored technique. Suppose you want to generate 20/255 (about 8% duty cycle). You take an 8-bit accumulator and add 20 to it repeatedly. The PWM output is the carry out of the top bit. You can find a spreadsheet with the logic, but you’ll have to imagine the output waves are squares since the spreadsheet helpfully draws straight lines between points.

This spreadsheet models the PWM output logic.

To do this right, the code should run on a precise interrupt and equalize the time between outputs. However, for this quick demo, I’ve assumed the time for calling the main loop will be regular enough. I considered doing it on an interrupt, but — honestly — I’m not sure how faithful the simulator is, how time-accurate it is, and it doesn’t appear you can easily add libraries to it, so you’d almost certainly have to manage the interrupts at the register level.

The output signal gets smoothed by an RC filter. The values here are interesting and it is fun to watch the scope as you vary the parameters in this part of the circuit. You want a noise-free reference signal. So that implies a big capacitor. However, a big capacitor takes more time to charge and discharge, so the voltage will take longer to settle. It is a classic trade-off. Do you want a noisy fast response or a clean slow response?

In this case, the pot probably doesn’t change very fast, but in real life, the input signal might be changing all the time and you might even consider a sample and hold on that input to make sure it doesn’t change while you are in the middle of guessing.

Tuning

Obviously, you can change the RC values easily in the simulator. It is even possible to add sliders to set the values graphically while the simulation is running (the pot is set up to do this already). Changing the code, however, requires a stop and restart.

In the code, you can change the number of loop cycles the convert routines wait to allow a new PWM value to settle (SETTLELOOPS) and how long to pause between readings (SAMPLOOP). The interactions between these numbers and the RC values are critical. Larger RC time constants require more time to produce correct results. Smaller RC numbers will require less time, but the noise will introduce errors. Take your pick.

PWM signal with 2uF capacitor.
PWM signal with 47uF capacitor.

The Verdict

This is a toy example. The PWM generation suffers from some issues and PWM isn’t a great idea for a conversion reference. Still, it shows a good bit of what is possible with the cosimulation available with Falstad. I am really looking forward to the next time I need some exotic signal fed into a circuit. Just using the Arduino as a function generator will have its uses.

I do wish you could add libraries and save an entire project more easily. Still, there are many what-if scenarios you could simulate quickly and easily using this tool. Since it has only been in the code base for a few months, I’m hopeful some of these issues will work out over time. Add debugging to the mix, and it would be a real winner.

Tinkercad allows you to simulate Arduino, but not with the circuit sophistication of Falstad. It does require an install, but we are always surprised we don’t hear more about Simulide.

AVR Reverse Engineering Hack Chat

Join us on Wednesday, April 21 at noon Pacific for the AVR Reverse Engineering Hack Chat with Uri Shaked!

We’ve all become familiar with the Arduino ecosystem by now, to the point where it’s almost trivially easy to whip up a quick project that implements almost every aspect of its functionality strictly in code. It’s incredibly useful, but we tend to lose sight of the fact that our Arduino sketches represent a virtual world where the IDE and a vast selection of libraries abstract away a lot of the complexity of what’s going on inside the AVR microcontroller.

While it’s certainly handy to have an environment that lets you stand up a system in a matter of minutes, it’s hardly the end of the story. There’s a lot to be gained by tapping into the power of assembly programming on the AVR, and learning how to read the datasheet and really run the thing. That was the focus of Uri Shaked’s recent well-received HackadayU course on AVR internals, and it’ll form the basis of this Hack Chat. Then again, since Uri is also leading a Raspberry Pi Pico and RP2040 course on HackadayU in a couple of weeks, we may end up talking about that too. Or we may end up chatting about something else entirely! It’s really hard to where this Hack Chat will go, given Uri’s breadth of interests and expertise, but we’re pretty sure of one thing: it won’t be boring. Make sure you log in and join the chat — where it goes is largely up to you.

Our Hack Chats are live community events in the Hackaday.io Hack Chat group messaging. This week we’ll be sitting down on Wednesday, April 21 at 12:00 PM Pacific time. If time zones have you tied up, we have a handy time zone converter.

Click that speech bubble to the right, and you’ll be taken directly to the Hack Chat group on Hackaday.io. You don’t have to wait until Wednesday; join whenever you want and you can see what the community is talking about.

Hackaday Links: April 26, 2020

Gosh, what a shame: it turns out that perhaps 2 billion phones won’t be capable of COVID-19 contact-tracing using the API that Google and Apple are jointly developing. The problem is that the scheme the two tech giants have concocted, which Elliot Williams expertly dissected recently, is based on Bluetooth LE. If a phone lacks a BLE chipset, then it won’t work with apps built on the contact-tracing API, which uses the limited range of BLE signals as a proxy for the physical proximity of any two people. If a user is reported to be COVID-19 positive, all the people whose BLE beacons were received by the infected user’s phone within a defined time period can be anonymously notified of their contact. As Elliot points out, numerous questions loom around this scheme, not least of which is privacy, but for now, something like a third of phones in mature smartphone markets won’t be able to participate, and perhaps two-thirds of the phones in developing markets are not compatible. For those who don’t like the privacy-threatening aspects of this scheme, pulling an old phone out and dusting it off might not be a bad idea.

We occasionally cover stories where engineers in industrial settings use an Arduino for a quick-and-dirty automation solution. This is uniformly met with much teeth-gnashing and hair-rending in the comments asserting that Arduinos are not appropriate for industrial use. Whether true or not, such comments miss the point that the Arduino solution is usually a stop-gap or proof-of-concept deal. But now the purists and pedants can relax, because Automation Direct is offering Arduino-compatible, industrial-grade programmable controllers. Their ProductivityOpen line is compatible with the Arduino IDE while having industrial certifications and hardening against harsh conditions, with a rich line of shields available to piece together complete automation controllers. For the home-gamer, an Arduino in an enclosure that can withstand harsh conditions and only cost $49 might fill a niche.

Speaking of Arduinos and Arduino accessories, better watch out if you’ve got any modules and you come under the scrutiny of an authoritarian regime, because you could be accused of being a bomb maker. Police in Hong Kong allegedly arrested a 20-year-old student and posted a picture of parts he used to manufacture a “remote detonated bomb”. The BOM for the bomb was strangely devoid of anything with wireless capabilities or, you know, actual explosives, and instead looks pretty much like the stuff found on any of our workbenches or junk bins. Pretty scary stuff.

If you’ve run through every binge-worthy series on Netflix and are looking for a bit of space-nerd entertainment, have we got one for you. Scott Manley has a new video that goes into detail on the four different computers used for each Apollo mission. We knew about the Apollo Guidance Computers that guided the Command Module and the Lunar Module, and the Launch Vehicle Digital Computer that got the whole stack into orbit and on the way to the Moon, but we’d never heard of the Abort Guidance System, a backup to the Lunar Module AGC intended to get the astronauts back into lunar orbit in the event of an emergency. And we’d also never heard that there wasn’t a common architecture for these machines, to the point where each had its own word length. The bit about infighting between MIT and IBM was entertaining too.

And finally, if you still find yourself with time on your hands, why not try your hand at pen-testing a military satellite in orbit? That’s the offer on the table to hackers from the US Air Force, proprietor of some of the tippy-toppest secret hardware in orbit. The Hack-A-Sat Space Security Challenge is aimed at exposing weaknesses that have been inadvertantly baked into space hardware during decades of closed development and secrecy, vulnerabilities that may pose risks to billions of dollars worth of irreplaceable assets. The qualification round requires teams to hack a grounded test satellite before moving on to attacking an orbiting platform during DEFCON in August, with prizes going to the winning teams. Get paid to hack government assets and not get arrested? Maybe 2020 isn’t so bad after all.

P-51 Cockpit Recreated with Help of Local Makerspace

It’s surprisingly easy to misjudge tips that come into the Hackaday tip line. After filtering out the omnipresent spam, a quick scan of tip titles will often form a quick impression that turns out to be completely wrong. Such was the case with a recent tip that seemed from the subject line to be a flight simulator cockpit. The mental picture I had was of a model cockpit hooked to Flight Simulator or some other off-the-shelf flying game, many of which we’ve seen over the years.

I couldn’t have been more wrong about the project that Grant Hobbs undertook. His cockpit simulator turned out to be so much more than what I thought, and after trading a few emails with him to get all the details, I felt like I had to share the series of hacks that led to the short video below and the story about how he somehow managed to build the set despite having no previous experience with the usual tools of the trade.

A Novel and a Film

Grant has been making short films for a while, mainly in collaboration with John Dwyer, an author of historical novels. Grant’s shorts are used as promos for John’s books, and nicely capture the period and settings of John’s novels. Most of these films required little in the way of special sets, relying instead on stock footage and vintage costumes to achieve their look and feel. John’s latest novel would change all that.

Called Mustang, the novel centers on a hotshot fighter pilot in WWII. Grant’s vision for the short to promote the book was inspired by the recent Christopher Nolan film Dunkirk, which featured intricate sequences filmed in the cockpit of a Spitfire. Granted wanted a similar look, and began arranging to use a real P-51 Mustang for filming. That presented immediate problems. First, there aren’t that many of the vintage aircraft left, and those that are still flying usually have anachronistic instruments in the cockpit, like GPS. Also, Grant wanted the instruments to respond as if the plane were airborne, and to have the shadows cast by the canopy into the cockpit suggest aerial maneuvers. Such an effect would be difficult to achieve with a plane stuck on a runway.

That’s when Grant realized that a gimballed cockpit simulator was needed. It could have a period-accurate dashboard, be positioned outdoors to take advantage of natural daylight and real backgrounds rather than CGI, and could be pitched, rolled and yawed to simulate flight. It would be perfect, and it would save the project. There was just one problem: he had no idea how to build it.

Helping Hands

Wisely, Grant turned to his local hackerspace, Dallas Maker Space, for help. There he found not only the tools he lacked, but kindred spirits with the necessary skills and the willingness to share them. They started working on the cockpit instrument panel, which ended up including a combination of actual flight hardware and mocked-up instruments. The fake instruments used steppers and an Arduino to drive the needles, which were controlled by a custom iPad app that was used to animate them live during filming. The real instruments, like the artificial horizon and turn-and-slip indicator, were powered by a vacuum pump and responded to the movements of the simulator on its gimbals.

The gimballed cockpit set for exterior shots. The wide horizon and natural lighting combined with the 3-DOF gimbal make for a very realistic effect.

Mounting this convincing panel into something was an entirely different undertaking. Grant relied heavily on the experience of DMS members to design a structure strong enough to support the actor and allow for the motion needed to create a convincing effect. The cockpit mockup, made from plasma-cut sheet metal and plywood, is mounted to a heavy-duty three-axis gimbal, including a massive bearing from a pallet jack for the yaw axis.

Set and talent, ready for action.

Grant had originally planned to place the mockup on a mountaintop for shooting, much as the Spitfire mockup from Dunkirk was placed on the edge of a cliff to give an unobstructed horizon to simulate flying over the English Channel. When that proved logistically challenging, he set up on an airport runway and used clever camera blocking to avoid shooting the horizon. Grips manually moved the simulator while Grant manipulated the fake instruments and filmed the results, which I think speak for themselves. If only the budget – and on-set safety – would have supported simulating the massive four-blade Mustang propeller, the illusion would have been complete.

I really enjoyed digging into this project and all the hacks that it entailed. Movie magic is as much about hacking as anything else, at least behind the cameras, and it’s good to see what’s possible with a limited budget. We recently featured a low-budget but high-style sci-fi movie set build, and we’ve gone in-depth with a playback designer for the Netflix series Lost in Space, both in these pages and as a Hack Chat.

 

 

New Part Day: Arduino Goes Pro with the Portenta H7

The Consumer Electronics Show in Las Vegas is traditionally where the big names in tech show off their upcoming products, and the 2020 show was no different. There were new smartphones, TVs, and home automation devices from all the usual suspects. Even a few electric vehicles snuck in there. But mixed in among flashy presentations from the electronics giants was a considerably more restrained announcement from a company near and dear to the readers of Hackaday: Arduino is going pro.

While Arduino has been focused on the DIY and educational market since their inception, the newly unveiled Portenta H7 is designed for professional users who want to rapidly develop robust hardware suitable for industrial applications. With built-in wireless hardware and the ability to run Python and JavaScript out of the box, the powerful dual-core board comes with a similarly professional price tag; currently for preorder at $99 USD a pop, the Portenta is priced well outside of the company’s traditional DIY and educational markets. With increased competition from other low-cost microcontrollers, it seems that Arduino is looking to expand out of its comfort zone and find new revenue streams.

That’s a Lot of Pins

The Portenta H7 is obviously a far cry from the relatively dinky 8-bit Arduinos that we’ve all got filling up our parts drawers. Developed for high performance edge computing applications, the new board is powered by a 32-bit STM32H747XI that utilizes both an ARM Cortex M7 and an M4 running at 480 MHz and 240 MHz respectively. The two cores can work independently, allowing for example one core to run interpreted Python while the other runs code compiled in the Arduino IDE. When they need to work together, the cores can communicate with each other via a Remote Procedure Call (RPC) mechanism.

The new 80-pin connectors on the Portenta

Outwardly, the new board doesn’t look far removed from the modern Arduino form factor we’re used to. The USB connector has been upgraded to a Type-C, but the Portenta still retains the dual rows of pads ready for hand-soldered headers — that’s their more recent pinout that they call the Arduino MKR form factor.

If you look on the back of the board however, you’ll see that they’ve added two 80-pin high density connectors. According to the product page, these are intended to allow the Portenta to simply be plugged into a device as a removable module. The idea being that devices in the field can easily have their Portenta swapped out for an upgraded model. Some digging into the product page documentation section turns up a schematic that lists the connectors as Hirose DF40C-80DP-0.4V(51).

The base model Portenta features 8 MB SDRAM and 16 MB NOR flash, but it can be custom ordered with up to 64 MB of memory and 128 MB of flash should you need it. It’s also possible to delete various interfaces from the board when ordering, so if you don’t want network connectivity or the NXP SE050C2 crypto chip, they can simply be left off. However as of this writing it is unclear as to what minimum order quantity is necessary to unlock this level of customization, or or how much these modifications will change the unit cost.

Year of the Arduino Desktop?

The Portenta Carrier Board

The Portenta H7 is an impressive enough piece of hardware on its own, but when it’s plugged into the optional Carrier Board, things really start to get interesting. The Carrier Board provides full size connectors for all of the onboard peripherals, and according to documentation, turns the Portenta into an eNUC-class embedded computer. There’s even support for DisplayPort to connect a monitor, and miniPCI for expansion cards.

With a fully loaded Portenta H7 slotted into the Carrier Board, it would seem you have the makings of a low-power ARM “desktop” computer. Albeit one that wouldn’t outperform the Raspberry Pi Zero, and which costs several times more.

The Arduino press release and product page doesn’t make any mention of what kind of software or operating system said computer would run, so presumably that’s left as an exercise for the customer. While not particularly well suited to it, the ARM Cortex-M family of processors is capable of running the Linux kernel, so spinning up a “real” OS image for it should be possible. Of course with a maximum of just 64 MB of RAM, you’ll want to keep your performance expectations fairly low.

Where Does Portenta Fit?

We can’t even speculate what a maxed out Portenta would cost, and there’s no pricing or release date for the Carrier Board. But even at $99, the base model Portenta H7 would be a tough sell for hackers and makers who are used to buying dual-core ESP32 boards at 1/10 of the price, or the Teensy 4.0 which has a 600 MHz Cortex-M7 at 1/4 of the price. Which is fine, since this board isn’t intended for the traditional core Arduino audience.

Seeing the carrier board, we can’t help but notice some parallels here with the Raspberry Pi Compute Module. With connections broken out to a SODIMM header, the idea of the Computer Module was to help bridge the gap between the DIY community and the commercial one by offering up a Raspberry Pi in a more rugged form factor that would be easier to integrate into end-user products. But since it wasn’t any cheaper than the stock Pi, there wasn’t a whole lot of incentive to switch over. We haven’t seen consumer products advertising “Raspberry Pi Inside!” so it’s hard to tell if there has been any meaningful adoption from industry.

One has to wonder why any company that has the resources to integrate such an expensive board into their products wouldn’t just come up with their own custom design around the Portenta’s STM32H747XI chip, which even in single quantities, can currently be had for less than $15. The difference may end up coming down to the world-renowned community that surrounds the Arduino brand, and the company’s efforts to modernize their toolchain.

Review: OSEPP STEM Kit 1, a Beginner’s All-in-One Board Found in the Discount Aisle

As the name implies, the OSEP STEM board is an embedded project board primarily aimed at education. You use jumper wires to connect components and a visual block coding language to make it go.

I have fond memories of kits from companies like Radio Shack that had dozens of parts on a board, with spring terminals to connect them with jumper wires. Advertised with clickbait titles like “200 in 1”, you’d get a book showing how to wire the parts to make a radio, or an alarm, or a light blinker, or whatever.

The STEM Kit 1 is sort of a modern arduino-powered version of these kits. The board hosts a stand-alone Arduino UNO clone (included with the kit) and also has a host of things you might want to hook to it. Things like the speakers and stepper motors have drivers on board so you can easily drive them from the arduino. You get a bunch of jumper wires to make the connections, too. Most things that need to be connected to something permanently (like ground) are prewired on the PCB. The other connections use a single pin. You can see this arrangement with the three rotary pots which have a single pin next to the label (“POT1”, etc.).

I’m a sucker for a sale, so when I saw a local store had OSEPP’s STEM board for about $30, I had to pick one up. The suggested price for these boards is $150, but most of the time I see them listed for about $100. At the deeply discounted price I couldn’t resist checking it out.

So does an embedded many-in-one project kit like this one live up to that legacy? I spent some time with the board. Bottom line, if you can find a deal on the price I think it’s worth it. At full price, perhaps not. Join me after the break as I walk through what the OSEPP has to offer.

What’s Onboard?

There are plenty of input and output devices:

  • 7 Push Buttons
  • Potentiometers (3 rotary and 1 slide)
  • Passive Infrared Sensor (PIR)
  • Light Sensor
  • Sound Sensor
  • LM35 Temperature Sensor
  • 10 LEDs (various colors)
  • Servo Motor
  • Stepper Motor
  • DC Motor
  • LCD Display
  • Buzzer
  • Speaker
  • RGB LED

In addition, the kit comes with an ultrasonic distance sensor in a little bracket that can connect to the stepper motor. That’s the only part that needs power and ground that isn’t already wired up.

Because the heart of the board is an Arduino UNO clone, you can do anything you like to program it. However, OSEPP touts their visual block diagram language that is basically Scratch. You can use it for free on most platforms and there is even a Web-based version although it can’t download code. It looks like Scratch or other block-oriented systems you’ve seen before.

I’m not usually fond of the visual block languages, but this one at least shows you the actual Arduino code it generates, so that isn’t bad. But you can still use any other method you like such as the standard IDE or PlatformIO.

You can see a video about the board, below.

The Good and the Bad

The board feels substantial and able to withstand a good bit of abuse. There’s a good range of components, and I like that the arduino is a real daughter board and not just built onto the PCB. Despite using the block language, I do like the tutorial booklet. It is very slick and has projects ranging from an IR doorbell to a mini piano. You can see a page below — very colorful and clear.

Of course, the suggested retail price of $150 is a bit offputting. You might think a breadboard with a handful of LEDs and other parts would be a much lower-cost option but just look around for arduino kits for beginners and you’ll find prices are all over the place. On the other hand, with a parts kit you would have to know how to wire up things like stepper motors or DC motors, so there is some value to having it already done for you. There’s also value in not having a bag of parts to misplace.

The jumper wires in the kit have pins on one side and sockets on the other. The pins go into the Arduino’s connector and the sockets go over pins on the components. These aren’t quite as reliable as a spring clip and not as versatile either.

In my mind the worst part of the kit design is that the pins are right next to each of the components. That’s good for understanding, but it makes a mess of wiring. For instance, there are ten LEDs, and connecting them all means stretching jumper wires to both edges of the board The jumpers aren’t very long either, so any complex project is going to have wires crisscrossing the sensors and LCD.

Granted, in this image I could have removed some of the wires from the bundles but that wouldn’t help that much, either. If you need to hook up more than a few of the available components you will have a mess. I would have put some sort of spring clip or even screw terminals and put them all on the top and bottom of the board with clear color-coded marking about where they connect. Then the wiring would all be out of the way. There are probably a few other ways they could have gone, and at this price, they could afford the few extra inches on the PCB.

There are a few other things that would have been nice touches to finish off this kit. I would have enjoyed a short chapter in the booklet about using the Arduino IDE directly so that people know it exists. And having even a small breadboard attached for your own exploration would make sense, but would then call for a different type of jumper wire.

Short Example Using the Distance Sensor

I wanted to do something with the board so I decided to play with the distance sensor and the servo. The distance sensor is a bit annoying both because you have to wire it all up and it has a tendency to fall off when you transport the board.

The demo (you can find it online) won’t win any originality prizes. The program moves the servo to scan from 0 to 180 degrees in 5 degree increments. It measures the distance of what’s in front of it. When it completes a scan, if it saw something close (you could adjust the sensitivity), it moves the sensor back to that position and waits 30 seconds. Otherwise, it keeps scanning.

Really, this is no different from any other Arduino program. That’s kind of the point. Despite the emphasis in the book on the point-and-click language, this is really just an Arduino.

In Summary

For the deep sale price I found, the board will work well for its intended audience of students or anyone starting out with Arduino or microcontrollers. Even a more advanced audience who just wants a way to hammer out a quick prototype might find it worth the $30 or $40 you can sometimes pay. But at full price, it is hard to imagine this makes sense because of the mess of wire routing and limited expansion options.

Ask Hackaday Answered: The Tale of the Top-Octave Generator

We got a question from [DC Darsen], who apparently has a broken electronic organ from the mid-70s that needs a new top-octave generator. A top-octave generator is essentially an IC with twelve or thirteen logic counters or dividers on-board that produces an octave’s worth of notes for the cheesy organ in question, and then a string of divide-by-two logic counters divide these down to cover the rest of the keyboard. With the sound board making every pitch all the time, the keyboard is just a simple set of switches that let the sound through or not. Easy-peasy, as long as you have a working TOG.

I bravely, and/or naïvely, said that I could whip one up on an AVR-based Arduino, tried, and failed. The timing requirements were just too tight for the obvious approach, so I turned it over to the Hackaday community because I had this nagging feeling that surely someone could rise to the challenge.

The community delivered! Or, particularly, [Ag Prismatic]. With a clever approach to the problem, some assembly language programming, and an optional Arduino crystalectomy, [AP]’s solution is rock-solid and glitch-free, and you could build one right now if you wanted to. We expect a proliferation of cheesy synth sounds will result. This is some tight code. Hat tip!

Squeezing Cycles Out of a Microcontroller

Let’s take a look at [AP]’s code. The approach that [AP] used is tremendously useful whenever you have a microcontroller that has to do many things at once, on a rigid schedule, and there’s not enough CPU time between the smallest time increments to do much. Maybe you’d like to control twelve servo motors with no glitching? Or drive many LEDs with binary code modulation instead of primitive pulse-width modulation? Then you’re going to want to read on.

There are two additional tricks that [AP] uses: one to fake cycles with a non-integer number of counts, and one to make the AVR’s ISR timing absolutely jitter-free. Finally, [Ag] ended up writing everything in AVR assembly language to make the timing work out, but was nice enough to also include a C listing. So if you’d like to get your feet wet with assembly, this is a good start.

In short, if you’re doing anything with hard timing requirements on limited microcontroller resources, especially an AVR, read on!

Taking Time to Think

The goal of the top-octave generator is to take an input clock and divide it down into twelve simultaneous sub-clocks that all run independently of each other. Just to be clear, this means updating between zero and twelve GPIO pins at a frequency of 1 MHz or so — updating every twenty clock cycles at the AVR’s maximum CPU speed. If you thought you could loop through twelve counters and decide which pins to flip in twenty cycles, you’d be mistaken.

But recognizing the problem is the first step to solving it. Although the tightest schedule might require flipping one pin exactly twenty clocks after flipping another, most of the time there are more cycles between pin updates — hundreds up to a few thousand. So the solution is to recognize when there is time to think, and use this time to pre-calculate a buffer full of next states.

[Ag]’s solution uses a few different loops that run exactly 20, 40, and 60 cycles each — the longer versions being just the 20-cycle one padded out with NOPs. These loops run inside an interrupt-service routine (ISR). When there are 80 or more cycles of thinking time until the next scheduled pin change, control is returned to the main loop and the next interrupt is set to re-enter the tight loops at the next necessary update time.

All the fast loop has to do is read two bytes, write them out to the GPIO pins, increment the pointer to the next row of data, and figure out if it needs to stall for 20 or 40 additional cycles, or set the ISR timer for longer delays and return to calculations. And this it can do in just twelve of the twenty cycles! Slick.

Buffers

Taking a step back from the particulars of the top-octave generator, this is a classic problem and a classic solution. It’s worth your time to internalize it, because you’ll run into this situation any time you have real-time constraints. The problem is that on average there’s more than enough time to complete the calculations, but that in the worst cases it’s impossible. So you split the problem in two parts: one that runs as fast as possible, and one that does the calculations that the fast section will need. And connecting together fast and slow processes is exactly why computer science gave us the buffer.

In [AP]’s code, this buffer is a table where each entry has two bytes for the state of the twelve GPIO pins, and one byte to store the number of clock cycles to delay until the next update. One other byte is left empty, yielding 64 entries or 256 bytes for the whole table. Why 256 bytes? Because the AVR has an 8-bit unsigned integer, wrapping around from the end of the table back to the beginning is automatic, saving a few cycles of wasteful if statements.

But even with this fast/slow division of labor, there is not much time left over for doing the pre-calculation. Sounding the highest C on a piano keyboard (4186 Hz) with a 20 MHz CPU clock requires toggling a GPIO pin every 2,390 cycles, so that’s the most time that the CPU will ever see. When the virtual oscillators are out of phase, this can be a lot shorter. By running the AVR at its full 20 MHz, and coding everything in assembly, [AP] can run the calculations fast enough to support twelve oscillators. At 16 MHz, there’s only time for ten, so every small optimization counts.

Some Optimization Required

Perhaps one of the cleverest optimizations that [AP] made is the one that makes this possible at all. The original top-octave chips divide down a 2 MHz square wave by a set of carefully chosen integer divisors. Running the AVR equivalent at 2 MHz resolution would mean just ten clocks per update and [AP]’s fast routine needed twelve, so the update rate would have to be halved. But that means that some odd divisors on the original IC would end up non-integral in the AVR code. For example, the highest C is reproduced in silicon as 2 MHz / 239, so to pull this off at 1 MHz requires counting up to 119.5 on an integer CPU. How to cope?

You could imagine counting to 119 half of the time, and 120 the other. Nobody will notice the tiny difference in duty cycle, and the pitch will still be spot on. The C programmer in me would want to code something like this:

uint8_t counter[12] = { 0, ... };
uint8_t counter_top[12] = { 119, ... };
uint8_t is_counter_fractional[12] = { 1, 0, ... };
uint8_t is_low_this_time[12] = { 0, ... };

// and then loop
for ( i=0 ; i<12; ++i){
  if ( counter[i] == 0 ){
    if ( is_counter_fractional[i] ){
      if ( is_low_this_time[i] ){
        counter[i] = counter_top[i];
    is_low_this_time = 0;
      else {
        counter[i] = counter_top[i] + 1;
    is_low_this_time = 1;
      }
    }
  }
}

That will work, but the ifs costs evaluation time. Instead, [AP] did the equivalent of this:

uint8_t counter[12] = { 0, ... };
uint8_t counter_top[12] = { 119, ... };
uint8_t phase[12] = { 1, 0, ... };

for ( i=0 ; i<12; ++i){
  if ( counter[i] == 0 ){
    counter[i] = counter_top[i] + phase[i];
    counter_top[i] = counter[i];
    phase[i] = -phase[i];
  }
}

What’s particularly clever about this construction is that it doesn’t need to distinguish between the integer and non-integer delays in code. Alternately adding and subtracting one from the non-integer values gets us around the “half” problem, while setting the phase variable to 0 means that the integer-valued divisors run unmodified, with no ifs.

The final optimization shows just how far [AP] went to make this AVR top-octave generator work like the real IC. When setting the timer to re-enter the fast loop in the ISR, there’s the possibility for one cycle’s worth of jitter. Because AVR instructions run in either one or two clock cycles, it’s possible that a two-cycle instruction could be running when the ISR timer comes due. Depending on luck, then, the interrupt will run four or five clocks later: see the section “Interrupt Response Time” in the AVR data sheet for details.

In a prologue to the ISR, [AP]’s code double-checks the hardware timer to see if it has entered on a one-cycle instruction, and adds in an extra NOP to compensate. This makes the resulting oscillator nearly jitter free, pushing out a possible source of 50 ns (one cycle at 20 MHz) slop. I don’t think you’d be able to hear this jitter, but the result surely looks pretty on the oscilloscope, and this might be a useful trick to know if you’re ever doing ultra-precise timing with ISRs.

The Proof of the Pudding

Naturally, I had to test out this code on real hardware. The first step was to pull a random Arduino-clone out of the closet and flash it in. Because “Arduinos” run at 16 MHz with the stock crystal, the result is that a nominal 440 Hz concert A plays more like a slightly sharp F, a musical third down. It sounds fine on its own, but you won’t be able to play along with any other instruments that are tuned to 440 Hz.

[AP]’s preferred solution is to run the AVR chip at 20 MHz. Since the hardware requirements are very modest, you could use a $0.50 ATTiny816 coupled with a 20 MHz crystal and you’d have a top-octave generator for literal pocket change — certainly cheaper than buying even an Arduino clone. I tested it out with an ATMega48P and a 20 MHz crystal on a breadboard because it’s what I had. Or you could perform crystalectomy on your Arduino to get it running at full speed.

We went back and forth via e-mail about all the other (firmware) options. [AP] had tried them all. You could trim the ISR down to 16 cycles and run at 16 MHz, but then there’s only enough CPU time in the main loop to support ten notes, two shy of a full octave. You could try other update rates than 1 MHz, but the divisors end up being pretty wonky. To quote [AP] from our e-mail discussion on the topic:

“After playing with the divider values from the original top octave generator IC and trying different base frequencies, it appears that the 2 MHz update rate is a “sweet spot” for getting reasonable integer divisors with < +/-2 cents of error. The original designers of the chip must have done the same calculations.”

To make a full organ out of this setup, you’ll also need twelve binary counter chips to divide down each note to fill up the lower registers of the keyboard, but these are easy to design with and cost only a few tens of cents apiece. All in all, thanks to [AP]’s extremely clever coding, you can build a fully-polyphonic noisemaker that spits out 96 simultaneous pitches, all in tune, for under $10. That’s pretty amazing.

And of course, I’ve already built a small device based on this code, but that’s a topic for another post. To be continued.