Comments (4)
I don't have a teensy, myself, so my answer is guesswork to a degree. But looking at the code, mozzi uses only ADC_0, and as far as I am aware, not all analog pins are accessible by both ADC units. Likely, this is what you are running into.
Fortunately, it seems rather straight-forward to set up non-synchronous ADC on teensy (and the ADC library is already required; https://github.com/pedvide/ADC). You should be able to use ADC_1, freely.
from mozzi.
from mozzi.
Thank you both for your help!
I looked through the analog.c and mozzi_analog.h channel mappings and quite frankly didn't understand too much at first. After realizing that the code differentiates the channel mapping based on the chip the Teensy is using, for instance
#elif defined(__MK64FX512__) || defined(__MK66FX1M0__)
for the Teensy 3.6, I tried copying this whole chunk of code into the mozzi_analog.h file, which didn't work. As suggested by tfry-git, I looked into the ADC library and found this pin scheme:
https://forum.pjrc.com/attachment.php?attachmentid=11811&d=1508341808
which shows that the "problematic" pins are in fact connected to ADC1.
So by using the ADC Library
#include <ADC.h>
Creating an object of it
ADC *adc1 = new ADC();
And using the corresponding reading function
adc1->analogRead(pin)
instead of mozziAnalogRead(pin)
the program works.
I am unsure, if this method of reading has disadvantages over the mozziAnalogRead(), since it says in the doc:
"mozziAnalogRead() reads the analog input of a chosen channel, without blocking other operations from running."
However I am calling the ADC reading in updateControl() at 64 Hz without problems so far.
So the issue is resolved and I can keep building the synth of my dreams.
Thank you very much again!
from mozzi.
adc->analogRead() waits for the conversion to complete before returning. I don't know how long that takes on teensy (by default). On the classic AVRs, it simply introduces too long delays. It might be quite ok on teensy, but if you're experiencing buffer underruns, that will be one of the first things to look into.
Alternatively, you can use non-blocking API:
adc->startSingleRead(..., ADC_1);
[...]
if (adc->isComplete(ADC_1)) {
x = adc->readSingle(ADC_1);
} else {
// keep using the previous value of x until the next iteration
}
It may be a bit cumbersome when reading multiple pins, but it should cause virtually no overhead.
from mozzi.
Related Issues (20)
- RFC: Mozzi 2.0 part 3 - Miscellanious
- UNO R4 port broken HOT 2
- Compatability/Compilation Issues w/ Nano 33 BLE Sense HOT 5
- Apparent frequency drops when amplitude increased beyond 8 bits on AVR HOT 3
- mozzi_rand cannot go full range HOT 7
- AVR PWM range is not actually 0-488 ("8.5 bit"), but effectively 0-400 HOT 6
- Minor / infrastructure: Avoid duplicate workflow runs on pushes to PRs HOT 1
- I2S dac with a nano. HOT 12
- VS10XX as DAC HOT 38
- RFC: Analog input scaling - what's the best approach HOT 3
- Allow to disable twi_nonblock HOT 5
- Review uses of "int", and "long" data types.
- Optimization of `Oscil::phMod()`
- GP0 io issues on RP2040 HOT 7
- Force PWM mode for power supply on GPIO, or suggest it in documentation
- I2S dacs config in Mozzi2 HOT 9
- A question, not an issue per se: lgt8f328p HOT 2
- RP2040 is out of tune HOT 5
- URL to webpage in _About_ section is wrong HOT 2
- Port for PY32f002 - PY32F003 -PY32F030? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mozzi.