I am looking to write code for a generic three phase encoder that you find in bldc scooter motors. I've got a setup where I can read the signals coming from the encoders, and I have written software for some test interrupts to count the 'ticks' as the signals are fired. Which is great. But now I want to generalized it into a class like the existing Encoder class in the teensy library. So, I have two questions:
1) Has someone already done this and I'm just duplicating effort?
2) Assuming it has not been done before, I was looking at the existing Encoder class code (which is for a quadrature encoder), and it has this complicated manner of referencing a struct pointer that is stored in an array where each element in the array is associated with each possible pin the interrupt can be attached to. And there is an interrupt method for each interrupt pin that essentially passes parameters into a common method. I think that all makes sense...but before I start to emulate it I just want to make sure there isn't something better out there that I should be considering. My code is going to be interrupt-only, so I think I can safely ignore the non-interrupt stuff. And like I said, I think I understand the basics of what the Encoder code is doing and I can replicate appropriately in my three phase code.
3) In an earlier discussion, someone had mentioned that the Teensy had some builtin functions for Encoders. When I looked at relevant code, it seemed to be quadrature encoder specific. Am I wrong and there is generic encoder support builtin to the Teensy?
thanks for any advice and pointers.
-Mark
1) Has someone already done this and I'm just duplicating effort?
2) Assuming it has not been done before, I was looking at the existing Encoder class code (which is for a quadrature encoder), and it has this complicated manner of referencing a struct pointer that is stored in an array where each element in the array is associated with each possible pin the interrupt can be attached to. And there is an interrupt method for each interrupt pin that essentially passes parameters into a common method. I think that all makes sense...but before I start to emulate it I just want to make sure there isn't something better out there that I should be considering. My code is going to be interrupt-only, so I think I can safely ignore the non-interrupt stuff. And like I said, I think I understand the basics of what the Encoder code is doing and I can replicate appropriately in my three phase code.
3) In an earlier discussion, someone had mentioned that the Teensy had some builtin functions for Encoders. When I looked at relevant code, it seemed to be quadrature encoder specific. Am I wrong and there is generic encoder support builtin to the Teensy?
thanks for any advice and pointers.
-Mark