• 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: , , , , ,

  • Just a small update on the status of the DIY CPU:

    The circuit design of the main CPU components is completed. The layout was split up in six parts :

    • ALU and Shifter
    • Index Registers
    • General Purpose Registers and Program Counter
    • Flags
    • Clock and External Bus I/O
    • Microcode Sequencer

    Each part occupies an 160x100mm circuit board. The boards are interconnected with pin headers to provide access to the internal data and address bus and to distribute the clock signal.

    DIY CPU PCB Layout

    DIY CPU PCB Layout

    Parallel to the layout the circuit was constructed in a simulation tool to test correct function. To fill the microcode storage with meaningful code, a Delphi program was written to generate the microcode sequences for the opcodes.

    DIY CPU Microcode Generator

    DIY CPU Microcode Generator

    This program was used to implement the microcode for a few basic opcodes which were then used to write a small assembler program that calculates the fifth fibonacci number (see screenshot).

    I’m currently working on some other projects to get some distance from the CPU. This helps to spot errors when looking over it a few weeks later. Then a few additional circuit boards for data I/O and storage/RAM will have to be designed.

    Tags: , , ,

  • This is the first post of a larger project, in fact, the largest of my projects so far: To build a 16bit CPU from 74HC chips. Now you may ask “Why?”, and then I might reply “Because (I think) I can!”. I just like circuits which are relatively simple in each part but rather complex as a whole. A CPU is the perfect example for a structure which is comprised of many simple parts which have to work in perfect synchronicity.

    This post is intended to give an overview over the main features and specs which will define the structure of the CPU. The implementation of each unit will be detailed in future posts.

    The following attributes are defining for the overall structure of the CPU and were either determined in advance or during the planning phase:

    • 16bit data bus
    • 16bit address bus
    • Four 16bit general purpose registers
    • Four 16bit special purpose registers
    • Each general purpose register can be accessed bytewise
    • 16bit program counter
    • Internal structure microcode controlled
    • Max. 127 microcode steps per instruction
    • Fully static design down to 0Hz
    • 16bit instructions (8bit Opcode, 8bit Parameters)
    • 8bit flag register
    • One external interrupt
    • 256 interrupt vectors
    • 64bit wide microcode instructions

    The microcode approach was chosen because of its simplicity and flexibility over a combinatorial logic design, despite being slower. If an instruction is to be added, changed or removed, this is simply a matter of reprogramming the microcode storage instead of rewiring a whole lot of chips. In the circuit, the microcode is just a number of cascaded memory chips (SRAM or EEPROM) with each data output pin wired to a control pin of one part of the CPU. Each instruction walks through a specified number of addresses, which in turn output a previously programmed sequence of data bits that control each part of the CPU to be active at precisely the right moment. For example, one data bit could be wired to the output enable of a register A and another data bit to the load enable of a different register B. If those to bits were to be active in the same clock cycle, the data from register A would by copied to register B.

    After planning all parts of the CPU with all their control inputs the number of necessary microcode bits added up to 62. The nearest multiple of 8 being 64, I used eight EEPROMs with an 8bit data interface and 16bit address bus. Their outputs will control and coordinate all other units of the CPU, each of which will get its own post:

    Overview of Internal Structure

    Overview of Internal Structure

    • Microcode storage and microcode counter with jump conditions
    • General Purpose Registers with read and write logic
    • Special Purpose Registers with read, write and counter logic
    • 16-bit ALU and 16-bit Shifter with flag calculation, input and output control
    • Flags register with read, write and set logic
    • Program counter
    • External bus interface

    At the time of writing this post, the design has been almost completed, so the specifications are unlikely to change significantly.

    Tags: , , ,

  • While experimenting with flyback transformer circuits I found a simple induction heater circuit and decided to give it a try.

    Induction heating uses a high frequency electromagnetic field to induce eddy currents in a piece of conductive material. The current and the resistance of the material lead to ohmic heating. To generate the high-frequency field a self resonant oscillator is used. The circuit mainly consists of two MOSFETs, a tank capacitor and a center tapped coil.

    Circuit Schematic

    Circuit Schematic

    For a detailed description of the circuit operation see the source page.

    I did not make a PCB for this circuit but instead soldered it on a piece of perfboard. This is not optimal in regard to trace resistance because the solder has about 7.5 times the specific resistance of copper, but it works ok. An improvement would be to solder some thick copper wires between the components.

    Induction Heater

    Induction Heater

    My circuit resonates at approx. f=115 kHz (no load inside the coil). With a capacitance of C=440 nF the inductance L of the coil can be calculated by the following formula

    Induction Formula

    to be approx. 4.3 µH.

    With an input of 15 V at 660 mA the voltage over the coil is 92 Vpp.

    Voltage across the Coil

    Voltage across the Coil

    Heating a bolt or nail to a red glow takes about 5 minutes with an increased current draw of approx. 3 A.

    Nail heated by Induction

    Nail heated by Induction

    Tags: , , ,

  • This happens when you use a capacitor which is not rated for the applied voltage:

    Exploded Electrolytic Capacitor

    Exploded Electrolytic Capacitor

    Tags: , ,

  • After the first attempt to build a Tesla Coil failed 10 years ago I finally fulfilled this childhood fantasy. Remembering the problems of obtaining high voltage capacitors and the like I went for the Solid State (No big capacitors and spark gaps, just transistors) approach this time. Not being the most skilled person when it comes to analog, and especially high frequency, circuits I started searching on the Internet. The design had to meet some requirements: It should run on a DC power supply (i.e. not mains power) and not need any exotic parts.

    Sectional Drawing of the Tesla Coil

    Sectional Drawing of the Tesla Coil

    I finally settled for a circuit from this site (Mini Tesla Coil 3) and made my own PCB layout. This was the first PCB I made using a laser cutter to transfer the layout to the board. A blank copper-clad board was sprayed with two layers of black paint which was then etched away by the laser cutter. To completely burn away the paint the same image was lasered several times on the highest power. Afterwards the board was etched with HCl/H2O2.

    The circuit uses an LC filter which has to be tuned to the resonant frequency of the secondary oscillator circuit.  (If you choose to use it. I found that the circuit works just fine with out it. Apparently it is only necessary to filter any unwanted oscillations.) To measure the resonant frequency, connect a function generator to the lower end of the secondary coil and set it to a square wave output with 50% duty cycle. Then place a piece of wire parallel to the coil and hook it up to an oscilloscope (Also connect the grounds of function generator and oscilloscope.) Now increase the frequency of the square wave until you see a sine wave on the oscilloscope. When the sine wave has the biggest amplitude, you have found the resonant frequency. With a 9 Vpp square wave I measured a sine wave of about 90 Vpp. You have to do this procedure twice. Once with the topload and once without.

    With the frequency you can now calculate the necessary values for the inductor and capacitor via the formula

    Resonant Frequency

    Use available values to approximate your frequency as closely as possible.

    The secondary coil has 1200 windings and was wound with 0.15mm enamelled copper wire on a Ø75mm PVC drain pipe. At each end the thin copper wire is routed to the inside of the pipe through small holes and soldered to a thicker wire. The holes are then sealed with hot glue. The pipe is mounted to a wooden base which also holds the posts that hold the primary coil. The Topload Capacity is a stainless steel ball which was sold as a home decoration item.

    The primary coil is wound from Ø1mm copper wire. In my case it has about 8 windings of which a section can be selected with wire clamps. This makes quick adjustments possible. The driver circuit has four connections to the coils. One leads to the bottom of the secondary coil and is used as a feedback to measure the oscillations and drive the primary coil accordingly. This is done with the remaining wires. Voltage is applied alternately between wires 1-2 and 2-3 thus doubling the effective amplitude over the primary coil.

    Tesla Coil and Driver Board

    Tesla Coil and Driver Board

    Here are some photos of sparks I made with my coil. You can generate quite interesting effects with light bulbs and other things filled with thin gas.

    Tesla Coil sparking to my Finger

    Sparking to my Finger

    Discharges in Lightbulb

    Discharges in Lightbulb

    Discharges in Lightbulb

    Discharges in Lightbulb

    Discharges in Lightbulb

    Discharges in Lightbulb

    approx. 10cm Sparks

    approx. 10cm Sparks

    Tags: , ,

  • After building a flyback high voltage supply, which I will describe in a later post, I was experimenting with putting the electrodes into thin glass tubes. This produced much longer arcs due to the concentration of the ionized air.

    To get an even better result, I tried evacuating the tubes with a syringe.  To seal one end of the tube I placed a thick wire in one end and put a drop of hot glue around it.  Over the other end I put a piece of PVC hose and pierced the wire through it into the tube. The entryhole was also sealed with hot glue. To ensure a tight seal some air is sucked out of the tube while the hot glue is still liquid.  This way the glue fills the holes.

    Tube with sealed Electrodes

    Tube with sealed-in Electrodes

    As the glass tubes only have a volume of about 5ml and the syringe 65ml, one pull reduces the pressure inside the tube from 1bar to about 0.05bar. (p*V = const.)

    When the voltage (between 20kV and 30kV) is applied to the electrodes, a continuous channel of violet (the photo does not reproduce the color correctly)  nitrogen plasma is formed inside the tube. The plasma quickly heats the glass and the hot glue, so don’t apply the voltage too long or the seal will break. Magnetic fields will deflect the plasma channel.

    Plasma Channel deflected by magnetic Field

    Plasma Channel deflected by magnetic Field

    These small tubes quickly got boring, so I decided to make a bigger version with a Ø30mm L=100mm plexiglas tube. To seal of the ends, I turned caps on the lathe. The caps were then fitted with a hole for the electrodes and a hose connection. The holes around the electrodes are again sealed with hot glue. To get the caps airtight, o-rings were used.

    To get a low enough pressure inside the tube, the syringe has to be pulled several times. Between each pull, the tube has to be closed. This is achieved with an electric valve.

    Cap with O-Ring

    Cap with O-Ring

    Tube with Cap and Hose

    Tube with Cap and Hose

    When the pressure inside the tube is low enough and the voltage high enough, a glowing channel of plasma will form. Due to the heat it generates in the residual air, it will bulge upwards. This will heat the tube and slowly melt the plexiglas. The plasma stream can be deflected with strong magnets or by influencing the electrostatic field around the tube, i.e. by placing your fingers near or on the tube.

    Plasma Channel in Discharge Tube

    Plasma Channel in Discharge Tube

    Plasma Channel in Discharge Tube

    Plasma Channel in Discharge Tube

    With one of the smaller tubes I put a drop of ethanol (C2H5OH) inside the syringe before pulling the air out. This produced a thin ethanol vapor inside the tube and caused the plasma to glow blueish-white instead of violet.

    Blueish Glow from Ethanol Atmosphere inside the Tube

    Blueish Glow from Ethanol Atmosphere inside the Tube

    Tags: , , ,

  • Due to university and work it has been a while since the last post. But I just completed a little project that’s worth posting.

    32kHz Oscillator

    32kHz Oscillator

    Several old 27C256 EPROMS were lying around unused. So I thought about a purpose for them. As I also had some 8×8 LED matrices, a little animated display came to mind.
    With each frame consisting of 8×8 pixels the 32kByte EPROM can hold 4096 frames. Each byte holds one line of the display, eight bytes one frame.

    The lower 3 addressbits of the EPROM have to by switched synchronously with the corresponding line on the display. This is achieved by wiring them to a 3-to-8-decoder (74*238) which in turn switches the lines. As up to eight LEDs can light up at once per line. To handle the current an ULN2308A darlington driver is used.

    The columns are directly controlled by the data-output of the EPROM. To drive the LEDs a 2N2907 transistor is used.

    The clock is generated by a crystal oscillator circuit consisting of a 32768 Hz crystal and an inverter gate.

    The 32kHz squarewave from the oscillator is then divided by a 12-stage ripple counter (4040). The seventh to ninth stage are used for the line-addressing and are wired to the A0-A2 inputs of the EPROM and to the A,B,C inputs of the 74*238.

    The next three stages are connected to a DIP-switch. The output of the switch leads to the clock input of another 4040. This way the frame-rate is selectable from 32fps, 16fps and 8fps.
    Only fourteen addresspins of the EPROM are used, the fifteenth can be set to high or low via a jumper.

    Logic Section of the Display Schematic

    Logic Section of the Display Schematic

    I wanted the whole circuit to fit under the LED matrix, but unfortunately the EPROM is slightly bigger, so the circuitboard protrudes about 3mm on the left and the right.
    Apart from the LEDmatrix and the EPROM only SMD components were used on the two-sided PCB. The layout is rather dense and 0.3mm vias were used. Originally i wanted to etch the PCB myself, but quickly gave up that plan when the opportunity to let it manufacture for free together with other boards arose.

    EPROM Display PCB

    EPROM Display PCB

    EPROM Display PCB with EPROM

    EPROM Display PCB with EPROM

    EPROM Display LED Matrix

    EPROM Display LED Matrix

    In the pictures above you can the bottom side of the populated PCB with one of the 4040’s, the 74*238, the crystal (the little golden thing), the DIP-switch and the EPROM-socket. In the next picture, the EPROM is inserted and on the last picture the LED-Matrix is lighted with some random data that was stored in one of the old EPROMs.

    You can download the schematic and the board-layout (for EAGLE) here.

    EPROM Display Program

    EPROM Display Program

    To easily generate data for the display, a small program was written in Delphi. You can draw each image on the 8×8 field and save the sequence of images to a binary file that can be directly programmed into the EPROM.

    The source-code can be downloaded here.

    Tags: , , , ,