Ping-Pong Ball Makes Great PID Example

It is a common situation in electronics to have a control loop, that is some sort of feedback that drives the input to a system such as a motor or a heater based upon a sensor to measure something like position or temperature. You’ll have a set point — whatever you want the sensor to read — and your job is to adjust the driving thing to make the sensor read the set point value. This seems easy, right? It does seem that way, but in realitythere’s a lot of nuance to doing it well and that usually involves at least some part of a PID (proportional, integral, derivative) controller. You can bog down in math trying to understand the PID but [Electronoobs] recent video shows a very simple test setup that clearly demonstrates what’s going on with an Arduino, a motor, a distance sensor, and a ping-pong ball. You can see the video below.

Imagine for a moment heating a tank of water as an example. The simple approach would be to turn on the heater and when the water reaches the setpoint, turn the heater off. The problem there is though that you will probably overshoot the target. The proportional part of a PID controller will only turn the heater fully on when the water is way under the target temperature. As the water gets closer to the right temperature, the controller will turn down the input — in this case using PWM. The closer the sensor reads to the setpoint, the lower the system will turn the heater.

Continue reading “Ping-Pong Ball Makes Great PID Example”

HDMI From Your Arduino

Creating a video signal from a computer, a job that once required significant extra hardware, is now a done deal with a typical modern microcontroller. We’ve shown you more NTSC, PAL, and VGA projects than you can shake a stick at over the years. Creating an HDMI video signal however is not so straightforward. It’s not a loosely defined analogue standard but a tightly controlled digital one upon which the clever hacks that eke full colour composite video from a single digital I/O pin will have little effect. Surely creating them from a simple microcontroller will be impossible! Not according to [techtoys], who has created an Arduino shield that creates an HDMI output from an SPI control input.

At its heart are two interesting integrated circuits that give us a little bit of insight into creating graphics at this level. First up is an RA8876 MIPI TFT controller which is a full graphics engine that produces a digital RGB output, followed by a CH7035B HDMI encoder that produces an HDMI output from the RGB. This combination of chips is particularly interesting one, because the RA8876 supports a variety of different interfaces that between them should be able to talk to most microcontrollers. In the Arduino world the only other HDMI options come via the use of an FPGA.

This is a project that seems to have been around for a couple of years, but which is still an active one. The classic Arduino shield form factor may now seem a little past its zenith, but as this board shows it’s still capable of being used for interesting new applications.

Thanks [th_in_gs] for the tip.

Tiny Game System Is An Experiment In Minimalism

Many people assumed the smartphone revolution would kill the dedicated handheld game system, and really, it’s not hard to see why. What’s the point of buying the latest Nintendo or Sony handheld when the phone you’re already carrying around with you is capable of high-definition 3D graphics and online connectivity? Software developers got the hint quickly, and as predicted, mobile gaming has absolutely exploded over the last few years.

But at the same time, we’ve noticed something of a return to the simplistic handheld systems of yore. Perhaps it’s little more than nostalgia, but small bare-bones systems like the one [Mislav Breka] has entered into the 2019 Hackaday Prize show that not everyone is satisfied with the direction modern gaming has gone in. His system is specifically designed as an experiment to build the most minimal gaming system possible.

In terms of the overall design, this ATMega328 powered system is similar to a scaled-down Arduboy. But while the visual similarities are obvious, the BOM that [Mislav] has provided seems to indicate a considerably more spartan device. Currently there doesn’t seem to be any provision for audio, nor is there a battery and the associated circuitry to charge it. As promised, there’s little here other than the bare essentials.

Unfortunately, the project is off to something of a rocky start. As [Mislav] explains in his writeup on Hackaday.io, there’s a mistake somewhere in either the board design or the component selection that’s keeping the device from accepting a firmware. He won’t have the equipment to debug the device until he returns to school, and is actively looking for volunteers who might be interested in helping him get the kinks worked out on the design.

Tea Bot Solves Another First World Problem

In the movie Wall-E, future humans live in floating chairs and have everything done for them. Today, we grumble if we have to go to physically find a light switch or a remote control. How far away can floating chairs with screens be? T2, the Tea Bot, gets us one step closer to that. Using a laser-cut frame, an ESP8266, and a servo motor, the T2 brews your tea for exactly the right amount of time.

We were kind of hoping the robot would at least dunk the tea bag in and out, but it does provide a web interface that lets you select the brew. Of course, the code is available, so you could make modifications — maybe turn on a hotplate underneath the cup.

Continue reading “Tea Bot Solves Another First World Problem”

High Precision Analog IO With Digital Pins

Reading the temperature of your environment is pretty easy right? A quick search suggests the utterly ubiquitous DHT11, which speaks a well documented protocol and has libraries for every conceivable microcontroller and platform. Plug that into your Arduino and boom, temperature (and humidity!) readings. But the simple solution doesn’t hit every need, sometimes things need to get more esoteric.

The technique summarized by an image from Microchip Appnote AN685

