Wow hackscribble that is very impressive. I may look into this as the chips are incredibly cheap! Thanks for letting me know.
I have another idea. Or really it's the first idea but slightly different. I am thinking if I set up two byte arrays(64 items in size or 32 integers) I can do the analogread(~120 usec) in my digital pin interrupt with some fast bit shuffling and boolean logic. Should be able to fill an array in about 22ms.
Now what I need is some sort of timer interrupt running at 100Hz(every 10ms) to send the filled buffer over the serial without inteferance? Is this possible? I've theoretically calculated how long it should take to send the array and it should be around ~5ms assuming I miss the 1ms USB poll time that's 4ms of cushion time to account for other things happening. Should also mention that while these measurements are occurring the program is doing effectively nothing else except testing a conditional statement.
Is this too 'heavy' for an attached interrupt?
//Interrupt code to handle the initialization
void rotorPulsedInit() {
if (PINB & 0b00000001) { //if(digitalRead(PinB)==HIGH)
intensity = analogRead(photoDiode);//Approx 120usecif(!bufferTwo){
//Turn integer into two bits
bufferOne[fillIndex] = intensity & 0xFF;
fillIndex++;
bufferOne[fillIndex] = (intensity >> 8) & 0xFF;
fillIndex++;
if(fillIndex == 63) {//If we have filled the buffer start to fill the next one
indexTwo = true;
fillIndex = 0;
}
} else {
bufferTwo[fillIndex] = intensity & 0xFF;
fillIndex++;
bufferTwo[fillIndex] = (intensity >> 8) & 0xFF;
fillIndex++;
if(fillIndex == 63) {//If we have filled the buffer start to fill the first one
indexTwo = false;
fillIndex = 0;
}
}
pulseCount++;
}
}
Not sure how exactly to go about setting up a timed 100Hz interrupt? Maybe google will help.