PWM: Teensy to Drive Analog Gauge

Hey all,

Looking to set up an analog gauge driven by a Teensy. The idea is the Teensy receives data from various devices over CANbus and then translates it to a PWM signal to drive a gauge.

Anyone done this, or something similar using a PWM output on the Teensy?
 
I've use Teensy to write a PWM signal to a transistor to vary fan speed. Have a look at analogWrite on a digital pin.
 
Ah, so using a transistor as an intermediary (not running a PWM fan directly off of the Teensy), gotcha. Are you aware of the current limits with the 4.0 on the PWM analogWrite pins? The draw of the stepper motors on most gauges seems to be 20mA or less, wondering if a transistor is necessary.
 
I believe the current capability of a digital pin is around 20 ma. If you are just trying to drive a mechanical gage (like a car speedometer), I'm guessing the Teensy will work from a current perspective. What voltage do the gages need? Teensy will only output 0 to 3v3 so a transistor may be needed.
 
I believe the current capability of a digital pin is around 20 ma
When we are talking about a Teensy 4.x, than, according to this page, "The recommended maximum output current is 4mA."

The draw of the stepper motors on most gauges seems to be 20mA or less, wondering if a transistor is necessary.
If the motor of the analog gauge is indeed a stepper motor, you won't be able to drive that with a PWM signal. Better to use the TeensyStep library (and probably some transistors).

Paul
 
Hey Paul-

Thanks for the suggestion -- definitely sounds like the way to go. The TeensyStep library is (per the GitHub readme, at least) not compatible with Teensy 4.0/4.1. I'd like to avoid building anything new around old hardware which is hard to source currently, so wondering if there's another option or if the library is compatible with the 4.0 but just not listed.

Reider
 
Code:
// TEENSY 3.0 - Teensy 3.6 ==================================================================================

#if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
#include "timer/teensy3/TimerField2.h"

// TEENSY 4 ================================================================================================

#elif defined(__IMXRT1052__)
#include "timer/teensy4/TimerField.h"
As you can see from this snippet from TeensyStep,h it is compatible with Teensy 4.0/4.1.
This code was taken from the GitHub site.

EDIT: Oops Wrong Again. See #8 below.
 
Last edited:
No, TeensyStep is not compatible with T4.x. Are you sure that your gauge has a stepper motor? Do you have a datasheet?
 
Bit of a change of plans: doing some testing on a gauge like this (https://www.amazon.com/Samdo-Marine...&sprefix=needle+fuel+gauge,aps,81&sr=8-8&th=1) and it seems like resistive-type gauges are the most readily available so would like to go this route. These gauges have a +12v, GND, and a sensor connector that varies the gauge readout based on the resistance to ground. For this gauge (which accepts resistances between 0-190ohm between the sensor pin and ground), 0ohm is the 'full' gauge position and 190ohm is the 'empty gauge position.

To drive this with the Teensy my understanding is that the PWM pins on the 4.0 can be used to switch a low side switching transistor, which can simulate various resistances in this range based on the PWM duty cycle putting the signal pin to ground.

Any thoughts/feedback? Working on a schematic now, I'll send it on here to get feedback once it's a bit more complete :D
 
Back
Top