1

I am thinking over an autonomous rover.

One of the features/components of the rover will be ability to know how fast is the rover moving and what distance did it travel. I would like to use dedicated attiny85 chip for that. The chip will use rotary encoder and interrupts to detect motion. It will be connected throught I2C/SPI (do not know yet) with the main controller. Main controller will ask the attiny85 on speed and distance if needed.

The problem is, I guess, that rotary encoder will use interrupts and so the I2C or SPI may not work properly. I could disable interrupts while communicating but:

  1. Motion sensing won't be precise, as I will loose some motion data.
  2. When attiny85 will be on receiving side, it wont know soon enough that it should disable the interrupts.
  3. There is a chance that SPI/I2C uses the interrupts as well, not sure, have to check.

Am I right? What would you advise?

5
  • 2
    If your interrupts are brief enough I can't see them being a problem. 90% of the SPI or I2C communication is done in hardware anyway and won't be affected by the interrupts - it's only between each byte that you will be doing anything, and that may be done in interrupts (depending on your implementation) anyway which will mean other interrupts are disabled at the time.
    – Majenko
    May 15 '17 at 10:46
  • @Majenko Thanks a lot. So this concept is worth trying you say. I will try it and then post the experience.
    – Divisadero
    May 15 '17 at 10:56
  • Certainly worth trying.
    – Majenko
    May 15 '17 at 10:59
  • @Divisadero how did it work? I'm thinking about using the software serial library with I2C, and I would like to know if interrupts cause problems for I2C communication.
    – David
    Nov 12 '18 at 18:38
  • 1
    @daweim0 I was/am too busy, didnt get to that. I played a bit with I2C and interrupts and it dependes on the I2C speed. If you do not need high bitrate, you will be fine. But be sure to use hardware I2C for sure.
    – Divisadero
    Nov 13 '18 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.