Arduino Compatible R3 Mega - Funduino Brand (HCARDU0036)

Post Reply
admin
Site Admin
Posts: 866
Joined: Sun Aug 05, 2012 4:02 pm

Arduino Compatible R3 Mega - Funduino Brand (HCARDU0036)

Post by admin » Wed Apr 10, 2013 1:30 pm

Image

The Arduino Mega 2560 is a microcontroller board based on the ATmega2560. It has 54 digital input/output pins (of which 14 can be used as PWM outputs), 16 analogue inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with an AC-to-DC adapter or battery to get started. The Mega is compatible with most shields designed for the Arduino Duemilanove or Diecimila. The Mega 2560 is an update to the Arduino Mega, which it replaces.

Revision 3 of the board has the following new features:

-- 1.0 pinout: added SDA and SCL pins that are near to the AREF pin and two other new pins placed near the RESET pin, the IOREF that allows the shields to adapt to the voltage provided from the board. In future, shields will be compatible both with the board that uses the AVR, which operates with 5V and with the Arduino Due that operates with 3.3V. The second one is not a connected pin, that is reserved for future purposes.
-- Stronger RESET circuit.
-- Atmega 16U2 replace the 8U2.

Specifications
Microcontroller: ATmega2560
Operating Voltage: 5V
Input Voltage (recommended): 7-12V
Input Voltage (limits): 6-20V
Digital I/O Pins: 54 (of which 15 provide PWM output)
Analogue Input Pins: 16
DC Current per I/O Pin: 40 mA
DC Current for 3.3V Pin: 50 mA
Flash Memory: 256 KB of which 8 KB used by bootloader
SRAM: 8 KB
EEPROM: 4 KB
Clock Speed: 16MHz

Pinout
Image

ChrisJ
Posts: 7
Joined: Mon Dec 30, 2013 11:34 am

Re: Arduino - Mega (HCARDU0036)

Post by ChrisJ » Mon Feb 03, 2014 2:26 pm

Hi Andrew

I have tried using one of you Adafruit Motor Shields one of my Mega 2560 and motors 3 & 4 are not driven, they work fine on Uno boards.

After some time researching I think the problem is in the AFMotor h file. Motors 1 & 2 are defined for the 2560 board, but not in the motors 3 & 4 definitions.

#define MICROSTEPS 16 // 8 or 16

#if defined(__AVR_ATmega8__) || \
defined(__AVR_ATmega48__) || \
defined(__AVR_ATmega88__) || \
defined(__AVR_ATmega168__) || \
defined(__AVR_ATmega328P__)
#define MOTOR12_64KHZ _BV(CS20) // no prescale
#define MOTOR12_8KHZ _BV(CS21) // divide by 8
#define MOTOR12_2KHZ _BV(CS21) | _BV(CS20) // divide by 32
#define MOTOR12_1KHZ _BV(CS22) // divide by 64

#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define MOTOR12_64KHZ _BV(CS10) // no prescale
#define MOTOR12_8KHZ _BV(CS11) // divide by 8
#define MOTOR12_2KHZ _BV(CS11) | _BV(CS20) // divide by 32
#define MOTOR12_1KHZ _BV(CS12) // divide by 64[/color][/b][/color][/size][/b]

#elif defined(__AVR_ATmega32U4__) // Leonardo (mem 22 Nov 2012)
#define MOTOR12_64KHZ _BV(CS00) // no prescale
#define MOTOR12_8KHZ _BV(CS01) // divide by 8
#define MOTOR12_2KHZ _BV(CS01) | _BV(CS20) // divide by 32
#define MOTOR12_1KHZ _BV(CS02) // divide by 64
#endif

#if defined(__AVR_ATmega8__) || \
defined(__AVR_ATmega48__) || \
defined(__AVR_ATmega88__) || \
defined(__AVR_ATmega168__) || \
defined(__AVR_ATmega328P__)
#define MOTOR34_64KHZ _BV(CS00) // no prescale
#define MOTOR34_8KHZ _BV(CS01) // divide by 8
#define MOTOR34_1KHZ _BV(CS01) | _BV(CS00) // divide by 64
#else
#define MOTOR34_64KHZ _BV(CS40) // no prescale
#define MOTOR34_8KHZ _BV(CS41) // divide by 8
#define MOTOR34_1KHZ _BV(CS41) | _BV(CS40) // divide by 64
#endif

