Issue with ADC on Teensy 3.2

495 views
Skip to first unread message

Ben Sanders

unread,
Feb 21, 2016, 11:44:35 PM2/21/16
to Mozzi-users

Hello,


I am having an issue with the ADC on a Teensy 3.2.  I currently am using the DAC, have potentiometers on all the other analog lines, and have LEDs off 8 of the digital lines.  I am using Arduino IDE 1.6.5 and Teensyduino 1.2.5.


When I do a test with my setup without Mozzi using analogRead, I can read the potentiometers fine.  However, when I change the test to use Mozzi and mozziAnalogRead, I get either 2048, 0, or things like 286265102 as the value.


Can anyone see what I'm doing wrong here?  I attached the two test programs (non_mozzi_pot_test is without Mozzi and uses analogRead, sensor_read_test uses Mozzi and mozziAnalogRead).


Thanks!

-Ben


sensor_read_test.ino
non_mozzi_pot_test.ino

Ben Sanders

unread,
Feb 23, 2016, 11:24:39 PM2/23/16
to Mozzi-users
Ok, strangely I found that that if I only read a few of the pins like {A0, A1, A4, A5, A6, A9} it works, but then I add A2 and it goes back to the strange behaviour.  Very confusing.

I'm also having something where sometimes the readings will all go to zero (in the case where I"m only reading a few pins and they are returning sane values).  But if I try measuring the voltage across a particular potentiometer with my voltmeter, they start working again.

I would think it was something strange with the wiring except that it all works fine when I'm using the normal analogRead function.

Tim Barrass

unread,
Feb 24, 2016, 6:15:01 AM2/24/16
to mozzi...@googlegroups.com
Hi Ben,
mmm tough one - it's a while since I ported to Teensy3.1, but a clue might be that Mozzi uses the Teensy ADC library, where your non-Mozzi test uses the Teensyduino analogRead() function.  I think at the time I was working on it, the library seemed easier to understand than low-level Teensy programming.  Mozzi only uses one of the 2 available adc objects in the library - I'm not sure if this could cause problems.  Also, Mozzi was ported using a 2014 version of ADC - I don't know if much has changed since then.

I'm afraid the amount of time I am able to spend on troubleshooting Mozzi on the variety of processors is very limited these days, so it would be great if any other members of the community have any insight into these kind of issues...

Sorry no quick solution from me...

TIm

--
You received this message because you are subscribed to the Google Groups "Mozzi-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mozzi-users...@googlegroups.com.
To post to this group, send email to mozzi...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/mozzi-users/c25aa63f-a028-47fe-96ba-01f5bb78332b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ben Sanders

unread,
Feb 24, 2016, 12:39:30 PM2/24/16
to Mozzi-users
Thanks for the response!

What about just using analogRead instead of mozziAnalogRead in my sketch?  I had a small test last night where I looped through some pots in a step sequence and had a sine wave generated based on those using analogRead, and it seemed to be working fine.

Tim Barrass

unread,
Feb 24, 2016, 6:07:05 PM2/24/16
to mozzi...@googlegroups.com
Yep, if it works for your sketch, just use analogRead().  The Mozzi version prevents audio processing being blocked while waiting for analogRead() to finish, but if you don't have any gitches on Teensy3.x, there's no reason not to use the standard analogRead().

Tim

Ben Sanders

unread,
Feb 26, 2016, 11:18:28 AM2/26/16
to Mozzi-users
Ok, great!  I'll try some combinations and see how it works out.

Thanks for your help (and your awesome library!)

livestocki...@gmail.com

unread,
Jul 17, 2016, 10:13:17 AM7/17/16
to Mozzi-users
In case anyone is still wondering for a fix, I had this same problem and fixed it by downloading the new ADC library from github: https://github.com/pedvide/ADC

Hopefully this helps!

Reply all
Reply to author
Forward
0 new messages