Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

AFMotor.cpp with ATmega8
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

AFMotor.cpp with ATmega8

by Tex Funk on Mon May 12, 2008 9:30 pm

I'm trying to get the motor shield to work with an Arduino Extreme v2 and two DC motors. I believe I've narrowed my problems down to the IO registers that get initialized in the AF_DCMotor definition, but I haven't been able to determine the functional equivalents for those registers on the ATMega8 (keeping in mind I don't need the full functionality, so if I end up cutting the other functions out of the header and just having enough horsepower to run the two motors, that would be fine).

Going by the following compile errors I'm assuming these are the registers I need alternatives for:
AFMotor.cpp: In constructor 'AF_DCMotor::AF_DCMotor(uint8_t, uint8_t)':
AFMotor.cpp:60: error: 'TCCR2A' was not declared in this scope
AFMotor.cpp:60: error: 'COM2A1' was not declared in this scope
AFMotor.cpp:61: error: 'TCCR2B' was not declared in this scope
AFMotor.cpp:62: error: 'OCR2A' was not declared in this scope
AFMotor.cpp:70: error: 'COM2B1' was not declared in this scope
AFMotor.cpp:80: error: 'TCCR0A' was not declared in this scope
AFMotor.cpp:80: error: 'COM0B1' was not declared in this scope
AFMotor.cpp:80: error: 'WGM00' was not declared in this scope
AFMotor.cpp:80: error: 'WGM01' was not declared in this scope
AFMotor.cpp:81: error: 'TCCR0B' was not declared in this scope
AFMotor.cpp:82: error: 'OCR0B' was not declared in this scope
AFMotor.cpp:90: error: 'COM0A1' was not declared in this scope
AFMotor.cpp:92: error: 'OCR0A' was not declared in this scope
AFMotor.cpp: In member function 'void AF_DCMotor::setSpeed(uint8_t)':
AFMotor.cpp:135: error: 'OCR2A' was not declared in this scope
AFMotor.cpp:137: error: 'OCR2B' was not declared in this scope
AFMotor.cpp:139: error: 'OCR0B' was not declared in this scope
AFMotor.cpp:141: error: 'OCR0A' was not declared in this scope

Any thoughts? I found what look like timers in iom.h, but as far as the OCR and COM reg's I'm not sure which ones to use.
Tex Funk
 
Posts: 9
Joined: Mon May 12, 2008 9:22 pm

by mtbf0 on Mon May 12, 2008 10:11 pm

why not replace the mega8 on your board with a mega168. you can get one with the bootloader preprogrammed for $6 from adafruit.
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

by Tex Funk on Mon May 12, 2008 10:18 pm

That seems too easy somehow.

Thanks :P should look more closely at what's on offer; I could use the extra space anyhow.
Tex Funk
 
Posts: 9
Joined: Mon May 12, 2008 9:22 pm

by Tex Funk on Tue May 13, 2008 9:14 am

Well, I ordered the 168s, but now I'm curious: if I should, for some strange desperate reason, want to use the motor shield with an ATMega8, is it even possible to do it?
Tex Funk
 
Posts: 9
Joined: Mon May 12, 2008 9:22 pm

by adafruit on Tue May 13, 2008 10:17 am

you 'can' but a lot of the functionality would be lost, since the chip doesnt have as many PWM channels...ive yet to do it since the NG is being used less & less.

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

by Tex Funk on Tue May 13, 2008 10:30 am

Well this, again, is a little academic since you sold me some ATMega 168s last night, but is there any documentation that I could use to find equivalent registers for a couple of PWM channels on the 8? I can already tell I'm going to be really bored tonight and desperate to see my motors run forwards, then backwards, then forwards.
Tex Funk
 
Posts: 9
Joined: Mon May 12, 2008 9:22 pm

by adafruit on Tue May 13, 2008 3:51 pm

thats the thing, there arent any equivalent pwm registers. the 8 doesnt have them!

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

by Tex Funk on Tue May 13, 2008 4:36 pm

It doesn't have any, or it doesn't have as many? I only need to use two motor channels at a time, and I found what look like two timer channels on the 8 which seem like they could replace TCCR2A and 2B if I could figure out what registers to use in place of OCR2A. But maybe there's not even enough capacity to run two PWM motor channels?
Tex Funk
 
Posts: 9
Joined: Mon May 12, 2008 9:22 pm

Please be positive and constructive with your questions and comments.