For years we’ve been watching [Edward]’s heroic efforts to build accessible underwater sensing hardware. When we last heard from him he was working on improving the accuracy of his Arduino’s measurements of the humble NTC thermistor. Now the goal is the same but he has an even more surprising plan, throw the ADC out entirely and sample an analog thermistor using digital IO. It’s actually a pretty simple trick based on an intuitive observation, that microcontrollers are better at measuring time than voltage. 

The basic circuit

The circuit has a minimum of four components: a reference resistor, the thermistor, and a small capacitor with discharge resistor. To sense you configure a timer to count, and an edge interrupt to capture the value in the timer when its input toggles. One sensing cycle consists of discharging the cap through the discharge resistor, enabling the timer and interrupt, then charging it through the value to measure. The value captured from the timer will be correlated to how long it took the cap to charge above the logic-high threshold when the interrupt triggers. By comparing the time to charge through the reference against the time to charge through the thermistor you can calculate their relative resistance. And by performing a few calibration cycles at different temperatures ([Edward] suggests at least 10 degrees apart) you can anchor the measurement system to real temperature.

For all the gory details, including tips for how to save every last joule of energy, check out [Edward]’s post and the Microchip appnote AN685 he references. Besides this series [Edward]’s Cave Pearl Project has already yielded an impressive number of Hackday posts. For more great hardware writeups check out a general hardware build for a single sensing node, or the “temperature sensor” [Edward] made with no external parts at all!

Developing An Automatic Tool For CAN Bus Hacking

In the old days, a physical button or switch on the dashboard of your car would have been wired to whatever device it was controlling. There was potentially a relay in the mix, but still, it wasn’t too hard to follow wires through the harness and figure out where they were going. But today, that concept is increasingly becoming a quaint memory.

Assuming your modern car even has physical buttons, pushing one of them likely sends a message over the CAN bus that the recipient device will (hopefully) respond to. Knowing how intimidating this can be to work with, [TJ Bruno] has been working on some software that promises to make working with CAN bus user interfaces faster and easier. Ultimately, he hopes that his tool will allow users to rapidly integrate custom hardware into their vehicle without having to drill a hole in the dashboard for a physical control.

But if you’re the kind of person who doesn’t like to have things done for them (a safe bet, since you’re reading Hackaday), don’t worry. [TJ] starts off his write-up with an overview of how you can read and parse CAN messages on the Arduino with the MCP2515 chip. He breaks his sample Sketch down line by line explaining how it all works so that even if you’ve never touched an Arduino before, you should be able to get the gist of what’s going on.

As it turns out, reading messages on the CAN bus and acting on them is fairly straightforward. The tricky part is figuring out what you’re looking for. That’s where the code [TJ] is working on comes in. Rather than having to manually examine all the messages passing through the network and trying to ascertain what they correspond to, his program listens while the user repeatedly presses the button they want to identify. With enough samples, the code can home in on the proper CAN ID automatically.

The upside to all this is that you can activate aftermarket functions or hardware with your vehicle’s existing controls. Need an example? Check out the forward-looking camera that [TJ] added to his his 2017 Chevy Cruze using the same techniques.

Continue reading “Developing An Automatic Tool For CAN Bus Hacking”

An Epic Tale Of Thermistors: Tricks For Much Better Temperature Sensing

For years [Edward] has been building professional grade underwater sensing nodes at prices approachable for an interested individual without a government grant. An important component of these is temperature, and he has been on a quest to get the highest accuracy temperature readings from whatever parts hit that sweet optimum between cost and complexity. First there were traditional temperature sensor ICs, but after deploying numerous nodes [Edward] was running into the limit of their accuracy. Could he use clever code and circuitry to get better results? The short answer is yes, but the long answer is a many part series of posts starting in 2016 detailing [Edward]’s exploration to get there.

Orange is 12 bits, red is 24

The first step is a thermistor, a conceptually simple device: resistance varies with temperature (seriously, how much more simple can a sensor get?). You can measure them by tapping the center of a voltage divider the same way you’d measure any other resistance, but [Edward] had discarded this idea because the naive approach combined with his Arduino’s 10 bit ADC yielded resolution too poor to be worthwhile for his needs. But by using the right analog reference voltage and adjusting the voltage divider he could get a 20x improvement in resolution, down to 0.05°C in the relevant temperature range. This and more is the subject of the first post.

What comes next? Oversampling. Apparently fueled by a project featured on Hackaday back in 2015 [Edward] embarked on a journey to applying it to his thermistor problem. To quote [Edward] directly, to get “n extra bits of resolution, you need to read the ADC four to the power of n times”. Three bits gives about an order of magnitude better resolution. This effectively lets you resolve signals smaller than a single sample but only if there is some jitter in the signal you’re measuring. Reading the same analog line with no perturbation gives no benefit. The rest of the post deals with the process of artificially perturbing the signal, which turns out to be significantly complex, but the result is roughly 16 bit accuracy from a 10 bit ADC!

What’s the upside? High quality sensor readings from a few passives and a cheap Arduino. If that’s your jam check out this excellent series when designing your next sensing project!