View Single Post
Old 09-05-2013, 02:08 PM   #43 (permalink)
nickdigger
EcoModding Apprentice
 
Join Date: Aug 2009
Location: terra firma
Posts: 138
Thanks: 4
Thanked 24 Times in 22 Posts
re: resistor tolerances

Ideally, the difference between button resistances will be great enough to account for that. The pseudo-code in my head does not translate a precise microvolt reading to a particular button sequence, rather, a "range" will be tested:
if (level < LeftOnly) buttonState= LeftButtonBit;
else if (level < LeftMiddle) buttonState = LeftButtonBit | MiddleButtonBit;
else if et cetera . . .
else buttonState = buttonsUp;

The voltage levels would be stored in a PROGMEM array. After the VoltageLevel-to-ButtonBit conversion has happened, the rest of the button code should work as is. Eh, except for using the PINC interrupt as a trigger. We would simply read the voltage level at every timer2-overflow ISR, to detect a level change. I guess that would nullify your Sleep Mode thing, unless it's possible to use the Analog Comparator as a trigger. This is new to me.

This should probably be set as a compile-time option in the code, as 90%+ mpguino owners will not want to rewire their units. Too bad this wasn't suggested and implemented from the beginning. Understandably, analog inputs and other hardware expansion were not on anyone's mind, when getting the basic Injector-Capture system working was a huge achievement in itself.
  Reply With Quote