Microcontroller firmware installation

From RepRap
Jump to: navigation, search


Mendel Build Documentation



Motherboard-programming.jpg
RepRap has a Motherboard that is the overall controller of the machine. Each extruder has a subsidiary controller. The motherboard and extruder controllers have to be programmed. This page tells you how to do that.
Please Note this page describes how to install the RepRap standard firmware. There are alternatives to the standard firmware available and these are listed on the Comparison of RepRap Toolchains.

Both the motherboard and the extruder controllers need to have a bootloader installed before you can upload programs to them. This only needs to be done once, and, if you bought ready-made boards, the bootloader will already have been installed in them. But if you made the boards yourself you will have to do that. Bootloader-installing instructions are here.

Before you start

These instructions were tested on Ubuntu 32-bit, are known to work on Ubuntu 64-bit, all variants of Mac OS X (including PPC) and Windows 32-bit, but not Windows 64-bit. If you do manage to get this to work with Windows 7 64-bit, please let us know how you did it, by adding instructions to this Wiki.

Setting up Arduino Software for Sanguino

Before you can download into your Sanguino motherboard, you need to have the Arduino environment set up to be able to recognize the different Atmel 644p processor.

Download and install Arduino software, then download the Sanguino extensions from Zach's Sanguino site.

Warning: make sure that the IDE version of Arduino that you use matches the Sanguino version.

Newer versions of arduino (at least 0018 and later)

These versions have better support for hardware like the Sanguino, so you only need to add one folder instead of doing a lot of editing.

Copy the Sanguino folder that's in the downloaded zip file into your arduino-00XX/Hardware folder so that your folder structure looks like this:

    arduino-00XX/hardware/Sanguino

Make sure you select Sanguino from the boards menu!

NOTE:

Recently Sanguino has been ported to use the Arduino Core. The Sanguino is now compilable and uploadable easily with Arduino IDE 1.0.4 or above using Optiboot loader. Atmega644p and Atmega1284p are now build and uploadable sketches on latest Arduino IDE. Blog with Details can be found on Bhashatech blog website

Older versions of arduino (0017 and earlier)

In the downloaded core files you will need to copy the folders to their respective locations.

   * copy sanguino-software-1.x/cores/sanguino to arduino/hardware/cores/sanguino
   * copy sanguino-software-1.x/bootloaders/atmega644p to arduino/hardware/bootloaders/atmega644p
   * copy all the folders in sanguino-software-1.x/libraries/ to arduino/hardware/libraries/ overwriting the existing libraries.

Next you need to edit the boards.txt file to add the Sanguino to the available boards. It can be found in arduino/hardware/boards.txt


Restart the Arduino environment and you can now download your firmware to the Sanguino.

Full instructions are also available here.

Programming the Motherboard

Compiling

The C++ program to be loaded into the Motherboard is in the directory mendel/firmware/FiveD_GCode/FiveD_GCode_Interpreter of the download. The latest version is here in the RepRap Subversion repository, but take care with that - it may be an unstable development version. The stable version is located inside the reprap-mendel-yyyymmdd.zip that you downloaded when you installed the RepRap Host software Installing_RepRap_on_your_computer ).

In your download directory there is a distribution configuration file called configuration.h.dist. Copy that file to a new file called configuration.h. The reason for this copying is that, when you download a new version of RepRap, you may not want to over-write your personal configuration file.

Run the Arduino Development Environment and load up the sketchbook mendel/firmware/FiveD_GCode/FiveD_GCode_Interpreter/FiveD_GCode_Interpreter.pde. Your new configuration.h file should appear as one of the tabs.

Click on that tab and read through the file. It is extensively commented and gives instructions on what to do to configure the firmware for your particular RepRap setup. When you have edited it, select File->Save.

In the Arduino Development Environment select Tools->Board->Sanguino then select Sketch->Verify/Compile.

The program should compile without errors.

Uploading

Plug the USB<->serial cable you made up on this page into the six-pin connector on the left edge of the Motherboard as shown. Make sure you get it the right way round. The RTS connection (which you should have coloured green) goes to the top end of the Motherboard connector labeled "GRN". The ground connection (coloured black) goes at the bottom, labeled "BLK".

Check that you have a jumper fitted on the 2-pin connector by C8 on the Motherboard just to the right of the 6-pin connector you're using. It is this jumper that allows the board to be programmed.

Plug a USB cable into the USB-B socket, but don't connect the other end to your computer yet.

Check the list of connections at Tools->Serial Port and note them. Then plug in the USB cable and check the list again - a new entry should have appeared (on Linux it will be something like /dev/ttyUSB0, and on Windows it will be something like COM5). Select that new entry if it hasn't automatically been selected by the Arduino software - it is the USB interface that you just plugged in.

Incidentally - the Power LED on the Motherboard should now be alight. The Motherboard is USB powered.

