I thought I'd jot down some notes on the architecture of the system I'm building. Mostly because I'm not exactly sure if the Arduino Micro can do everything I am planning, or even exactly sure what I'm planning! There are some limitations I'm finding now that I'm becoming more familiar with the capabilities of the Arduino, and hopefully putting these here as I find them will help me understand what's achievable. In particular, I'm concerned use of some features invalidate others.
IR Sensor
The IR sensor looks through timing holes (well, actually one at the moment) on the disc and triggers an interrupt when a hole is present. This trigger is on a falling edge of the IR voltage (which is 0-5V or thereabouts). The trigger voltage level is the 1.1V internal reference voltage of the ATmega32U4 chip.
The analog pin ADC7 (pin A0) is used in my current implementation as the comparator AIN1 value (i.e., the IR sensor).
This can be changed by setting bits MUX0..n in ADMUX.
From the manual pp.295 "It is possible to select any of the ADC13..0 pins to replace the negative input to the Analog Comparator. The ADC multiplexer is used to select this input, and consequently, the ADC must be switched off to utilize this feature. "
"AIN+ can be connected either to the AIN0 (PE6) pin, or to the internal Bandgap reference. AIN- can only be connected to the ADC multiplexer.
It looks like we can't use a comparator interrupt AND an ADC - and we need the ADC for the video input i'm really unclear on this - can't find any definitive answer by searching. Basically the above quotes say to me that the multiplexer is used to "replace" the negative input."AIN- can only be connected to the ADC multiplexer." (pp.293) So, with comparator in use we must use the ADC multiplexer and therefore we can't use the multiplexer for ADC, right?
" If ACME is cleared or ADEN is set, the Bandgap reference is applied to the negative input to the Analog Comparator."
Well, that's what we want! Can we have AIN0 as the *PIN* connected to the IR, and AIN1 connected to bandgap reference?
We would have to clear ACME and/or set ADEN.
ACME/ADEN/MUX2..0/Analog Comp Neg Input
0 x xxx Bandgap Ref.
1 1 xxx Bandgap Ref.
and I currenty have 1/0 which is "select ADC0 for neg input". Bzzt.
So I need ACME = 0 (do NOT enable multiplexer for comparator)
I need ADEN - 1 which is the ADC ENABLE.
Then I need to be able to select the AIN0 to be the pin for the IR.
pp. 293: " AIN+ can be connected either to the AIN0 (PE6) pin, or to the internal Bandgap reference. "
So, that's my only choice - connect AIN+ to PE6 pin, and AIN- to bandgap.
PE6 pin on Arduino is... mapped to digital pin 7
But anyway, in theory this frees up the ADC to do its stuff because we don't need/use the overloaded analog multiplexer to select AIN1.
So, that seems to clear that up. Will have to reconfigure and test in the next few days.