3Dot Troubleshooting & Bootloader Burning

3Dot Troubleshooting

Error Codes

When there is an error in a command sent to the Arduino/3DoT, a telemetry packet with an Exception Code will be returned. Below is a list of the possible Command Exception codes. Following that, an example showing how to read exception code telemetry is provided.

Command Exception Codes

The finite state machine for command processing and decoding will generate the exception or error codes listed below. These codes will be sent to the Arduino IDE “Serial Monitor” as well as telemetry to the ArxRobot App.

01           Start byte 0xA5 expected

02           Packet length out of range 1 – 20

03           LRC checksum error

04           Undefined command decoder FSM state

05           Array out of range i >= 23

Exception Code Example

In this example, the camera home command is sent with an incorrect LRC byte to examine how exception codes work.

A5 01 04 00

Command Packet ID        = A5

Packet Length N                = 01

Camera Home                   = 04

Parity                                    = 00       A0 = A5 ⊕ 01 ⊕ 04

The telemetry packet (CA…) in Figure 12.1 was sent as a response from the 3DoT board when the command packet (A5 01 04 00 above) was sent. Looking at the command packet (start byte = A5), the user has sent a CAMERA_MOVE_HOME (3rd byte = 04) command with the LRC byte as 00. By calculating the LRC byte by hand (A5 ⊕ 01 ⊕ 04) it is shown that the correct LRC byte is equal to A0.

The 3DoT firmware responds to this simulated data transmission error by sending telemetry packet CA 03 0E 03 A0 64 as shown in Figure 17-1.

Figure 17-1: Telemetry packet sent from Arduino/3Dot board.

data[i] i = 0 i = 1 i = 2 i = 3 i = 4 i = 5
Packet CA 03 0E 03 A0 64
Description Packet ID Packet Length N+1 Command Exception ID LRC Checksum Error Expected Checksum Packet Checksum

The “Telemetry ID” is 0E, which is sent indicating an error was detected when trying to decode the command. 03 indicates that LRC byte sent is incorrect. In this example, A0 is the expected LRC byte that is needed to be sent. Knowing this, if the user were to send the exact same command packet, but changing the LRC byte to A0 (A5 01 04 A0), the microcontroller will not reply with a telemetry packet again.

Going back to the telemetry packet  (start byte = CA), the last byte is now the LRC byte for the telemetry packet (CA ⊕   03 ⊕   0E ⊕   A0 = 64). Again, this component is used to verify that all elements were read accurately.

It is not important understanding how to find the LRC bytes for telemetry packets, as they are automatically calculated, but it is good to know the purpose of the LRC byte for data packets for both commands and telemetry and how it is computed by the software.

Bluetooth Troubleshooting

Connecting over Bluetooth can be finicky at times. If there are too many nearby sources try initially pairing to the 3Dot on your own (in isolation). If connecting still doesn’t work: first try restarting the 3Dot and rescanning Bluetooth within the app. If connecting proves to not work consistently try these steps:

  1. Turn off 3Dot
  2. Force Close Arxterra
  3. Turn off and on Bluetooth (in phone settings)
  4. Reopen Arxterra
  5. Then scan for devices within Arxterra

Burning Bootloader and Fuse Settings

A bootloader is the first piece of code a microcontroller executes when it is powered ON. Usually, manufacturers burn the appropriate bootloaders into microcontroller chips prior to selling them. For instance, this is how computers recognize the type of Arduino plugged into it. However, dealing with a fresh microprocessor chip, the bootloader will have to be burned onto it before it is capable of being programmed. This tutorial will walk through how set the appropriate fuse settings and burn the 3DoT Bootloader to the board.

Equipment

  • USBtiny AVR Programmer (Amazon.com)
  • 050” 2X3 Female Header with 6 Jumper Wires (3DoT ICSP pin socket)
  • 3DoT ICSP Breakout
  • 8MHz External Crystal Breakout (if chip supplied with fuse set to external clock)
  • 3DoT Board

*Note: The AVRISP programmer MKII or any other AVR programmer can be used as well.

Connecting the 3DoT Board

STEP 1: Connect the external crystal and ISP breakout board to the 3DoT board as shown.

