Friday, 15 February 2013

Panelolu2 - An I2C control solution for Sanguinololu, Melzi and moreThe original Panelolu was designed to provide a simple user interface for a 3d printer controlled by a Sanguinololu and similar electronics - enabled by the Ultipanel code within the Marlin firmware. By connecting to the right pinouts it also works with Printrboard and RAMPS.I have developed a new version which uses an I2C port expander to drive the LCD screen and adds a piezo buzzer and indication LEDs. This version uses less pins, making it compatible with the Melzi electronics and even leaves enough spare pins to drive a couple more outputs (such as an additional extractor fan and stepper driver cooling fan).

In the photo above the grid covers the piezo buzzer and the H,E and F LEDs indicate that the Heated bed, Extruder and Fan (or second extruder) are on. It would be relatively simple to change the firmware to have these LEDs turn on for another reason. The R for reset and the encoder wheel are the same as in the original Panelolu although I have made the encoder wheel about 1/3 smaller to fit better.

Circuit board

The Panelolu2 design simplifies the assembly by mounting all components on one circuit board that can be soldered directly to an LCD screen. The standard way to connect it to the screen is with a single row of 2.54mm headers as shown below. This row of headers could be replaced by wires (ribbon cable would be best) - enabling a variey of case designs, such as Printbit's Panelolu Box for Mendel Max.

This simplification also extends to the wiring which is now a 2x6 IDC plug on both ends of a ribbon cable. The circuit uses a combination of through hole and surface mount components; the other side of the prototype circuit board is shown below. The brightness and contrast pots are now on the back of the board and can be adjusted through the rear of the case.

I have tidied up the Schematic: the components are the MCP23017 port expander, the SD card circuitry, buzzer, click encoder and LEDS.

Of course the whole project is Open Source Hardware and the eagle files are available on github.Case design

As mentioned above, the circuit board and LCD allow for multiple case designs. I have made a simple case with a back leg allowing the Panelolu2 to sit on the bench alongside the printer. The case design is all done in OpenSCAD with both .scad and .stl versions of the files, available on Thingiverse. One of the great things I have found about Thingiverse is it allows you to embed the Thingiviews of the STL files, so here are the front and back case views:

Front&lt;p&gt;Your browser does not support iframes.&lt;/p&gt;
Back&lt;p&gt;Your browser does not support iframes.&lt;/p&gt;
The OpenSCAD file also allows the back leg to be generated to support the case at your chosen angle. For the rotary encoder I adapted Miserybot's "Spinner Knob" design to make it about 1/3 smaller and a lot thinner - the .stl is on Thingiverse and I will upload the OpenSCAD code once it is cleaned up.

Adapter BoardsOne of the aims of the Panelolu2 was to reduce the complexity involved in wiring it up. I have designed adapter boards to allow compatibility of the Panelolu2 with various electronics. The picture below shows the adapter board connected to a Sanguinololu.

Update added the Sanguinololu and Melzi adapter schematics:

As can be seen from the schematic the two mosfets for driving additional light loads such as fans are on the PWM and A3 pins on the Sanguinololu. These pins can be accessed as Arduino digital pins 4 for the pin labelled PWM and 28 for the pin labelled A3. In Marlin firmware to turn on the fan connected to Transistor 1:M42 S255 P4And transistor 2M42 S255 P28In overview the picture below shows the inputs and outputs from the prototype Melzi adapter board.

The Schematic for the Melzi adapter board is:

The same logic as described the solder jumper operations on the Sanguinololu adapter board applies to the Melzi board. For the two additional outputs they are on pin A4 and A3 which are digital pins 27 and 28 respectively.In Marlin firmware to turn on the fan connected to Transistor 1:M42 S255 P28And transistor 2M42 S255 P27For basic operation the ISP and expansion header plug into the Melzi and the Panelolu plugs into its 2x6 connector. If desired FETs can be mounted to switch a 12V supply, for example to drive external fans.