Select Upload to I/O Board (the little square box with the right -> arrow).

On the Sanguino-derived gen-3 motherboard, you need to press the reset button in order to upload the firmware to it. This can be tricky, because not all computers are equal and may compile the firmware in different spans of time. You want to press reset as soon as you see the "Binary sketch size: X bytes (of a X byte maximum)" message.

On at least some versions of the RepRap Gen3 motherboard, jumpering the auto reset jumper allows the Arduino IDE to automatically reset the board when uploading, which is very convenient and avoids all the manual timing issues.

After a few seconds the debug LED on the Motherboard should flicker - this is the program being loaded into the board.

After a few more seconds the Arduino Development Environment should say Done uploading and the debug LED should settle down to a regular pulse at about 2 Hz. That is the RepRap program running on the Motherboard.

If the upload doesn't work, unplug the USB cable, wait a couple of seconds, and plug it back in. Then (with your non-mouse hand) hold down the Motherboard's RESET button. Hover the mouse over the Upload to I/O Board box, release the RESET, then almost immediately click the mouse.

Or click Upload to I/O Board then press and hold the reset button on the motherboard until you see white text at the buttom of the Arduino IDE, then immediately release the reset button, and wait for the Done uploading...

To see how to test the programmed Motherboard, follow this link.

Programming an Extruder Controller

Extruder-programming.jpg

The procedure for this is very similar to that for programming the Motherboard.

Compiling

The C++ program to be loaded into Extruder Controllers is in the directory mendel/firmware/FiveD_GCode/Extruder of the download. The latest version is here in the RepRap Subversion repository, but take care with that - it may be an unstable development version. The stable version is located inside the reprap-mendel-yyyymmdd.zip that you downloaded when you installed the RepRap Host software. Installing_RepRap_on_your_computer

In your download directory there is a distribution configuration file called configuration.h.dist. Copy that file to a new file called configuration.h. The reason for this copying is that, when you download a new version of RepRap, you may not want to over-write your personal configuration file.

Run the Arduino Development Environment and load up the sketchbook mendel/firmware/FiveD_GCode/Extruder/Extruder.pde. Your new configuration.h file should appear as one of the tabs.

Click on that tab and read through the file. It is quite short. The comments give instructions on what to do to configure the firmware for your particular extruder setup. For details on calculating E_STEPS_per_MM, see the page Commissioning. When you have edited it, select File->Save.

If you are using a thermistor as an extruder temperature sensor you should also look at the file temperature.h. Select the table that corresponds to your thermistor. If you are using a thermistor for which there is not a standard table that is not a problem. There's a Python program to generate tables for any thermistor. The program is in your RepRap files at mendel/firmware/createTemperatureLookup.py. See this page for details.

In the Arduino Development Environment select Tools->Board->Arduino Diecimila or Duemilanove w/ ATmega 168 then select Sketch->Verify/Compile.

The program should compile without errors.

Uploading

Plug the USB<->serial cable you made up on this page into the six-pin connector on the left edge of the Extruder Controller as shown. Make sure you get it the right way round. The RTS connection (which you should have coloured green) goes to the bottom end of the Extruder Controller connector labeled "GRN/RTS". The ground connection (coloured black) goes at the top, labeled "BLK/GND".

Plug a USB cable into the USB-B socket, but don't connect the other end to your computer yet.

Check the list of connections at Tools->Serial Port and note them. Then plug in the USB cable and check the list again - a new entry should have appeared (on Linux it will be something like /dev/ttyUSB0, and on Windows it will be something like COM5). Select that new entry if it hasn't automatically been selected by the Arduino software - it is the USB interface that you just plugged in.

You don't need a programming jumper on the extruder controller (2.2). You don't need to do the "press Reset after 5 seconds" trick to get the IDE to successfully upload. (Both of which you DO need for the 1.2 Motherboard)

Incidentally - the Power LED on the Extruder Controller should now be alight. The Extruder Controller is USB-powered for programming, and self-powered when it is running from its 12 volt supply. You may find that some of the other LEDs light as well - this is fine.

Select Upload to I/O Board (the little square box with the right -> arrow). After a few seconds the debug LED on the Extruder Controller should flicker - this is the program being loaded into the board.

After a few more seconds the Arduino Development Environment should say Done uploading and the debug LED should go out.

If the upload doesn't work, unplug the USB cable, wait a couple of seconds, and plug it back in. Then (with your non-mouse hand) hold down the Extruder Controller's RESET button. Hover the mouse over the Upload to I/O Board box, release the RESET, then almost immediately click the mouse.

To see how to test a programmed extruder controller, follow this link.

After successfully uploading new firmware, we recommend immediately copying a snapshot of that exact firmware (and all the source code you used to build it) onto a second computer.

See also

See also the Generation 3 Firmware page.