STEP 2: Insert a battery and turn the board ON.

STEP 3: Connect the AVRISPmkII to your computer. If the internal LED turns green suitable drivers are detected. If not, see “Installing MKII Driver” below.

STEP 4: Connect the AVRISPmkII to the board. Ensure the VCC pin (red wire on the ribbon cable) matches up with the bottom right pin(closest to battery holder) on the board.

The external LED will light up green when the board is detected.

Installing MKII driver

If the AVR programmer is not recognized by your computer, the appropriate driver must first be installed. Download the proper driver for the AVR programmer from the web. If the AVRISP MKII driver is being used, it can be downloaded from this link. If the USBtiny AVR Programmer is being used, the driver can be downloaded from this link.

Next, solder jumper wires to the 2X3 female headers, and connect them to the ICSP pins on the 3DoT board. Then connect the female headers to the corresponding output pins from the programmer:

To configure AVRISP MKII Programmer to work with Arduino IDE (steps to download in section “02 – 1: Arduino IDE Tutorial”), it is necessary to install lib-win32 drivers. Extract the downloaded zip file, then follow the steps below to install AVRISP drivers:

STEP 1: Disable windows driver signature enforcement by following steps in this tutorial.

STEP 2:  Plug in the programmer to computer intended for the installation process, then open the “Device Manager”.

STEP 3:  Right-click on “AVRISP mkII” and click on “Update Driver Software”.

STEP 4:  Click on “Browse my computer for driver software”.

STEP 5: Make sure that “Include subfolders” is checked, then click on “Browse”.

STEP 6: Navigate to the extracted folder (i.e. avrispmkii_libusb-win32_1.2.1.0), then click “OK”.

STEP 7: Click on “Let me pick from a list of device drivers on my computer”.

STEP 8: Click on “libusb-win32 devices”.

STEP 10:  Click on “Browse” and locate “AVRISP_mkII.inf” in the “Downloads” folder.

STEP 11: Click “Next” to close and the driver should be successfully installed.

Writing the Fuse Settings

Now, setting the correct fuse settings can be done by two methods:

Method 1: Using Atmel Studio 7 (Windows Only)

STEP 1: Open Atmel Studio 7 and click Tools -> Device Programming.

STEP 2: The following window will appear. The tool to select is the AVRISPmkII. The device to select depends on what microcontroller is being used on your device. In the case of the 3DoT board, you will be selecting the Atmega32U4. You can find it by using the drop down menu or by typing out the name. Ensure the settings are as pictured and click “Apply”.

STEP 3: If your device connected successfully you should see the following window. Click “Fuses”.

STEP 4: Set the fuses as pictured and click “Program”. To understand what each fuse setting does, refer to the ATmega32u4 Datasheet.

A warning may pop up to change to certain fuses. These warnings can be accepted.

Method 2: Using avrdude (All platforms)

STEP 1: Download and install WinAVR.

( On Linux run sudo apt-get install avr-libc avrdude binutils-avr gcc-avr srecord )

( On OS X install CrossPack )

STEP 2: Open Command Prompt (or a terminal window on Linux/OS X). Paste the following command into the command prompt.

avrdude -c avrispmkII -p m32u4 -P usb -U efuse:w:0xCB:m -U hfuse:w:0x98:m -U lfuse:w:0xE2:m

This will configure the board to use the ATmega32u4’s internal clock, so the external crystal will no longer be needed.

To customize the fuse settings, see this calculator for the possible options.

Burn Bootloader using Arduino IDE

STEP 1: Plug in the ICSP socket to the 3DoT board and jumper wires to the proper AVRISP mkII programmer pins. Then switch ON the 3DoT.

STEP 2: After switching the 3DoT ON, the LED on the AVRISP mkII programmer will change from red to yellow.

STEP 3: Open Arduino IDE and go to Tools > Programmer. Make sure “AVR mkII” is selected.

STEP 4: Select “Arxterra 3DoT” from Tools > Board.

If the Arxterra 3DoT board is not installed in your Arduino IDE, see “Using the 3DoT Bootloader

STEP 5:  Go to Tools > Burn Bootloader.

STEP 6: Ignore the “WARNING” and wait for the Bootloader to be burned.