wiki:ArduinoMega

Version 5 (modified by sgk, 15 years ago) ( diff )

--

翻訳します。

Arduino Mega

概要

Arduino Megaは、Atmel社のATmega1280(データシート)を搭載したマイクロコントローラ・ボードです。 デジタルI/Oピン54本(このうち14本はPWM出力が可能)、アナログ入力16本、UART(シリアルポート)4組、16MHzの水晶発振子、USB接続(デバイス側)、電源コネクタ、ICSPヘッダ(ISPコネクタ)、リセットボタンを持っています。 マイクロコントローラを動かすのに必要な物を全て備えています。 単純にUSBケーブルでパソコンに接続するか、ACアダプタまたは電池を接続すれば動きます。 Arduino Megaでは、Arduino DuemilanoveまたはDiecimila向けに設計されたほとんどのシールドがそのまま使えます。

回路図およびリファレンス設計

EAGLEファイル:近日掲載

回路図:arduino-mega-schematic.pdf

仕様

マイクロコントローラ ATmega1280
動作電圧 5V
入力電圧(推奨) 7~12V
入力電圧(定格) 6~20V
デジタルI/Oピン 54本(うち14本はPWM出力も可能)
アナログ入力ピン 16本
デジタル出力の負荷電流 最大40mA
3.3Vピン(3V3)の負荷電流 最大50mA
フラッシュメモリ 128KB(うち4KBはブートローだで使用)
スタティックRAM 8KB
EEPROM 4KB
クロック速度 16 MHz

電源供給

電源の供給は、USBバスパワーまたは外部電源から行います。これらの供給源は、自動的に選択されます。

外部電源(USBでは無い場合)は、いわゆるACアダプタまたは電池です。ACアダプタは、中心電極の太さが2.1mmで中心電極がプラス(センター・プラス)のプラグを、ボードの左端の電源ジャックに差し込みます。電池を使用する場合は、下の段の左のピンヘッダの「Gnd」および「Vin」の場所に電池からの配線を差し込みます。

外部電源の電圧の定格は6~20ボルトです。しかし、7ボルト以下の場合には、内部の5V電源が5Vに満たないことがあり、動作が不安定になる可能性があります。また、12ボルト以上の場合には、ボードに搭載する電源レギュレータが過熱しボードが破損する可能性があります。したがって、外部電源の推奨範囲は7~12ボルトです。

電源関係のピンは以下のとおりです。

Vin

(USBコネクタやその他の安定化電源からの5Vではない)外部電源の入力です。 外部電源は、このピンに供給してください。 また、電源ジャックから供給している場合は、供給されているそのままの電圧がここに出力されています。

5V

ボード上のマイクロコントローラやその他の部品に供給されている安定化された5V電源の導線です。 この導線の電圧は、電源ジャックまたはVinからの電圧をボード上の電源レギュレータによって安定化したもの、またはUSBコネクタからの5V電圧です。 また、外部の安定化電源からの5V電圧を、このピンに供給することもできます。 電源ジャック、Vin、5Vピンから供給された電圧がUSBコネクタに逆流することはありません。

3V3

ボード上のFTDIチップが生成した3.3V電源です。このピンの最大負荷は50mAです。

GND

グラウンドです。

メモリ

ATmega1280には、プログラムコードの格納用として128KBのフラッシュメモリがあります(このうち4KBはブートローダ用に使用されています)。 さらに、8KBのスタティックRAM、4KBのEEPROMがあります。 EEPROMは、EEPROMライブラリを用いてプログラム中から読み書きすることができます。

入出力

54本あるデジタルI/Oピンは、入力または出力に切り替えて使用することができます。 切り替えにはpinMode()関数、出力にはdigitalWrite()関数、入力にはdigitalRead()関数を使用します。 入出力の動作電圧は5Vです。 出力として使用する場合の最大負荷は40mAです。 入力として使用する場合、20~50KΩのプルアップ抵抗が接続されます。 一部のピンには、特有の役割があります。

シリアル:0番(RX)1番(TX)、シリアル1:19番(RX)18番(TX)、シリアル2:17番(RX)16番(TX)、シリアル3:15番(RX)14番(TX)

シリアル通信の送受信(RX=受信、TX=送信)に使います。 0番および1番のピンは、FTDI USB~TTLレベルシリアル通信変換チップの対応するピンにも接続されています。

外部割り込み:2番(割り込み0)、3番(割り込み1)、18番(割り込み5)、19番(割り込み4)、20番(割り込み3)、21番(割り込み2)

設定により、これらのピンの値LOW、LOW→HIGHのエッジ、HIGH→LOWのエッジ、いずれかの方向の値の変化によって割り込みをかけることができます。 詳細についてはattachInterrupt()関数のページを参照してください。

PWM:0番~13番

analogWrite()関数により、8ビットのPWMでアナログ電圧を出力することができます。

SPI:50番(MISO)、51番(MOSI)、52番(SCK)、53番(SS)

SPIによる通信に使用することができます。 SPIはハードウェア的にはサポートされていますが、現時点ではArduino言語ではサポートしていません。 SPIのピンは、ICSPヘッダー(ISPヘッダー)にも接続されています。これらは、DuemilanoveやDiecimilaと同じ配列です。

