• Every project needs some blinking LEDs. This one has 300!

    LEDs

    LEDs of the LED Matrix

    This 10×10 LED Matrix has 100 serially connected WS2812B LEDs which are controlled by an LPC11U24 microcontroller. The µC receives commands and image data from the PC via USB. The frame measures 400x400x35mm and is constructed from lasercut wood panels and holds without screws or glue. The grid dividers have been painted white to maximize light reflection. Initially I planned to cover the front with frosted plexiglas, but when I glued paper onto the grid during construction, the realized that it may look even better with a nice paper as the diffuser.

    The WS2812B leds came on a 2m long self-adhesive strip with 60 LEDs per meter. To mount them to the woodpanel, the strip was cut between each LED and attached to the wood. To bridge the gaps, 3 wired cable pieces were soldered to the LEDs in a serpentine layout.

    LED Matrix LEDs Closeup

    LED Matrix LEDs Closeup

    LED Matrix LEDs Closeup

    LED Matrix LEDs Closeup

    Controlling the LEDs is done via a one-wire serial protocol which is simple but has rather strict timing requirements. A one-bit is high for 0.8µs, then low for 0.45µs while the zero-bit is high for 0.45µs and then low for 0.8µs. To set the color of x LEDs, x * 3bytes are sent from the µC to the first LED in GRB order. The first LED takes the first three bytes and sets its three constant current sources accordingly. All following data is passed on to the next LED after the signal has been reshaped. This repeats for all LEDs on the line. To start over, the data line is pulled low for at least 50µs, after which the first LED is again ready to accept data.

    There are several ways to produce the required timing: If the µC is fast enough, one can just use delays of the appropriate length. If the µC is just fast enough, the delays have to be handcoded in assembler (see the Adafruit NeoPixel Library for reference). A third way uses the State Configurable Timer available in some LPC µCs (see this forum post on LPCware.com).

    My solution (adapted from this code on GitHub) uses the built-in SPI hardware of the LPC to generate the correct timing by setting the wordsize to 15bits and then transmitting

    • 111111111100000 for a one-bit
    • 111110000000000 for a zero-bit

    Image date is stored in a big array of 300 bytes and can be received by the µC via USB. Unfortunately, the maximum packet size of USB2.0 full-speed devices is 64 bytes. This means 5 packets are needed to transmit the necessary 300 bytes. I use the first byte in each packet to indicate which part of the image is contained in the following 60 bytes and then copy them to the appropriate position in the array. Additionally, a few commands to clear, refresh, fill or set individual pixels are implemented via USB control transfers (Commands are sent to Endpoint1 and image data is sent to Endpoint2.)

    LED Matrix Software

    LED Matrix Software

    LED Matrix

    LED Matrix

    On the PC side I wrote a little program in Delphi which uses libUSB-win32 to handle the USB communication. Using the program, one can paint each pixel, display 10×10 bitmaps or transmit a downsampled stream from the desktop (size and position are configurable). All image data can be gamma-corrected before transmission to ensure better color representation.

    Up until now, I concentrated on the software and used an LPCXpresso development board to test the code. Next I will design a small circuit board that can be placed inside the case of the display and make it a stand-alone unit.

    Future plans include some procedural effects generated by the µC (like plasma or fire), SD-card interface for automatic playback of images/videos and a bluetooth interface to stream image data from a PC or android phone.

    When the project has reached a point where the software is presentable, I will make it available here or in a follow-up post.

    Tags: , , , , ,

  • USB Display with different Brightness per Digit

    USB Display with different Brightness per Digit

    Last month I finally came around to order a lot of circuit boards that piled up over the last years. One of those boards was made to use some parts I just bought because they were on sale (the 16-segment LED digits) and a sample part I ordered just because I though it would be neat to have (the MAX6955).

    The MAX6955 from Maxim Integrated is an LED display driver for a combination of 7, 14 or 16-segment digits with up to 128 LEDs. The chip provides a font,  global or per-digit brightness control and two-speed blinking between two text buffers. Additionally, 32 switches in a matrix configuration can be scanned and debounced. To talk to the chip, the I²C-protocol is used.

    USB Display Software

    USB Display Software

    To control the display driver, an ATmega168 with the V-USB software USB stack is used. It is supplied with 3.3V and clocked at 12MHz (which is not possible, according to the datasheet, but works fine). Only four buttons were attached to the MAX6955 and placed on the backside of the PCB.

    At the moment, the PC-side software (which uses libUSB-win32) can send text and commands to the AVR which just passes them on to the MAX6955. In the future, I want to add a text memory on the AVR  so it can display and scroll messages independently from the PC. Maybe I will add some functions to dynamically vary the brightness of the digits to produce some cool effects.

    USB Display Backside

    USB Display PCB Backside

    I wanted the circuit board to be as small as possible, meaning it has the size of the eight 16-segment digits. All components were fitted between the pins of the display digits. To program the AVR, a card-edge ISP connector was used. To protect the circuit and to improve the contrast of the red LEDs a case was lasercut from red plexiglas.

    USB Display

    USB Display with Text

    You can download the circuit board layout (Eagle) here, the AVR firmware (C) here, and the software (Delphi) here.

    Tags: , , , , ,

  • Years of disassembling old printers and scanners yielded a lot of stepper motors which lay unused in a drawer for a long time. This was the inspiration to design a small and easy to use interface for a stepper motor. The first idea was to use the standard combination of the L293 motor controller and the L297 full bridge driver, but those chips take up a lot of space and do not provide microstepping functionality. A better option is an integrated stepper motor controller, like the Allegro A3984, which includes a microstep sequencer and the MOSFET bridge in a very small package. It can drive motors with up to 35V and 2.5A, which is enough for most small and medium stepper motors, especially those harvested from printers.

    To provide an easy interface, the motor should be controllable from the PC. This leaves an RS232 or an USB interface to connect to a microcontroller which in turn connects to the stepper motor driver. While there exists a (very good) software USB stack for the AVR microcontrollers, I chose the LPC11U24. After having worked with LPC microcontrollers at my job a lot, I was already familiar with the LPC11C24 and the lpcXpresso IDE.

    The LPC11U24 has an integrated hardware USB interface and a built-in USB bootloader which shows up as an mass storage device to the computer. Flashing a new firmware is as easy as dragging the binary file to the USB driver!

    Additional to controlling the motor via USB I wanted some methods of direct input on the motor. For that reason I added three buttons and a potentiometer on the circuit board. To connect limit or reference switches, some pinheaders are included. Three LEDs provide feedback from the LPC.
    As one motor is seldom enough to do something interesting, a way of connecting several motors together. My solution to this problem was to add a CAN-bus interface using the MCP2515 CAN controller and the MCP2551 CAN transceiver. The MCP2515 is connected to the LPC via SPI. The CAN bus and power connections (5V and motor power) are available on pin headers on each side of the PCB to make the controllers cascadeable.
    The A3984 provides an input for a reference voltage to control the motor current. An 10bit DAC (MCP4716) was added and connected to the LPC via I²C.
    The circuit board was designed to fit on the back of a NEMA17 (42x42mm) stepper motor.

    USB Stepper Motor Driver

    USB Stepper Motor Driver

    As of yet the USB communication is basically working and the motor is turning. The microstepping works quite well and the motor runs very fast and smooth. I have already implemented velocity ramping but apparently still have some calculation errors as the positioning is not exact. Software modules for reading the potentiometer and the buttons are completed, too. Sending and receiving CAN message is also working. The next step is to make the controllers talk to each other and to enable the master to discover other attached motors. After that the USB communcation has to be improved. In the end, the master should store a sequence of motion commands (maybe G-Code?) and control all attached motors.

    As a first test I used the motor to wind a coil for an electromagnet. I wrote a litte delphi program that sends commands via USB and constructed a frame from lasercut plexiglass to hold the bobbin.

    USB Stepper Motor Control Software

    USB Stepper Motor Control Software

    Coil Winding with Stepper Motor

    Coil Winding with Stepper Motor

    When the project is a little more advanced, I will publish the circuit board layout and the full source code for the firmware and the control software.

    Tags: , , , , ,