Go Down

Topic: Attiny85, I2C & Interrupts (Read 2042 times) previous topic - next topic

dlar

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


Coding Badly

Hi all,


Greetings.

Quote
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.

Quote
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.

dlar

Thanks for the response.

Quote
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.


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

Quote
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


dlar

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:

Quote
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

Code: [Select]
if (rpmcount >= 20)
to
Code: [Select]
if (rpmcount >= 333) {

PART TAKEN FROM THE PLAYGROUND:
Code: [Select]
  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.

Coding Badly

Quote
How do I edit the  code below?


Someone else will have to help with that question.

Go Up