LED:13番

13番ピンは、ボード上に搭載したLEDにも接続されています。 値がHIGHの時に点灯し、LOWの時に消灯します。

I2C:20番(SDA)、21番(SCL)

「Wire」ライブラリ(解説はWiringのウェブサイトにあります)を使用すると、I2C(TWI)による通信を行うことができます。 これらの配置は、DuemilanoveやDiecimilaと異なります。

アナログ入力は16本あり、それぞれ分解能は10ビットです(つまり、1024段階の値を取ることができます)。 デフォルトでは0~5Vの範囲を計測しますが、AREFピンに電圧を与え、analogReference()関数で設定することにより、範囲の上限を変更することができます。

この他、ボード上には以下のピンがあります。

AREFピン

アナログ入力ピンで入力を行う際の参照電圧を印加します。 このピンに印加された電圧を参照電圧として使用するかどうかは、analogReference()で設定します。

Reset(リセット)ピン

このピンへの入力電圧をLOWにすると、搭載しているマイクロコントローラをリセットすることができます。 シールドを搭載するとDuemilanove上のリセットボタンを覆い隠してしまうため、このピンを使ってシールド上にリセットボタンを装備するのが普通です。

通信

The Arduino Mega has a number of facilities for communicating with a computer, another Arduino, or other microcontrollers. The ATmega1280 provides four hardware UARTs for TTL (5V) serial communication. An FTDI FT232RL on the board channels one of these over USB and the FTDI drivers (included with the Arduino software) provide a virtual com port to software on the computer. The Arduino software includes a serial monitor which allows simple textual data to be sent to and from the Arduino board. The RX and TX LEDs on the board will flash when data is being transmitted via the FTDI chip and USB connection to the computer (but not for serial communication on pins 0 and 1).

A SoftwareSerial library allows for serial communication on any of the Mega's digital pins.

The ATmega1280 also supports I2C (TWI) and SPI communication. The Arduino software includes a Wire library to simplify use of the I2C bus; see the documentation on the Wiring website for details. To use the SPI communication, please see the ATmega1280 datasheet.

Programming

The Arduino Mega can be programmed with the Arduino software (download). For details, see the reference and tutorials.

The ATmega1280 on the Arduino Mega comes preburned with a bootloader that allows you to upload new code to it without the use of an external hardware programmer. It communicates using the original STK500 protocol (reference, C header files).

You can also bypass the bootloader and program the microcontroller through the ICSP (In-Circuit Serial Programming) header; see these instructions for details.

Automatic (Software) Reset

Rather then requiring a physical press of the reset button before an upload, the Arduino Mega is designed in a way that allows it to be reset by software running on a connected computer. One of the hardware flow control lines (DTR) of the FT232RL is connected to the reset line of the ATmega1280 via a 100 nanofarad capacitor. When this line is asserted (taken low), the reset line drops long enough to reset the chip. The Arduino software uses this capability to allow you to upload code by simply pressing the upload button in the Arduino environment. This means that the bootloader can have a shorter timeout, as the lowering of DTR can be well-coordinated with the start of the upload.

This setup has other implications. When the Mega is connected to either a computer running Mac OS X or Linux, it resets each time a connection is made to it from software (via USB). For the following half-second or so, the bootloader is running on the Mega. While it is programmed to ignore malformed data (i.e. anything besides an upload of new code), it will intercept the first few bytes of data sent to the board after a connection is opened. If a sketch running on the board receives one-time configuration or other data when it first starts, make sure that the software with which it communicates waits a second after opening the connection and before sending this data.

The Mega contains a trace that can be cut to disable the auto-reset. The pads on either side of the trace can be soldered together to re-enable it. It's labeled "RESET-EN". You may also be able to disable the auto-reset by connecting a 110 ohm resistor from 5V to the reset line; see this forum thread for details.

USB Overcurrent Protection

The Arduino Mega has a resettable polyfuse that protects your computer's USB ports from shorts and overcurrent. Although most computers provide their own internal protection, the fuse provides an extra layer of protection. If more than 500 mA is applied to the USB port, the fuse will automatically break the connection until the short or overload is removed.

Physical Characteristics and Shield Compatibility

The maximum length and width of the Mega PCB are 4 and 2.1 inches respectively, with the USB connector and power jack extending beyond the former dimension. Three screw holes allow the board to be attached to a surface or case. Note that the distance between digital pins 7 and 8 is 160 mil (0.16"), not an even multiple of the 100 mil spacing of the other pins.

The Mega is designed to be compatible with most shields designed for the Diecimila or Duemilanove. Digital pins 0 to 13 (and the adjacent AREF and GND pins), analog inputs 0 to 5, the power header, and ICSP header are all in equivalent locations. Further the main UART (serial port) is located on the same pins (0 and 1), as are external interrupts 0 and 1 (pins 2 and 3 respectively). SPI is available through the ICSP header on both the Mega and Duemilanove / Diecimila. Please note that I2C is not located on the same pins on the Mega (20 and 21) as the Duemilanove / Diecimila (analog inputs 4 and 5).

Photo of the Arduino Mega by SpikenzieLabs.

Note: See TracWiki for help on using the wiki.