Use teensy microcontrollers instead of arduinos

This post is mostly just an advertisement for the teensy family of microcontrollers (MCUs).

People like to use ‘arduino’ as shorthand for easy to use MCU (and wherever you go you see arduinos with ratsnets of loose wires stuck in the headers) but in almost all cases you should use a teensy instead. Arduinos have given many people the wrong  impression that cheap and easy to use MCUs are not powerful enough to do some pretty heavy lifting.

Teensy is the project of Paul Stoffregen (twitter, github, buy teensys at https://www.pjrc.com/teensy/) – I use these so much in quick experiments and main rigs its hard to count how many I bought.

There are two versions you should consider – the teensy 3.2 which you’ll use for most stuff, and the teensy 3.6 which is even faster, has more pins, but can not handle 5V signals. There is also a cheaper LC version, use that if you need _many_ for some fun project. If you are currently using arduinos, just get a teensy 3.2.

Upsides:

  • Good price: Its its $11 for the LC version, 25 for the 3.2 workhorse and $30 for the 3.6 monster.
  • Insane speeds: the teensy 3.6 runs a 32 bit 180 MHz ARM Cortex-M4 processor with an FPU. That’s enough to run a wall-size LED screen.
  • Fast serial connection to PC. You can stream over 0.6 MB/s (megabytes per second) from a PC with these (source).
  • Many bus types are supported: Connect multiple i2c buses/peripherals to one teensy. I used this for all kinds of sensors/actuators.
  • Breadboard compatible. Its set up in a nice .1″ grid so it snaps into breadboards, not some fully insane proprietary half-offset pattern. This means you can use a breadboard and not have your rig fail in the middle of an experiment like an arduino with loose wires will.
  • So many fun built-in functions. Timers, interrupts, capacitive sensors, ADCs/DACs.
  • Great real analog i/o. This deserves its own point. These things can read two analog signals with 13bit usable resolution (more info). (Use the i2c bus to add more ADCs though if you need em). There’s also pretty nice DACs on there (more info).
  • Great community. If you google arduino problems you will likely eventually find the true solutions to basic problems. The teensy forums are full of usable solutions, even to tricky problems.

Downsides:

  • If you want the fastest one (the 3.6 at the time of writing) you can only use 3.3V signals, so use a 3.2 if you need 5V inputs/outputs.
  • On some linux systems, the teensy needs a physical reset after re-programming. Make sure you don’t block that button in your project 🙂

Some examples
of stuff that we’ve done that would be impossible with an arduino but were easy with a teensy:

  • Makeshift 100kHz signal generator and digitizer to measure the frequency response of a tunable lens.
  • Read a very precise quadrature encoder  by counting pulses at kiloherz speeds using the built-in hardware counters and some libraries.
  • Smooth control over stepper motors with microstepping libraries.
  • Capacitive touch buttons.
  • Running a pretty complex control loop with a bunch of floating point math and multiple i2c interfaces talking to a few sensors and a serial uplink to a PC at 500Hz.

To the average user, teensys look and behave just like arduinos, you use the same software to program them, all regular arduino code just works on them, but they go so much faster and further.

How to:

  • Buy one (or 4 or so, you’ll want more) from PJRC.
  • Install the arduino software (check that your version is supported, as of writing the latest supported one is 1.8.8).
  • Install Teensyduino.
  • Install the blink example, enjoy the blinking LED.
  • Go solve real problems.
This entry was posted in Technical things. Bookmark the permalink.

Comments are closed.