People who code: we want your input. Take the Survey
8

The processor has to execute something. You will always have an "endless" loop even if you're doing some work in an interrupt handler. The best solution depends on exactly what you're trying to do. The main advantage of using interrupts is they allow you to service events in real-time while your main program is doing something else. Timer interrupts ...


4

I would just like to add few points to other posts. My personal opinion is that endless while loop has no sense in systems which read from snsors or write to actuators as both has some physical constrains, eg. There is no point in reading from sensors at 1Mhz if the sensor has stability cycle before meassurent is accurate at 100Hz. Same goes to motor drivers....


4

Further to Guy's answer, using a timer interrupt to generate accurate intervals adds determinacy. For example, at any given time, you know exactly what the processor is doing, and all activities are performed at specified rates. You also should schedule at determined rates as otherwise you have no basis for time constants and such like, which will be ...


3

I'd also like to stress that the comparison between polling (i.e. checking if a interrupt flag has been set) and interrupt vectors (i.e. an ISR, or function that's loaded when a interrupt has occurred) should be more than just evaluating the efficiency/simplicity of executing a block of reactionary code. The interrupt controllers of most modern micros are ...


2

When I'm processing quadrature encoder input in an ISR, I prefer to have a simple ISR running on a timer that's guaranteed to run fast enough to catch every state (not state change) of the encoder. Interrupting on every pin transition invites a situation where the processor gets bogged down if a pin starts bouncing. Interrupting at a fixed rate may use up ...


2

Interrupt service routines should always do the absolute minimum. Remember that while your MCU is servicing an interrupt, it is doing nothing else. For a simple quadrature encoder, it should be possible to have a pair of ISR's, one triggered by a change on the A channel, the other triggered by a change on the B channel. Pretty much the only thing these ...


2

Some very general advice. My first impression from your question is that you are struggling with the fact that no hardware provides infinite resources. You can either slow down your control loops or look for better hardware (which may not exist). If your control has nested loops, then run each one a slow as possible. Are you controlling position at 20kHz? ...


2

I'm using the L3GD20H MEMS gyroscope with an Arduino ... How is the sensor's interrupt line intended to be used if the microcontroller can't handle the interrupt from an ISR using an interrupt-driven I2C subsystem? I'm assuming you've already looked at the L3GD20H datasheet and the L3GD20H errata sheet, and you understand that the data-ready pin (DRDY)...


2

I think you have a false assumption somewhere. A very quick scan through the atmel datasheet and arduino twi.c does not show any problems. Why do you think the microcontroller can't handle the interrupt from an ISR using an interrupt-driven I2C subsystem?


2

While this question may seem to be better suited for SE Arduino, I shall, nevertheless, propose a solution. Employ a ready written Arduino library, as this would save a lot of groundwork. Granted, as you mention that you have a main(), then one can assume that you are not using the Arduino IDE. However, the library (with the .cpp file and .h file) can still ...


1

No. The actual time is calculated from counter registers that automatically increment. The timer interrupt will be delayed, and things the timer interrupt is triggering will be delayed. This is called jitter. But the measurement of the interval will not change in accuracy. Counters roll over to zero automatically at the hardware level. So there are never ...


1

This kind of control situation in general Nyquist method is used, In your first if your sampling period is 4 ms, your sampling frequency is 250 Hz, so you can control event maximum 125 Hz or another saying 8 ms of sampling period. But it is only for starting, if your sensor values very volatile you would make your period much longer. But ...


1

Your signal actual going back and forth like that; it's registering with the microcontroller because you're at an intermediate voltage. As @TobiasK mentions, this is called "bouncing". You're trying to use this for controlling tires, so I would suggest you do a little math to determine whether or not a "subsequent" signal could be considered valid or not. ...


1

Old post, still answering for other people's reference. I am working on a similar project. Even to me a friend had suggested to use timer. Finally my suggestion would be to use as high speed controller as possible (mine is 80MHz). Use 5us Timer Interrupt (Scheduler). Do the following in this Scheduler Interrupt Routine: CheckSensors() ClockActuators() (...


1

Yes you would: no current [Arduino] on the market (that I know of) can effectively track the state changes without missing a few state changes. (Maybe the Due would be better or another board with a higher clock rate.) Interrupts can help a little, but: I believe it stops everything else on the chip; the motors might stop slightly when the interrupt is ...


Only top voted, non community-wiki answers of a minimum length are eligible