Sad to say, am I going to get in trouble with a two channel 200 ppr code wheel rotary encoder. At the beginning everything works fine for me. But increasing the rotation speed the GC seems to be too slow for freeing memory.
I made a little sample program with these two functions (phase A and B with both edges):
private static int _steps = 0; private void OnInputPhaseAInterrupt(uint data1, uint data2, DateTime time) { _steps++; } private void OnInputPhaseBInterrupt(uint data1, uint data2, DateTime time) { _steps++; }
Turning the wheel slowly (about one rotation per second) works. Doubling the speed and the runtime will crash after about five rotations.
I changed the trigger to edge high to decrease the interrupts with the same effect. All tests are handmade, so I can't give you an accurate border.
With the .NET MF and SDK 4.1 I got an OuOfMemoryException. Upgrading to .NET MF and SDK 4.2 it changed to Failed allocation for 5 blocks, 60 bytes message.
With two interrupts on both edges we get 800 (2 x 400) interrupts per second. So we talking about 800 Hz. Increasing the speed to five rotations per second we obtain 4 kHz.
Is this really to fast for the .NET MF on a 48 MHz ARM7? And what are the options? Going back to c-compiled code and JTAG debugger?
Catastrophe!
Hope for a helping hand.
Best regards,
Frank