Can I just copy and paste these definitions into the h file and alter them for motors 3 & 4? If so what should the CS values be?

Chris

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Arduino - Mega (HCARDU0036)

Post by andrew » Mon Feb 03, 2014 5:44 pm

Strange that they would have omitted this although if the definitions where missing I'd expect it to throw up an error when it tried to compile the library for a Mega. I'll set one up with a Mega to see if I can figure out the problem and a fix. I'll also create a thread for the motor drive shield so we can move this conversation to it.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Arduino - Mega (HCARDU0036)

Post by andrew » Tue Feb 04, 2014 9:44 am

Ok, as I can't currently replicate the problem I can't confirm this will fix it but try changing this:

#if defined(__AVR_ATmega8__) || \
defined(__AVR_ATmega48__) || \
defined(__AVR_ATmega88__) || \
defined(__AVR_ATmega168__) || \
defined(__AVR_ATmega328P__)
#define MOTOR34_64KHZ _BV(CS00) // no prescale
#define MOTOR34_8KHZ _BV(CS01) // divide by 8
#define MOTOR34_1KHZ _BV(CS01) | _BV(CS00) // divide by 64
#else
#define MOTOR34_64KHZ _BV(CS40) // no prescale
#define MOTOR34_8KHZ _BV(CS41) // divide by 8
#define MOTOR34_1KHZ _BV(CS41) | _BV(CS40) // divide by 64
#endif


To this:

#if defined(__AVR_ATmega8__) || \
defined(__AVR_ATmega48__) || \
defined(__AVR_ATmega88__) || \
defined(__AVR_ATmega168__) || \
defined(__AVR_ATmega328P__) || \
defined(__AVR_ATmega2560__)
#define MOTOR34_64KHZ _BV(CS00) // no prescale
#define MOTOR34_8KHZ _BV(CS01) // divide by 8
#define MOTOR34_1KHZ _BV(CS01) | _BV(CS00) // divide by 64
#else
#define MOTOR34_64KHZ _BV(CS40) // no prescale
#define MOTOR34_8KHZ _BV(CS41) // divide by 8
#define MOTOR34_1KHZ _BV(CS41) | _BV(CS40) // divide by 64
#endif


It's a stab in the dark so may not work. If not I'll take a closer look at the adafruit code to see if there is any reason for this. Also have you tried the MotorTest example to debug it?
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Arduino - Mega (HCARDU0036)

Post by andrew » Tue Feb 04, 2014 12:37 pm

I've set one up on a bench with a Mega but it seems to work fine on M4. Did you remember to connect an external power supply to the EXT_PWR terminal?
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

ChrisJ
Posts: 7
Joined: Mon Dec 30, 2013 11:34 am

Re: Arduino - Mega (HCARDU0036)

Post by ChrisJ » Tue Feb 04, 2014 5:17 pm

Hi Andrew

Yes it has a 7.2V NiCd supply.

Chris

ChrisJ
Posts: 7
Joined: Mon Dec 30, 2013 11:34 am

Re: Arduino - Mega (HCARDU0036)

Post by ChrisJ » Thu Feb 06, 2014 10:56 am

Hi Andrew

I sorted it, without realising it I was using a variant of the Adafruit library downloaded from the book Michael Margolis's book "Make an Arduino Controlled Robot" and, for some reason, He took out the code for the Mega leaving 'bits' behind. I'll contact the publishers about the problem, Mega and Shield working fine on the Adafruit library. Sorry for the time you've wasted.

Chris

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Arduino - Mega (HCARDU0036)

Post by andrew » Fri Feb 07, 2014 8:58 am

Glad you managed to get it sorted. I'm going to move this conversation to the new thread I've created in the shields forum shortly.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Post Reply

Return to “Arduino Development Boards”