A Raspberry Pi can be found centric to 3D printers and other CNC machines—almost since the sale of the first Raspberry Pi. Wired had an article about it back in 2013! But can a Pi cut it as a CNC brain? How fast can a Raspberry Pi toggle a digital output pin? A Pi (depending on the model) ticks along at near or just above the 1-GHz mark. So, off the cuff, you can bet it is really, really fast. The problem with that particular assessment is “really, really fast” is not an exact unit of measure.
Boomerangs and magic bullet blenders also go super-fast, so are they all going at the same speed? There is only one way to find out. Test’em, so we know what’s fastest—blenders, boomerangs, or Raspberry Pis. Just kidding, we will just test the Raspberry Pi with a few different types of code to measure the pin toggle speed.
Only two essential pieces of equipment were required for testing. A Raspberry Pi of course (in this case a Pi 3) and an oscilloscope to measure and observe what was going on.
It was decided that the Pi would be tested with C, Java, and Python. The code, regardless of the language, is all very similar to what you might otherwise use to blink an LED. The only difference is the lack of a delay between switching a pin HIGH or LOW. In fact, an LED and a resistor were used as a visual indicator while writing the code (Fig. 1).
Python was a bit faster to get working than its Java and C counterparts. To control the Raspberry Pi’s pins, it employs the “RPi.GPIO” module. This module is already part of the Python installation on the RasPi, so there weren’t any extra libraries that needed to be installed.