As an alternative
to the adapter board, standard female housings with crimp connectors
could be used. I intend to design boards for Printrboard and RAMPS in the near future.(update: done, see this blog post)I2C encoder optionInstead of linking the encoder and switch directly to pins on the Sanguinololu, Melzi or other electronics, the hardware has the option to run the encoder and switch over I2C. This would free up a couple more pins but the option is not yet supported by firmware. The Panelolu2 circuit board and adapter boards have solder jumpers, shown below on the back of the Melzi adapter board

Currently the firmware does not support routing the encoder signals over I2C so by default these jumpers will be set for normal operation. FirmwareThe Panelolu2 only runs on Marlin firmware at the moment. Excellent work was done by Daid in the Marlin code to split the LCD screen hardware from the user interface. This made it straightforward to implement the Panelolu2 code. As mentioned in previous posts LiquidTWI2 by Lincomatic is required; download it from github, rename the directory from "LiquidTWI2-master" to "LiquidTWI2 and put it in the

arduno-0023/libraries/

sub-folder.UPDATE: - This step is no longer required in the latest version of LiquidTWI2 (1.2.4) the library will work out the box with no configuration changes required.By default the Panelolu2 is disabled in LiquidTWI2, after saving the directory, edit LiquidTWI2.h to remove the comments on line 10: // #define PANELOLU2 //only possible....To #define PANELOLU2 //only possible....Continue following the instructions from here:Then download the T3P3 fork of Marlin, make the changes you need to configuration.h to suit your printer and ensure :#define EEPROM_SETTINGSand#define PANELOLU2are uncommented within configuration.h then upload as normal. The compiled
Marlin is ~100k, a very similar size to Marlin compiled for the original
Panelolu, so the electronics board will need enough space (a 1284P is fine, a 644P does not have enough space).

SummaryUpdate, added this section to summarise the process of getting the Panelolu2 working Sanguinololu.

If you are not already using it get the standard version of Arduino-0023 from the Arduino website, note that the T3P3 version of Marlin has not been tested with Arduino 1.0 or higher.

If you are not already using a Sanguinololu with 1284P then update the avrdude.conf file in the standard Arduino-0023 to include a definition of the atmega 1284p, I have used this one for a year now. Be sure to put it in arduino-0023\hardware\tools\avr\etc\ and rename or overwrite the old one. More detail in my first blog post.

If you are not already using a Sanguinololu with 1284P add the "Marlin\ArduinoAddons\Arduino_0.xx\Sanguino" directory to "arduino-0023\Hardware\" directory. This provides the Sanguino extensions required for Sanguinol and Melzi.

Modify the configuration.h of the Marlin to fit your printer setup (setting like controller board, axis dimensions, thermistors, etc). Its best to copy these from the configuration.h of your existing firmware. Update: This blog post should help.

Confirm Marlin compiles and uploads with //#define PANELOLU2 still commented out in configuration.h.

Then uncomment #define PANELOLU2 , along with #define EEPROM_SETTINGS and #define EEPROM_CHITCHAT and confirm it compiles and uploads. Note that with the #define PANELOLU2 uncommented, you must have the Panelolu2 connected or Marlin will hang and not finish initialising.

Check the printer operation and calibration to ensure you have edited the Marlin configuration.h properly.

Tuesday, 5 February 2013

An (almost) 32 bit font for OpenSCAD.I have used Tony Buser's bitmap OpenSCAD font to add 3D letters to various objects. I recently wanted to to get higher resolution than 8 bits but did not want the more complicated workflow (of which there are a number of examples 12 ) of creating the letters outside of OpenSCAD as a DXF, then importing them and linear extruding to get the desired 3D objects.

The solution was to use "The Dot Factory" which is designed for creating bitmaps for graphics LCDs. It allows you to import a system font (I used Lucida Console at 24pts) and export that as a text file with each character mapped to a number of bytes representing the bitmap. For example the letter "a"