Pages: [1]   Go Down
Author Topic: Attiny85, I2C & Interrupts  (Read 1836 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

 
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 198
Posts: 12755
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
if (rpmcount >= 20)
to
Code:
if (rpmcount >= 333) {

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

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 198
Posts: 12755
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How do I edit the  code below?

Someone else will have to help with that question.
Logged

Pages: [1]   Go Up
Jump to: