Friday 15 February 2013

Panelolu2

Panelolu2 - An I2C control solution for Sanguinololu, Melzi and more

The 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).


Panelolu2 Front View
  
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.
 
Panelolu2 Side View 

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
 
 
Back
 



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 Boards

One 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 P4

And transistor 2

M42 S255 P28

In 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 P28

And transistor 2

M42 S255 P27

For 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 option 

Instead 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.


Firmware 


The 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_SETTINGS
and

#define PANELOLU2

are 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).


Summary

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


  1. 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.
  2. 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.
  3. Get T3P3 Marlin from github.
  4. 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.
  5. Get LiquidTWI2 as mentioned above, note that configuration changes are no longer required in the latest version of LiquidTWI2.
  6. 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.
  7. Confirm Marlin compiles and uploads with //#define PANELOLU2 still commented out in configuration.h.
  8. 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.
  9. Check the printer operation and calibration to ensure you have edited the Marlin configuration.h properly.

Availability

As always the hardware is open source so the design files are available on Github: https://github.com/T3P3/Panelolu2.

Update: Now available on our webstore and on eMakershop and eBay 

Tuesday 5 February 2013

OpenSCAD Bitmap Font

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 1 2 ) 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"

    0b00000000, 0b00000000, //               
    0b00000000, 0b00000000, //               
    0b00000000, 0b00000000, //               
    0b00000000, 0b00000000, //               
    0b00000000, 0b00000000, //               
    0b00000000, 0b00000000, //               
    0b00000000, 0b00000000, //               
    0b00000000, 0b00000000, //               
    0b00011111, 0b11000000, //    #######    
    0b01111111, 0b11110000, //  ###########  
    0b01100000, 0b01111000, //  ##      #### 
    0b00000000, 0b00111000, //           ### 
    0b00000000, 0b00111000, //           ### 
    0b00000000, 0b00111000, //           ### 
    0b00000000, 0b00111000, //           ### 
    0b00001111, 0b11111000, //     ######### 
    0b00111111, 0b11111000, //   ########### 
    0b01111000, 0b00111000, //  ####     ### 
    0b11110000, 0b00111000, // ####      ### 
    0b11100000, 0b00111000, // ###       ### 
    0b11100000, 0b00111000, // ###       ### 
    0b11100000, 0b00111000, // ###       ### 
    0b11110000, 0b11111000, // ####    ##### 
    0b01111111, 0b10011111, //  ########  #####
    0b00011111, 0b00001111, //    #####    ####
    0b00000000, 0b00000000, //               
    0b00000000, 0b00000000, //               
    0b00000000, 0b00000000, //               
    0b00000000, 0b00000000, //               
    0b00000000, 0b00000000, //               
    0b00000000, 0b00000000, //


 
With some text manipulation (in my case using notepad++, which is excellent) this is converted into:
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,
    0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,0,0,0,0,0,
    0,0,0,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0



The matrix above is the format that Tony Buser's open scad bitmap drawer uses, define the number of bits per row and you are away:

Still a bit chunky but less so than the original 8 bit version:
The full list of characters created are:


ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
0123456789

 !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~


Depending on the character the bitmaps are 8,16,24 or 32 bits wide and the bitmaps are all 31 bits high.

If you render them all at once they can use quite a bit of processing power, best to leave extensive 3d lettering until the rest of the object is designed.

The OpenSCAD script is available on github.
 
Update: Inkscape has a plug-in to export direct to OpenSCAD so this may make that method easier - one to check next time!