Black Lives Matter - Action and Equality. ... Adafruit joins the Stop Hate for Profit campaign.
0

AFMotor library for ATmega644P
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

AFMotor library for ATmega644P

by chrille on Wed Apr 29, 2009 3:05 pm

I'm working on a robotic project, where I want more I/O's than the ATmega168/328 can provide, so I bought a couple of ATmega644P's. I already have a motor shield and it works great. I want to add support for the 'mega644P. I opened the AFMotor.h file and I figured out how to change the output pins for the 74HC595N. I decided to connect the LATCH, CLK, ENABLE and SERIAL pins of the '595N to PB0, PB1, PB2 and PB5 respectively. The problem, I'm facing now is that the PWM pins on the ATmega644P aren't located on the same pins as the ATmega168/328, and I just can't figure out how to change the library for using say PWM pins PB3 and PB4 of the '644P.

ATmega644P pin mapping shown below


ATMega644P
Code: Select all | TOGGLE FULL SIZE
                   +---\/---+
  INT0 (D 0) PB0  1|        |40  PA0 (AI 0 / D31)
  INT1 (D 1) PB1  2|        |39  PA1 (AI 1 / D30)
  INT2 (D 2) PB2  3|        |38  PA2 (AI 2 / D29)
   PWM (D 3) PB3  4|        |37  PA3 (AI 3 / D28)
   PWM (D 4) PB4  5|        |36  PA4 (AI 4 / D27)
  MOSI (D 5) PB5  6|        |35  PA5 (AI 5 / D26)
  MISO (D 6) PB6  7|        |34  PA6 (AI 6 / D25)
   SCK (D 7) PB7  8|        |33  PA7 (AI 7 / D24)
             RST  9|        |32  AREF
             VCC 10|        |31  GND
             GND 11|        |30  AVCC
           XTAL2 12|        |29  PC7 (D 23)
           XTAL1 13|        |28  PC6 (D 22)
  RX0 (D 8)  PD0 14|        |27  PC5 (D 21) TDI
  TX0 (D 9)  PD1 15|        |26  PC4 (D 20) TDO
  RX1 (D 10) PD2 16|        |25  PC3 (D 19) TMS
  TX1 (D 11) PD3 17|        |24  PC2 (D 18) TCK
  PWM (D 12) PD4 18|        |23  PC1 (D 17) SDA
  PWM (D 13) PD5 19|        |22  PC0 (D 16) SCL
  PWM (D 14) PD6 20|        |21  PD7 (D 15) PWM
                   +--------+


Help is greatly appreciated.
if (tired = true) {
gotoSleep;
} else {
replytoThisThread;
}
chrille
 
Posts: 62
Joined: Sun Oct 26, 2008 10:40 am
Location: Copenhagen, Denmark

Re: AFMotor library for ATmega644P

by adafruit on Wed Apr 29, 2009 5:27 pm

you will definately need to spend some time with the '644 and '168 datasheets

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: AFMotor library for ATmega644P

by franklin97355 on Wed Apr 29, 2009 7:10 pm

You might get some ideas at http://sanguino.cc

franklin97355
 
Posts: 21498
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: AFMotor library for ATmega644P

by chrille on Thu Apr 30, 2009 7:21 am

I have visited the Sanguino website and I have got the 74HC595N working with the ATmega644P and I know which of the pins on the '644P supports PWM. The only thing I need to know is how you change the PWM pins in the AFMotor library.
if (tired = true) {
gotoSleep;
} else {
replytoThisThread;
}
chrille
 
Posts: 62
Joined: Sun Oct 26, 2008 10:40 am
Location: Copenhagen, Denmark

Re: AFMotor library for ATmega644P

by mtbf0 on Thu Apr 30, 2009 7:50 am

chrille wrote:I have visited the Sanguino website and I have got the 74HC595N working with the ATmega644P and I know which of the pins on the '644P supports PWM. The only thing I need to know is how you change the PWM pins in the AFMotor library.


it will probably be a little more complicated than that. there will likely be slight differences in register names, bit names and bit locations for controlling the timers between the '644 and the 'x8 avrs. that's why ladyada suggested spending some time with the data sheets.
"i want to lead a dissipate existence, play scratchy records and enjoy my decline" - iggy pop, i need more
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

Re: AFMotor library for ATmega644P

by chrille on Fri May 01, 2009 8:51 am

I think I'll find another method for driving my motors. Thanks.
if (tired = true) {
gotoSleep;
} else {
replytoThisThread;
}
chrille
 
Posts: 62
Joined: Sun Oct 26, 2008 10:40 am
Location: Copenhagen, Denmark

Please be positive and constructive with your questions and comments.