Showing posts with label OLED. Show all posts
Showing posts with label OLED. Show all posts

Saturday, December 29, 2012

chipKIT

I recently picked up the chipKIT Max 32 and Basic I/O Shield.  My main interest was seeing whether we might possibly take advantage of the Arduino ecosystem.  There are literally hundreds of "shields" for Arduinos. The idea is that the board with the microcontroller has relatively few peripherals, and the experimenter can plug together a number of simple boards each with its own set of peripherals.


chipKIT Max32

chipKIT Max32
The Max32 has a PIC32MX795F512L which is quite an impressive part:
  • 80 MHz
  • 512K FLASH
  • 128K RAM
  • 16 Channel 10bit A/D
  • USB 2.0 OTG
  • 6 UART
  • 4 SPI
  • 5 I2C
  • 2 CAN
  • 10/100 Base T

The Max32 board also includes a USB to serial converter, 3 and 5 volt supplies, and 5 LEDs: 1 for power, 2 for USB send/receive and 2 connected to PIC digital I/O pins.  Power can be provided through the OTG USB connector, through the PICkit connector (not populated) or through a coaxial power connector.  Power provided through the connector can be regulated 5 volt or unregulated 9-15 volts.

83 PIC I/O pins are brought out to connectors on the board.

The Max32 connects to the PC via an OTG USB cable.  This has a standard Type A USB connector on the PC side, and a mini-USB on the Max32 side.  The mini-USB looks annoying similar to the ubiquitous micro-USB commonly used for cell phone chargers.  It is more or less standard for OTG USB, however, and is the cable used for the Beagle Board and PICkit, among others.


Basic I/O Shield

Basic I/O Shield
The Basic I/O Shield connects to the Max32 (or the smaller Uno32 or UC32 boards) through 4 connectors.

LED connected to OC1
The board includes 4 pushbuttons, 4 slide switches, 8 LEDs, a 32x128 pixel OLED display, a potentiometer, a temperature sensor and an EEPROM.  4 of the PIC32's output compare pins are brought to screw terminals on the board edge.  Another 4 screw terminals connect to those same OC pins through FETs.  A final two screw terminals connect to board ground and power for the four FETs.  A jumper allows for the Max32's power to connect to the FETs instead.

I2C connection
The EEPROM and temperature sensor are I2C devices.  The Basic I/O Shield's I2C connections don't line up with the Max 32's I2C connections, apparently because the Max32 matches the Arduino Mega format.  This means to use the temperature sensor or EEPROM the user must add two wires for the I2C connections.




Programming with MPIDE

MPIDE
 There exists an Arduino compatible programming environment, MPIDE, which can be used to program the PIC32 without the need for an external programmer.  The PIC32 comes preloaded with a bootloader which communicates over USB to MPIDE.

The environment is a clone of the Arduino environment, and most Arduino sketches run without modification.  MPIDE also includes a serial monitor, so serial data may be sent from the PIC and observed within MPIDE.

There are libraries for the various Basic I/O Shield peripherals in addition to the standard Arduino libraries, so using the temperature sensor, EEPROM or OLED display is a simple matter of making the appropriate library calls.  Of course, the switches, buttons, LEDs and potentiometer use the standard read/write digital or analog calls.

The compiler is quite slow, apparently because libraries are compiled on the fly.  Programming over the serial connection to the bootloader is also relatively slow, so development is relatively slow business.  In addition, there is no in-circuit debugging capability, although the readily available serial connection relieves this somewhat.

Although the environment uses normal Arduino calls, standard PIC references are available as well.  Of course, this would mean that the sketch would not be compatible with an Arduino.  But instead of
  digitalWrite( PIN_LED1, HIGH);
one could say
  _LATC1 = 1;
This doesn't seem like much of a difference either way, but consider setting several pins of a port to outputs:
  pinMode( 17, OUTPUT );
  pinMode( 38, OUTPUT );
  pinMode( 58, OUTPUT );
  pinMode( 59, OUTPUT );
versus
  TRISA &= 0xfff0;
(the Arduino commands reference pin numbers on the board, rather than anything related to the port).


Programming with MPLAB-X


PICkit 3 and Max32
PICkit clearance
The Max32 includes pads for a PICkit connector.   This is a simple, 6 pin, 90 degree header.  When this is installed the normal MPLAB-X techniques may be used with the board. 

This is considerably faster and allows for debugging.  If the developer wishes to return to using MPIDE, the bootloader must be reprogrammed using the PICkit, a rather simple process. When using the PICkit, there is not enough clearance to use either the OTG USB port or the coaxial power connector, so the circuit must be powered by the PICkit.



Programming Comparison

 It isn't clear to this writer that programming with MPIDE is any easier than with MPLAB, however, the small size and lack of features of MPIDE make the process less intimidating.  This is emphasized by the small size of the boards and the simplicity of simply having the board connected to the PC with no power cables, no programmers, no external additions.

In MPIDE, the user provides two functions, setup() and loop().  The main() function is provided by the frameworks.  While this fits the overwhelming majority of applications, it is somewhat limiting in some situations.  Nonetheless, it does provide some structure for the new developer.

