Wednesday, 10 October 2012

Panelolu

I was having a look at the various Panelolu designs.
More specifically at how to wire one up at the Think3dPrint3d website and decided that I needed to have a go at simplifying the wiring for use with an I2C connected LCD.

I am not using an SDSL per se, but an off the shelf Micro SD card reader that is a fraction of the cost (£5.84 vs £13.20 inc P&P)

This could potentially be done even cheaper with a standard SD card reader that can be had for about £1.14 from Ebay
If I believe I can use just 12 pins for all of the panel connectivity. If I use a couple of Dupont 2x3 connectors, then the other pins will still be available for any other uses that may come along, as they can stack side by side.
The great thing about Dupont connectors is that they are easy to change pinouts - just lift the flap that holds the pin in place, pull out the pin and move it to another slot. If you have any cables with single ends, 1x2, 1x4, 1x6 ends, you can easily change it to a different configuration if you have the appropriate connector or simply want to change the arrangement of pins from one end to the other to quickly make a custom cable.

Typical prices for Dupont pins and connectors - all prices from Ebay

100 x female pins £1.90
100 x male pins £2.25
100 x 1x2 pin connectors £1.63
100 x 1x3 pin connectors £1.63
100 x 1x4 pin connectors £2.25
100 x 1x6 pin connectors £2.25
100 x 2x3 pin connectors £2.32
40 x 1 pin female - 1 pin female wires £1.21

I use a ratchet crimper with replaceable jaws, but you can just as easily use a pair of needle nose pliers instead.

Here is the Schematic I mocked up, you will see that the PCF8574P chip handles all of the connectivity to the LCD.
I intend to use 90 degree header pins on the LCD panel and some 1x6 Dupont connectors, connection to the Micro SD board is again 90 degree header pins, a 1x6 Dupont and a 1 pin Dupont or 1x3 pin and 1x4 pin (as I need 7 pins) - total cost of connectors (3 x 1x6 connector, 1 x 1x1 connector, 2 x 2x3 connector, 30 x male pins) is about £0.80, with another £0.08 for 90 degree header pins.

Encoder - £6.19 for 10, Pots - £1.41 for 10, switch - £0.08, 2004 LCD - £4.24 and some perfboard.

If you can make do with a 1602 LCD, these can be had for £1.34.

So total parts cost for I2C Panel about £2.60 (includes cost of PCF8574P) , then add either Micro SD or standard SD, 2004 or 1602 LCD, and price varies from about £5.00 (standard SD and 1602) to £12.50 (micro SD and 2004) all in.

OK, the STL file for the panel may also need a little tweaking for my internals, but overall should be pretty simple to do.

Sunday, 7 October 2012

ATmega1284P, Marlin and I2C

I bought a few items from RS on a visit to their Hounslow branch and revived my account that had been dormant for nearly 10 years!

JST 2mm pitch 6 way connectors for running new wires to my Steppers (50 pack for £3.30)
Crimp Contact Pins for the connectors (50 pack for £1.60)
ATmega1284P-PU Microcontroller (£4.55 each)
Nylon Screw Insulator Rail bushings for my cast Prusa parts (50 pack for £3.67)

Not all parts were in stock at that branch, so I arranged for out of stock parts to be posted to me (one of the perks of an RS account is that the postage is free).

RS are often not the cheapest, but they do have hard to locate parts, like the JST connectors, and I do not need to worry about building a large order to offset postage costs of places like Rapid or Farnell.

The ATmega1284P from RS is half the price of the cheapest one I can find anywhere else - cheapest I can find is on Ebay for £7.99 with £1.20 postage.

I replaced the ATmega644P chip on my breadboard with the new 1284P chip, updated the settings in Arduino for "Mighty" and burned the bootloader and then uploaded the latest version of Marlin that actually compiles with a current version of Arduino (1.0 or 1.0.1) - all good so far.

Dowloaded the LiquidCrystal_I2C library and put the files in the relevant Arduino directory, then started splicing it into Marlin, very little to it as it happens - every file that has a reference for LiquidCrystal just needs to have an equivalent one for LiquidCrystal_I2C added.

Configuration.h

change
//LCD and SD support (Manual definitions if not using ULTIPANEL)
#define ULTRA_LCD  //general lcd support, also 16x2

to
//LCD and SD support (Manual definitions if not using ULTIPANEL)
#define I2C_LCD 0x27  // I2C LCD Panel (overrides the LiquidCrystal library with LiquidCrystal_I2C) - value is I2C Address for LCD
#define ULTRA_LCD  //general lcd support, also 16x2

ultralcd.h

change
#include <LiquidCrystal.h>

to
#ifdef I2C_LCD
  #include <LiquidCrystal_I2C.h>
#else
  #include <LiquidCrystal.h>
#endif


and
extern LiquidCrystal lcd;

to
#ifdef I2C_LCD
  extern LiquidCrystal_I2C lcd;
#else
  extern LiquidCrystal lcd;
#endif

ultralcd.ino

change
#include <LiquidCrystal.h>

to
#ifdef I2C_LCD
  #include <LiquidCrystal_I2C.h>
#else
  #include <LiquidCrystal.h>
#endif

and
LiquidCrystal lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7);  //RS,Enable,D4,D5,D6,D7

to
#ifdef I2C_LCD
  LiquidCrystal_I2C lcd(I2C_LCD, LCD_WIDTH, LCD_HEIGHT);
#else
  LiquidCrystal lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7);  //RS,Enable,D4,D5,D6,D7
#endif

Then re-compile and upload to the bigger ATmega1284P chip.

Everything worked fine, except that when I connect to the chip from Printrun, the printer no longer comes online.

Now this could be because I don't actually have a connection to an I2C chip or LCD display at this moment in time, I will have to wait until I have one to prove one way or the other.

I have a bunch of 8 bit I2C Expander chips on order (10 x PCF8574 for £3.71) but they seem to be lost in the post at present, looks like I will need to have the Ebay vendor resend them.

An alternative, but slightly more expensive option is an I2C LCD interface board.
These can be had on Ebay for as little as £2.44 each, I can wire my own for about £0.70 with the chips mentioned previously (37p for the I2C expander, 3p for the transistor, 25p for the potentiometer and a few more pennies for the pin headers and some perf board).

The main benefit of using the I2C version is that only 2 pins, SCL (D16) and SDA (D17) are required, along with a 5V and GND, and these can be spliced from any existing supply pins, compared with 6 dedicated pins for running the LCD directly.

In addition, any other I2C devices can be added with no extra pins being required as it is a bus based technology.

A unique address for each I2C device, which can be set by choosing which of the 3 Address pins are connected to 5V on the 8 bit I2C Expander:

Address pins A0, A1 and A2 make up the last 3 bits of a 7 bit binary number, so the available range is from 0100000 (32 decimal or 0x20 hex) - 0100111 (39 decimal or 0x27 hex).

Typical connectivity to an LCD panel as follows (image from Pavel Bansky's website):
I don't have any BC548B NPN transistors, plus they are end of life anyway, however I do have a C945 which should be a close enough substitute, but since this is only really for adjusting brightness I will probably just connect it to either a resistor or a potentiometer and adjust manually.

I also ordered some stepstick A4983 units from Ebay, these ones do 1/16 microstepping and are only £4.43 each, so nearly half the price of the previous ones I bought from Denmark and free shipping from China.