Tuesday, February 1, 2011

LeafLabs Maple with Nokia 5110 LCD display

I just got two Nokia5110 LCD displays, similar to this one. It's a basic monochrome 84x48 pixel display, very affordable, and they seem to be pretty widely available. It is the successor of the Nokia3310, both display can use the same drivers. One tricky part of the display is that the data is written to the display serially, one byte at a time. And one byte represents 8 pixels (vertically). So you cannot set one pixel at a time. This is fine for fonts (if they are multiple of 8 pixels high). But if you need control over each pixel, a display buffer needs to be implemented in the driver software.

I wanted to see if I can get this display to work on the Maple, so I did a quick port of an existing Arduino library for the display to the Maple. The library is modeled after the LiquidCrystal code, so it can be called pretty much the same way. It is just using a bit-banged approach to control the display, so you can hook up the display to pretty much any of the Maple GPIO pins. Hooking up the display requires 5 data pins on the Maple.
Here's a quick "Hello World" example:


The sketch for this is pretty simple too:

/*
 LCD_Nokia3310 Library - Hello World
 
 Demonstrates the use a Nokia 3310 or 5110 LCD display.  
 These displays are are 48x84 pixel monochrome serial displays
 
 If an 8x6 pixel font is used, characters are arranged in 6 lines x 14 characters
 This sketch prints "Hello World!" to the LCD
 and also the number seconds since the program was started
  
 The circuit:
 * LCD CS pin to digital pin 8
 * LCD reset pin to digital pin 7
 * LCD mode pin to digital pin 6
 * LCD clock pin to digital pin 5
 * LCD data pin to digital pin 4
 * LCD LED pin is connected to 3.3V
 */

#define LCD_PIN_CS 8   //digital Pin 8
#define LCD_PIN_RST 7
#define LCD_PIN_DC 6
#define LCD_PIN_SCK 5
#define LCD_PIN_DATA 4   //digital Pin 4

// include the library code:
#include <LCD_Nokia3310.h>

// initialize the library with the numbers of the interface pins
LCD_Nokia3310 lcd(LCD_PIN_CS, LCD_PIN_RST, 
                  LCD_PIN_DC, LCD_PIN_SCK, LCD_PIN_DATA);
uint8 x;

void setup() {
  lcd.init();
  lcd.setCursor(0,0);
  lcd.print("Hello World !!");
  x = 0;
}

void loop() {
  
  lcd.setCursor(0,2);
  if (x==0)
  {
    lcd.print("<= LCD Demo =>");
    x++;
  }
  else
  {
    lcd.setCursor(3,2);
    lcd.printInverse("LCD Demo");
    x = 0;
  }
  
  // set the cursor to column 0, line 5
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 4);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);   
  
  delay(1000);
}



The current display library does not implement a display buffer in RAM, so it's mostly useful for displaying fonts. But it's a nice tool to have for displaying textual data with a Maple.

Friday, January 28, 2011

Hardware - 32-bit Microprocessor boards

Sometimes more processing power is needed than you can get from an 8-bit Processor like the ATmega chips, e.g for audio processing, flight-controllers, networked scenarios. In those cases, stepping up to a 32-bit processor can be the solution. One processor architecture that is becoming popular with hobbyists are the ARM Cortex-M3 processors, the STM32F103 series from ST being one example of these.

Here are a few boards with STM32 processors:
This is the "Maple" boards from LeafLabs. It features an STM32F103RBT6 processor with 128KB of Flash and 20 KB of RAM. LeabLabs also provides and IDE and bootloader for this board as well as an arduino-style programming language which make this board a great choice to get started with 32-bit processor programming. It's also physically compatible with the Arduino, so Arduino shields can be plugged into the board.

This is another board featuring the STM32F103RBT6 processor, this one is by ITeadStudio and is called IFLAT-32. A JTAG programmer is needed to program this board, so it requires a bit more hardware to get started. On the plus side, it contains different peripherals like an RTC crystal, battery holder, MicroSD slot, and headers for Arduino shields and the popular XBee modules.

The processor manufacturer STMicroelectronics together with french development tool maker Raisonance also releases some development kits for getting started with STM32 programming:

This is their latest product, the "EvoPrimer" (aka. OPEN4) with a target board featuring the STM32F103VET6 processor (512KB Flash, 64KB RAM). The advantage is that this is a self-contained product with some of the most useful peripherals already built-in: LCD touch-screen (320x240), 3-axis accelerometer, joystick, audio DAC/codes, rechargeable battery, IR sender/receiver, some LEDs. It also has a programmer built in so it can be programmed directly through the Mini-USB port. Another feature is an Extension port which allows access to additional IO lines and modules of the processor (SPI, I2C, USART). There is a pretty active developer community at stm32circle.com, and the guys from Raisonance are very good answering questions in the forum.

Thursday, January 27, 2011

Hardware - 8-bit Microprocessor boards

I started out with the very popular Arduino platform, which is based on Atmel's family of 8-bit Microprocessors. It's pretty easy to get started, just get one of the boards, download the IDE, dust off your C++ skills and go.

Besides the original "Arduino" branded boards, there are quite a lot of Arduino-compatible boards out there, some share the same pin-out and footprint, while others look completely different but can still be programmed with the Arduino IDE.

This is an Arduino-compatible board (Freeduino).


Here is another one that I soldered from a kit, it also uses the ATMega328 chip (32KB Flash, 2KB RAM).


If you need more I/O pins or more Flash/RAM, there is the Arduino Mega, based on the ATMega1280 chip (128KB Flash, 8KB RAM).


This is the so-called Sanguino, using the ATMega644P chip (64KB Flash). No longer pin-compatible with the original Arduino, but can be programmed using the Arduino IDE.


Here we have a "Bare-Bones Board" sold by ModernDevice.com which can also be programmed using the Arduino IDE (a Serial adapter is needed though).


Finishing up the round-up is an Arduino-compatible board for 40-pin ATMega chips (e.g. ATMega644, ATMega1284P)