How often is your microcontroller actually doing something? You can find out by measuring idle time, but how exactly do you do this? [Jack Ganssle] shows that simple embedded applications can toggle a pin when idle, which can then be measured. More complex applications like those using a Real Time Operation System can do the same by making use of the idle hook. But what can you do to make this toggling pin feedback actually mean something?
His solution is to repurpose an analog multimeter. The meter is interface with the toggle pin and a trimpot calibrates the needle. This way the needle jumps when the processor is busy and returns to zero when idle. What a great tip for getting a little more feedback about what’s going on inside of that black plastic IC package. It’s not surprising to find such a clever hack from one of the Hackaday Prize judges.
While you’re in the analog multimeter aisle you might want to pick up a couple of extras for more alternate data displays.
I must have missed something because I was highly unimpressed.
Personally I like the fact that needle movement’s inherent inertia helps to average the alternating high/low states into a nice, clear, analog readout. If I were to implement average CPU load calculation within the embedded system itself it would definitely end up more of a burden for the CPU than wiggling its pin. Plus the movement catches your eye on a sudden load spike.
This is an old trick but it is *very* useful and *very* few people seem to know about it.
really? i think its quite elegant, an analog meter smoothed out what is essentially a PWM reading and displayes it in an acceptable manor, and all done by a device which is not designed to do the job in hand. its a hack, today is a day….
Done that ages ago. Some RTOS has stats module…
On one of my old PC motherboard, there was a ACPI green LED that shows the CPU activities. I hooked up a LED bar graph with a RC filter and use that as my CPU meter.
I toggle an I/O in IRQ entry/exit to measure the execution time of my IRQ.
May be next time I make tea, I submit it as a hack too!?
Only if you grow, pick, ferment, and package your own tea.
The trick in the video is to run an uninterruptable set/clear task while the RTOS is idle.This is just ONE single point to modify the software. If the system is 100% idle, it may only provide a low duty cycle (scheduler consumes time, too) – but this does not matter for the analog meter.
This is getting a little away from the hack, but if you’re looking at microcontroller power monitoring, the EnergyTrace++ feature in some of the newer MSP430s is awesome. It has logging and graphing of power usage even split by different parts of the device.
My favorite trick is to set a GPIO low when idle and high if any ISR (including the RTOS schedule timer) triggers. Then you can do a duty cycle measurement with a multimeter or scope to check the CPU usage.