The Arduino Mega platform is great in that it provides a low cost, low barrier to entry platform for projects. Unfortunately, these conveniences come with some disadvantages.
Specifically, in an effort to make the programming process as painless as possible, most (possibly all) versions of the Arduino Mega 2560 board will reset themselves when a new serial connection is initiated. Needless to say, it's pretty inconvenient for the computer controlling your engine to reboot if you're driving the car and the serial connection to your logger becomes unstable and has to reconnect (hint: the engine stops).
This feature will enable you to prevent that from happening.
(TODO more details)
The Speeduino firmware provides three options for preventing the Arduino from resetting (* indicates a bootloader update is required):
This is as simple as running a wire from the control pin to the reset pin on your Arduino.
The custom 16u2 firmware differs from the stock one in that it uses one of the 16u2's GPIO pins to recognize when the board should / should not be allowed to reset. The pin used is PB7, as illustrated.
How you connect the control pin to PB7 is up to you, but if you are connecting from a pin on the Speeduino's proto area, you may wish to use right-angle pin headers on the Arduino to make separating the Speeduino shield from the Arduino MCU (also illustrated).
Using the "When the engine is running" and "Prevent Always" reset control modes requires updating the usb-serial firmware on your Arduino's ATmega16U2 chip (these modes are unavailable if your board uses something else to perform usb serial functionality, such as an FTDI or CH340 chip).
A hex file for the updated bootloader can be found in the following locations:
To perform the update, you will need a copy of dfu-programmer. Directions for installing dfu-programmer for Mac can be found here. It may also be possible to use Atmel's flip programmer but it has not been tested.
The procedure is as follows (directions are for Windows but are very similar for Linux and Mac):
Extract both dfu-programmer and the updated bootloader into the directory of your choice.
Plug your Arduino into a USB port and wait for the computer to recognize it.
Briefly short the 16U2's RESET and GND pins. This will cause the 16U2 to enter DFU mode.
If you are prompted by Windows to install a driver, do not let Windows install the driver automatically. Instead, browse to the .inf file that came with dfu-programmer.
Use the following commands to backup your existing usb-serial firmware and install the new one (prepend sudo on Mac and Linux):
The bootloader update is complete. You should now disconnect and reconnect the Arduino to your computer.
In Windows, your Arduino will now appear as a generic USB Serial Device in the Device Manager so you will likely need to reconfigure TunerStudio to use the new port. If you like, you can check the "Bus reported device description" property in the device's Details tab to verify that "Speeduino Mega 2560" is shown.
Performing a Speeduino firmware update using the Serial Command method is a multi-step process:
If you have reset control set to "When engine is running," there is no special procedure required to update your Speeduino firmware. As long as the engine is not running, the Arduino will behave just as any other and you can update it the same way you would any other time.
If you have reset control set to "Always," you will either need to temporarily disable it from inside TunerStudio in order to update your Speeduino firmware.