Although the documentation claims that the environment uses C, there are some C++ features.  Some libraries, for example, are provided as classes so the user must instantiate the class in order to use the library.   Most of the standard functions, tho, are C functions, so attempts to use other C++ features could result in unnecessary complication.

The IDE places the user projects, or "sketches",  in a "sketchbook".  The sketches are easily available from the menu, making it quite convenient when small number of projects are available.  Many examples are also available from the menu, so it is easy to find examples when the programmer doesn't remember how some function is used.


Hardware Compatibility

The shields connect together through standard, wire wrap 0.1" spacing sockets.  However, the power connector is offset slightly from the other connectors, making it inconvenient to use standard 0.1" protoboards.  There are shield protoboards available, but that adds significantly to the cost of experimentation.

The PIC32 is a 3.3 volt device.  Most Arduinos are 5 volts.  All of the PIC32 pins are 5 volt tolerant, but the outputs probably won't provide sufficient voltage for most Arduino peripherals.


Overall Impressions

The Max32 is a very nice development platform.  The PIC32MX795F512L is an amazingly competent part with stunning speed and huge memory.  Programming is virtually identical to the dsPIC/PIC24 families.  The Basic I/O shield provides a range of peripherals that allow for significant experimentation, and the FETs allow for connection to motors, relays or other high energy devices.

However, the 3.3 volt format limits access to many devices, especially most Arduino shields.  The graphics OLED is a very nice (if tiny) display to play with, but in a purpose-built circuit the experimenter will almost certainly prefer an LCD, and there is no facility to learn this peripheral.  The particular display chosen does not seem to be widely available so that option is probably closed to the developer as well.

The cost, however, is attractive.  Including the OTG USB cable both boards plus cable come in at under $90 at the current time.  Most of the benefit could probably be gotten with the Uno32, saving about $20.  The Uno has considerably less memory and fewer I/O pins (42 vs. 83).  The Uc32 provides an intermediate step, combining the smaller size and fewer I/O pins of the Uno with the large memory of the Max, for an intermediate price.

All in all, a fun development environment, and not a bad way to break into microcrocontrollers, providing the user recognizes the limitations.

Tuesday, December 18, 2012

Displays

For some time now I have had almost an obsession with LCD displays.  In the past, there was a wide range of displays with a wide range of prices, generally more characters being a little more expensive, backlit displays being very expensive.

The most common backlight was the sickly, yellow-green LED backlight, which not only looked bad, but tended to be a real current hog.  Electroluminescent backlights were available, but they tended to require unfortunate voltages; typically AC and somewhere in the 60 to 400 volt range, not generally what we have lying around on a microcontroller project.

More recently, white LED backlights which are far more efficient have become available.  And, they have become a lot less expensive.  It seems as if a white backlight is often available for close to the cost of a non-backlit display, and while a yellow-green backlight may take almost an amp, the white ones tend to be in the 20 mA neighborhood.

N8ERO picked up some Newhaven negative displays which show white letters on a blue background.  I had seen these before, or something similar, on some FDIM projects, and while they don't look as nice as their pictures, they do look a lot better than the ugly green.

LCDs exhibit two kinds of slow.  The processor on the LCD takes some time to do it's thing, so code either has to delay or read the LCD's busy signal.   Reading the busy signal is kind of a pain, so most hobbyist projects simply wait long enough.  The actual display itself is a chemical change, so compared to electronics, it is very slow.  A result of this is that there it rarely a real penalty for waiting far longer than necessary for the display's processor to do it's thing.

However, in experimenting with different displays, it appears that negative displays are slower, as are 3 volt displays.  In the case of the blue Newhaven display, part of this slowness results in some rather ugly brown artifacts when the display is changing.

I found a blue, positive Newhaven display that was very inexpensive, but 3 volts.  3 volts is pretty handy for PIC24, PIC32, or dsPIC33 projects, not so much for the more common 5 volt projects.  This display is quite small, something that is also sometimes nice.  LCDs tend to take a lot of the panel space, and depending on the project, having a 20x2 display in a small space is an advantage.  However, small also means that the connections to the part are different than most LCDs, and kind of a pain.





Well, with LEDs now available in umpteen colors, and plummeting in price, it couldn't be long before someone came up with a display with an RGB backlight.  I picked one up, the price, while a little high, wasn't crazy.    This display is, interestingly, a 3 to 5 volt display.  Unfortunately, the 3 volt part means it is slow, and the negative display, which looks a lot nicer, makes it even slower.  This is a pretty slick choice for projects that have a display that mostly isn't changing.

More recently, displays based on organic LEDs have become available.  OLEDs have the advantage of very nice contrast, high speed, and relatively low current compared to backlit displays.  This particular OLED display has both the traditional 4 or 8 bit parallel interface as well as a serial interface.  I have to say, I think this one is my favorite.  It is slightly thinner than the LCDs, and the display is extremely crisp.  And it doesn't exhibit any of the shadow artifacts that LCDs tend to show when they are changing.

The one downside is that it appears to require that you use the busy flag.  While this is annoying, especially when using the 4 bit interface, once the code is written and wrapped in a library, that detail becomes invisible.  It is a little more expensive than an LCD, but boy is it nice.