|
Re: How many interrupts is too many interrupts?
Put simply, the programming mentor on our team gets nervous if we try to use more than 2 encoders. I'm not sure of their settings however. For a bot that requires alot of interrupt-free calculations to smoothly operate, I'll take his advice.
Now for some technical/theoretical:
In college I took an embedded processors class. In one project we programmed our PIC (same line as the FRC bot) and tried to trash it with interrupts. The idea was to keep a TRIAC-driven lightbulb lit to at least 75% of its maximum intensity while using 2 rheostats to make interrupts to drive a calculated LED display. This was fun and it showed the practical balance between keeping the LEDs lit and the lightbulb lit. Practically, our conclusions were (from memory):
Maximum # of interrupts per second = ~20% * {[# of clock cycles per second - 6% overhead]/[# of binary instructions per interrupt]}.
Breaking it down, the # of binary instructions per interrupt we used averaged out to just over 200. Note that a single line of C-code can have a gigantic amount of binary (1-2 variables, one operand) instructions.
I got stuck with an 8-bit 8Mhz processor, and in our scenario I could do 1 interrupt roughly once every half-millisecond -- or 2000 per second -- and still keep both the lightbulb and LEDs lit. YMMV though.
__________________
Drive Coach, 1885 (2007-present)
CAD Library Updated 5/1/16 - 2016 Curie/Carver Industrial Design Winner
GitHub
|