Attiny85, I2C & Interrupts

Hi all,

I have been thinking about making an I2C RPM module that will count the wheel rotations and send it back to the arduino.

I know on the Att85 the I2C & Interrupt pins are in fact the same pins.

How can I use the other pins on the Att85 as interrupts?

Also Will there be any issues with reading the speed of two encoders (Left & Right wheel) on the Att85?

Thanks in Advance

dlar:
Hi all,

Greetings.

How can I use the other pins on the Att85 as interrupts?

Use "pin change interrupts". There's a library here for the ATtiny85...
http://code.google.com/p/arduino-tiny/

But a library really isn't required. Enabling pin change interrupts is fairly easy.

Also Will there be any issues with reading the speed of two encoders (Left & Right wheel) on the Att85?

Tough to say. You have not indicated how fast the left and right wheels will be traveling.

Thanks for the response.

Use "pin change interrupts". There's a library here for the ATtiny85...
Google Code Archive - Long-term storage for Google Code Project Hosting.

But a library really isn't required. Enabling pin change interrupts is fairly easy.

do you have an example of pin change interrupts? i tried reading the data-sheet but it went over my head!!

Tough to say. You have not indicated how fast the left and right wheels will be traveling.

Motor rated voltage: 7.2V
Motor stall current: 2.5A
Output shaft stall torque: 10Kg/cm
Gearbox ratio: 86.8:1
Encoder type: Quadrature
Encoder resolution: 1000 state changes per 3 wheel rotations
Speed: 1Km/hr

The library look like it is the best way for me to get Pin Change interrupts working.

My next problem is figuring out how to do the calculations for the encoder:

Each gearbox has an optical quadrature encoder with a resolution of 1000 state changes per 3 revolutions of the output shaft (333.33 pulses per revolution).

How do I edit the code below?

Do I change

if (rpmcount >= 20)

to

if (rpmcount >= 333) {

PART TAKEN FROM THE PLAYGROUND:

  if (rpmcount >= 20) { 
    //Update RPM every 20 counts, increase this for better RPM resolution,
    //decrease for faster update
    rpm = 30*1000/(millis() - timeold)*rpmcount;
    timeold = millis();
    rpmcount = 0;
  }

Thanks in Advance.

How do I edit the code below?

Someone else will have to help with that question.