Teensy 3.1 analog help

Status
Not open for further replies.
I've got a couple questions about analog inputs with the teensy.

I'm using a 10kohm potentiometer (BI tech P270, linear taper, polymer element) to measure the absolute position of a shaft. I'm getting what I feel is a surprising level of noise, with a DC bias, but I'm a mere MechE so I'm probably missing something.

The pot is connected VCC to ground. Power is being supplied from a 5VDC switching regulator on a pololu speed controller, through a linear regulator (MIC2937A-3.3WT). Analog resolution is set to 13 bits via analogReadRes. Analog reference is the default VCC.


First problem - I hooked an analog pin to an accurate voltage divider (two 10kohm .05% thin film resistors), and it's showing a fairly strong voltage bias.
EDIT:OK, this one was my fault. The pin I was using had the internal pullup on. That'll do it every time.

* does the VCC as a reference clamp at 3.333V, such that my 3.367V input is causing a bias?
* is there anything else that would cause such a bias?

Second problem - I'm getting variation of about 20 counts, which is about 0.25% error. Is that roughly the expected level of noise? Seems pretty consistent on both potentiometer lines and the voltage divider line.
 
Last edited:
Hello and welcome to the forums :)
The pot is connected VCC to ground. Power is being supplied from a 5VDC switching regulator on a pololu speed controller, through a linear regulator (MIC2937A-3.3WT). Analog resolution is set to 13 bits via analogReadRes. Analog reference is the default VCC.


First problem - I hooked an analog pin to an accurate voltage divider (two 10kohm .05% thin film resistors), and it's showing a fairly strong voltage bias.
EDIT:OK, this one was my fault. The pin I was using had the internal pullup on. That'll do it every time.

* does the VCC as a reference clamp at 3.333V, such that my 3.367V input is causing a bias?
* is there anything else that would cause such a bias?
The Teensy 3 series is Max 3.3V only for analogs(can also provide an external source up to 3.3V or use the internal 1.2V), 5V safe for digital pins.

Second problem - I'm getting variation of about 20 counts, which is about 0.25% error. Is that roughly the expected level of noise? Seems pretty consistent on both potentiometer lines and the voltage divider line.
That sounds pretty good, but standard practice for the Teensy is to add a 0.1uF cap from the ADC pin to GND. That should cut down on noise. Also if you post the code your using we can probably help more since you don't mention if your using averaging or what speed your using for the ADC Conversion or Sample time.
 
I'm getting variation of about 20 counts, which is about 0.25% error. Is that roughly the expected level of noise?

Actually, that's quite good when your analog signal derives from a switching power supply that's powering a moving stepper motor! That's a recipe for terrible analog noise.
 
You should connect the pot between 3.3V and AGND. Run 3 dedicated wires from the pot directly to the Teensy. Do not share any of the analog wires with any of the motor wires, especially do not use the same wire for ground. Use GND for the motor control, and AGND for the analog ground to the pot.

Normally a small capacitor can help. For human user interface, the small delay isn't usually noticeable. But for position feedback, the lag could really cause your a lot of pain if you're trying to do any sort of numerical feedback to control the motor. Then again, if you're not implementing any feedback control algorithms, a small capacitor between the analog input and AGND might help. Use ceramic NP0 or C0G types. The type of capacitor is more important than the actual value.
 
Thanks guys.

I dropped a pair of 0.1uF caps in, and that brought it down to 15 counts. It should work even at 20 - the pot position is being run through an integrator so the noise should get squashed a little by that as well. If the delay is too much I'll pull'em back out. Pots are twisted pair (VCC/GND and Sig/GND) pigtails.

The Teensy 3 series is Max 3.3V

Specsheet says 3.6Vmax unless I'm reading it incorrectly. Anyway, the regulator seems to float around a bit, and is normally much closer to 3.33.

you don't mention if your using averaging or what speed your using for the ADC Conversion or Sample time.

All defaults, sampling at ~50Hz. Haven't messed around with that at all.

Actually, that's quite good when your analog signal derives from a switching power supply that's powering a moving stepper motor!

Two DC brushed motors, a BLDC motor, and a BLDC servo drive. The power stages are actually at 24V and 60V. The pololu controller knocks it down to 5V for the electronics (I actually don't know if it's a switching regulator or a linear regulator - I assume switching) and the linear reg knocks that down to 3.33V.
 
Last edited:
Specsheet says 3.6Vmax unless I'm reading it incorrectly.

Yes, you are indeed reading this spec incorrectly. That's the maximum voltage you're supposed to apply to analog only pins without causing damage to the hardware. The digital pins with analog are 5V tolerant on the MK20DX256 chip, but the analog only pins are not.

But just because a voltage doesn't damage the pin does not mean the ADC can successfully measure it. That 3.6V spec is about hardware damage, not measurement capability.

The maximum voltage which can be actually measured depends on the selected analog reference. By default that's the 3.3V power. You can also apply a lower AREF voltage, or use the internal 1.2V reference. Whatever reference voltage is selected determines the maximum voltage the ADC reads. Anything higher than the maximum reads the same number.
 
OK, sounds good.

I'll keep an eye on it. I think the high voltage I read previously was a measurement error - the regulator seems to be stable at the correct voltage now.

Thanks!
 
Status
Not open for further replies.
Back
Top