-
Notifications
You must be signed in to change notification settings - Fork 515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interrupts #63
Comments
Interrupts are currently used behind the scenes. In fact if you use StandardFirmata an Arduino Uno or similar board all of the interrupts are currently in use. PWM uses interrupts, Servo uses interrupts, millis() uses an interrupt, etc. This has been one of the larger problems when trying to scale Firmata. We're working on a new firmata example called ConfigurableFirmata (see the configurable branch and the new utility directory as well as the ConfigurableFirmata example). With ConfigurableFirmata you select features for a particular application rather than the general purpose StandardFirmata approach. This could free up a timer as long as conflicting features are not chosen. For example if you don't need a Servo, then you don't include the Servo class and that frees up a timer or if you don't need PWM you could free up multiple timers. Then we could add a RotaryEncoder feature class, but you'd need to sacrifice an existing feature in order to add a new feature that relies on interrupts so you couldn't use both a rotary encoder and a servo or a rotary encoder and pwm for example. For more capable boards such as the Due this may not be an issue as there may be additional timers available. |
Thanks a lot ! I will give a try to ConfigurableFirmata then. |
are you specifically interested in a rotary encoder feature or just interrupts in general. If you would like a rotary encoder feature class for configurable firmata that can be added as a feature issue and I'd be happy to accept a pull request, just be aware of this: "Inside the attached function, delay() won't work and the value returned by millis() will not increment. Serial data received while in the function may be lost. You should declare as volatile any variables that you modify within the attached function." So an interrupt handler needs to be extremely quick. I'm assuming the issue here is that millis shares the same timer that is allocated for attachInterrupt. The work around is to use another timer, but that would have to be done with avr-gcc syntax, instead of attachInterrupt (which abstracts away a ton of complexity) and would be processor dependent to some extent. |
In fact I'd like to use incremental rotary (or linear) optical encoders with my arduino MEGA, more informations here . Anyway I'll try to follow your advice. |
As discussed, I'm trying to implement a new feature to manage encoders (EncoderFeature) but I'm facing a problem I can't deal with : During sketch compilation, Arduino IDE returns the following error : IS_PIN_INTERRUPT and PIN_TO_INTERRUPT not defined in EncoderFeature.cpp (however these constants are defined in the Boards.h file and everything seems ok) I tried to include files using double quotes instead of brackets but nothing works have you ever had this problem? Note : If you want to reproduce the error, you can use nicolaspanel/Firmata(interrup branch)/test/unit/encoder_test/encoder_test.ino (or any other sketch) UPDATE (15/07/2013) : This implementation uses arduino external interrupts and my first tests are encouraging. Best regards |
It seems that current version does not handle interrupts (to manage encoders for example), is it planned in your roadmap?
The text was updated successfully, but these errors were encountered: