Sunday 22 July 2012

Disabling JTAG on PrintrBoard

Disabling JTAG on PrintrBoard - Get 4 more I/O pins

As I discovered while getting the Panelolu working with a Printrboard the JTAG interface is enabled by default. This uses 4 pins on one of the expansion headers:

In order to get access to these pins the JTAG interface needs to be disabled: to do this you have to change the fuses on the AT90USB1286 micro. An ISP is required (I use the Pololu AVR ISP) but others should work fine.

Warning: You can "brick" your micro if you mess up the fuse settings: handle with care and I don't recommend you mess with the clock settings!

Lincomatic describes how to set the fuses in his blog post on uploading a bootloader to the AT90USB1286. He has the following settings

LOW : 0xDE
HIGH: 0x9B
EXT: 0xF0

Using the fuse calculator at, start by selecting the AT90USB1286 and then put the DE,9B and F0 setting in at the bottom of the page. After applying these settings it is simple to deselect the "JTAG Interface Enabled" check box and recalculate the settings. The only one which has changed is the HIGH setting to 0xDB

Using the version of avrdude that comes with arduino 0023 change the fuse setting to disable the JTAG interface:

avrdude -c avrispv2 -p at90usb1286 -U hfuse:w:0xdb:m  -C ..\etc\avrdude.conf -P com40

You will need to change the "-c avrisp2" to match your ISP and the "-P com40" to match the com port it's on.

Now that we have read-write access to those pins the connections for the Panelolu can use 1 less plug and stay on just one expansion header:

The pin allocations are:

With pin numbering of:
TDI = 42
TDO =43
TMS = 44
TCK = 45

The only change to the firmware from that described in my previous post is:


      #define LCD_PINS_D4        42
      #define LCD_PINS_D5        43
      #define LCD_PINS_D6        44
      #define LCD_PINS_D7        45
So if you have an ISP and want 4 more IO pins this is the way to go. If you are going to buy a Printrboard then ensure you get your supplier to change the fuses to disable the JTAG interface before sending it to you.

Panelolu with Printrboard

Panelolu with Printrboard

Update: The Panelolu2 has replaced the Panelolu. It is much quicker to install, has adapter boards to no messing with cables and uses less pins. The blog post with the information is here, it is available to buy in our webshop.

The Printrboard is a based on the Teensylu which is itself a derivative of the Sanguinololu; the main difference is the use of the AT90USB1286  in place of the ATmega644P or 1284P.

Thanks to the work of Lincomatic, Marlin firmware will run on the AT90USB1286. The Printrboard section of the RepRap wiki page has information on the board and an outline of how to upload the firmware - you will need Lincomatic's fork of Marlin. The Printrboard I bought was supposed to come with a bootloader but that did not work. I followed Lincomatic's instructions to install the CDC bootloader using the Pololu ISP I have used previously on ATmega644P and ATmega1284P micros. It's worth ensuring you have a working setup with the Printrboard connecting to your control software (Pronterface for me) and firmware uploading before you go any further.

Built in SD card reader or SDSL?

The Printrboard has a build in SD card reader so you do not need an SDSL. That said I prefer to have the electronics hidden away, so using the SDSL in the Panelolu is my preference. Both options will work and are described below.

Hardware and wiring the Panelolu

The wiring internal to the Panelolu is identical to that described in my previous post, with the option not to bother with wires 13,15,16,17,19,20,21,22 and the 10 pin IDC connector if you are going to use the build in SD card reader on the Printrboard.
Unfortunately the design of the expansion headers on the Printrboard does not keep to the standard 2.54mm spacing between the expansion header and the ISP header (and 4 pins on ext1 are not I/O by default) - a simple IDC connector will not fit without bending the pins . The solution is to use the same connectors that are used on the LCD and circuit board within the Panelolu.

The pin out is as follows:
Ribbon cable wire number
Printrboard Pin Label
Marlin Pin
Marlin Pin
 Not used *
 Not used *

* Wire 1 and 2 are not connected/used but kept in for consistency with the original instructions.
** Can come either from the RESET pin on the expansion header or the ISP header.
*** Only required if a SDSL is used rather than the on board SD card reader

Update There was a mistake in the table above, thanks to Colin Bradburne for bringing the problem to my attention. It is fixed now - the lines in red have been amended.

If using the SDSL rather than the on board SD card reader then the following connections to the ISP header are used as well.

Ribbon cable wire number
Printrboard Pin Label
Marlin Pin number
Marlin Pin name

The Printrboard I bought does not have the expansion header pins labelled, I have annotated the pins on the screen shot of the board below:
The 4 pins labelled "JTAG PINS" are set to the JTAG interface by default - I have done a separate blog post about how to change the fuse settings to gain access to these pins as I/O. This does mean that we can't fit the Panelolu connections onto just one expansion header, hence the 4 pins on the second expansion header towards the centre of the board

The ribbon cable with the connectors will look like this:

Pairing this picture with the annotated screen shot of the board should show how to plug in the cables. (note that wire 1 and 2 are not in this picture as they are not used and that a 4 pin connector is used for MISO,SCLK and RESET because I ran out of 3 pin connectors)

Firmware configuration

The following firmware changes to Marlin are required to get the Panelolu working with a Printrboard. Please note that line numbers are based on my version of Lincomatic's branch of Marlin - they may be slightly different with a different version or after additional changes are made.


line 34-40:
#define MOTHERBOARD 81

#if (MOTHERBOARD == 81) //printrboard
 #define SDSUPPORT
 //comment out the following line to use onboard SD card reader

#define USESDSL
line 234:


within the Printrboard (81) section
line 953 -984  
  #ifdef ULTRA_LCD
    #ifdef NEWPANEL
      //we have no buzzer installed
      #define BEEPER -1
      //LCD Pins
      #define LCD_PINS_RS        41
      #define LCD_PINS_ENABLE    1
      #define LCD_PINS_D4        11
      #define LCD_PINS_D5        9
      #define LCD_PINS_D6        6
      #define LCD_PINS_D7        4

      //The encoder and click button
      #define BTN_EN1 2  //must be a hardware interrupt pin
      #define BTN_EN2 3 //must be hardware interrupt pin
      #define BTN_ENC 0  //the click
      //not connected to a pin currently
      #define SDCARDDETECT -1
      //from the same bit in the RAMPS Newpanel define
      //encoder rotation values
      #define encrot0 0
      #define encrot1 2
      #define encrot2 3
      #define encrot3 1
      #define BLEN_C 2
      #define BLEN_B 1
      #define BLEN_A 0

    #endif //Newpanel
  #endif //Ultipanel


Line 224-236

// SPI port
#if MOTHERBOARD == 81 //printrboard
#ifdef USESDSL  //SDSL with Panelolu
uint8_t const SS_PIN = 40;    //F2
uint8_t const SS_PIN = 26;    // B6
uint8_t const SS_PIN = 20;    // B0
uint8_t const MOSI_PIN = 22;  // B2
uint8_t const MISO_PIN = 23;  // B3
uint8_t const SCK_PIN = 21;   // B1 

To explain what the firmware changes actually do:
  • Add the USESDSL define to configuration.h which allows easy toggling between the onboard SD card reader and the SDSL
  • Enable the ULTIMAKERCONTROLLER which the PanelMax and Panelolu are derivatives of.
  • Define the pins that are used for the Panelolu within the Printrboard section of the pins definition file
  • Add a check to the SdPinMap to see if SDSL on onboard card reader is selected with the USESDSL define.

To get a Panelolu working on Printrboard: 
  • Confirm you can connect to the Printrboard and upload firmware - if not follow Lincomatic's instructions for loading a bootloader.
  • Get Lincomatic's branch of Marlin and make the changes listed in the Firmware section above.
  • Get the components required for a Panelololu and wire up the Panelolu end as described in my previous post.
  • Wire up the end of the ribbon cable that is going to the Printrboard as described above. 

Friday 20 July 2012

Panelolu Circuit Board

Panelolu Circuit Board

Update: The Panelolu2 has replaced the Panelolu. It is much quicker to install, has adapter boards to no messing with cables and uses less pins. The blog post with the information is here, it is available to buy in our webshop.

Thanks to Jason Thompson we now have circuit boards for the Panelolu to replace the breadboards. The circuit has not changed so if you are sourcing the bits yourself the breadboard is still a good option and will work fine; however the circuit board makes assembly easier and quicker - thanks Jason!

We have assembled some boards and soldered the headers onto LCDs so there is now an option to buy the kit from us with pre-soldered components.

They are available from eMakershop and eBay, as options.

Update: The Original design by Jason Thompson is available on the Think3dPrint3d Github: