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

  • Chemistry 17.05.2013 No Comments

    Another little chemistry project: Photographic prints using the cyanotype and salted paper process.

    Cyanotype

    Cyanotype Print

    Cyanotype Print

    The cyanotype process (or blueprint) is used to produce blue contact prints from transparent negatives. The blue color is the water insoluble pigment Iron(II,III) hexacyanoferrate(II,III) which is normally produced by reacting an Iron(II) salt with a ferricyanide salt or a Iron(III) salt with a ferrocyanide.

    To make photographic prints, the reaction has to be catalyzed by light. This is done by utilizing a light sensitive compound which releases Iron(III)-Ions upon exposure. The original cyanotype process uses an Ammonium iron(III) citrate solution, which has several disadvantages. An improved process[1] replaces the citrate with Ammonium Iron(III) Oxalate, which can be produced from simple chemicals in a two step synthesis.

    Synthesis of Ammonium Iron(III) Oxalate

    In the first step oxalic acid reacts with ammonia to form ammonium oxalate:

    Ammoniumoxalatsynthese

    Oxalic acid has a molar weight of 90.04 g/mol but is a dihydrate (two water molecules attached to each acid molecule) which results in a molar weight of 126,10 g/mol. Ammonia has a molar mass of 17,03 g/mol and was available as a 25% (13.4 Mol/L) solution which has a density of 0.91 g/mL. Those numbers allow to convert the molar ration of 1:2 to a weight ratio of 1 g : 1.35 g. I used 1.77 g of oxalic acid and 2.3 g ammonia solution. To react, the oxalic acid is added to the ammonia solution. The resulting solution is evaporated and the remaining solid ammonia oxalate monohydrate is collected. Ideally, it should weigh 2.00 g (14.04 mmol).

    The next step converts the Ammonium Oxalate to Ammonium Iron(III) Oxalate with the help of Iron(III) Chloride. As both reactants are solids, solutions have to be prepared.

    Ammoniumoxalatoferratsynthese

    Ferric chloride has a solubility of 920 g/L, while of the oxalate only 45 g will dissolve in 1 L of water. Having produced 14.04 mmol of the oxalate, we need to add 4.68 mmol of the chloride. When weighing the substances, the fact that Fe3Cl is a hexahydrate, has to be kept in mind. The molar mass of 162.21 g/mol has to be corrected to incorporate the mass of six water molecules, resulting in mass of 1.26 g. The 2.00 g of oxalate and 1.26 g of chloride are dissolved in 44.34 mL H2O and 1.37 mL H2O respectively.

    Vial of Ammonium Iron(III) Oxalate

    Vial of Ammonium Iron(III) Oxalate

    The solution, which should be of a light green color, now contains 2.00g or 4.68 mmol of Ammonium Iron(III) Oxalate and 14.04 mmol of Ammonium Chloride. Unfortunately, I could not come up or find a reaction to separate the two components. But I later verified, that the Ammonium Chloride has no negative effect on the print process.

    Preparing the Sensitizing Solution

    The sensitizing solution is later applied to a piece of paper to make it sensitive to light. It contains three parts Ammonium Iron(III) Oxalate and one part Potassium hexacyanidoferrate(II) by mass.

    The previously prepared 2.00 g of oxalate are added to 2 mL of water, heated to approx. 50°C and stirred until dissolved. In a second container, 0.67 g of Potassium hexacyanidoferrate(II) are added to 1.2 mL of water, heated to 70°C and stirred until dissolved.

    Subsequently, the two solutions are mixed together while continuously stirred. The solution is then filtered, filled up with water to a volume of 12 mL and, after it has cooled, stored in a dark place.

    Preparing the Paper and Making the Print

    The sensitizing solution should be stored in a dark place until needed. It can be applied to paper by placing a few drops on the sheet and dragging them over the surface with a glass rod. This is best done with minimal lighting. When the paper has soaked up the solution evenly, it is hung up to dry.

    The negative can be printed on sheets of overhead transparency. For best results, the image should be black and white and printed with high toner density.

    The dry sensitized paper is attached to the negative and then exposed either by sunlight or by ultraviolet light. I produced good results with UV tubes from a tanning lamp (which I also use to expose circuit boards). The exposure time is about 10s-20s with UV light. With sunlight, you can see that the exposure is finished, when the transparent areas of the negative have sufficiently darkened.

    To finish the print, the paper is rinsed with tap water until all green/yellow color is washed out and a blue and white image remains. After drying the paper, the print can be framed.

    Salt Print

    The salted paper process uses different chemicals and a different method to sensitize the paper. While the cyanotype is based on iron, the salted paper uses silver in the form of silver chloride. This salt is sensitive to light and decomposes to black elemental silver upon exposure. This results in a brown and white image.

    Preparing the Paper

    As the name implies, the paper is treated with a Sodium Chloride solution (2 g NaCl per 100mL water). After the paper has been soaked in the solution, it is dried. Meanwhile, a solution of silver nitrate is prepared (1 g AgNO3 per 10mL water). All steps involving the silver have to be carried out in a dark room to not expose it prematurely.

    The silver nitrate solution is then spread over the salted paper using the same method as with the cyanotype sensitizing solution. When the silver nitrate comes in contact with the sodium chloride in the paper, it reacts to sodium nitrate and the light sensitive silver chloride:

    Silberchloridsynthese

    The exposure follows the same procedure as with the cyanotype. Afterwards, the print has to be fixed to inhibit the further exposure of silver chloride. Due to the very low solubility of silver chloride in water rinsing is not enough.

    Instead, the print has to be soaked in a mixture of sodium thiosulfate, ammonia and water (10:2:100 ratio by weight). The print is soaked in this solution for about 15 min until all the unexposed silver is removed.

    The finished print can then be rinsed, dried and framed.

    Salt Print and Cyanotype

    Salt Print and Cyanotype

    Choosing the Paper

    The right paper plays an important role in making a good looking print. Standard printer paper does not take up the solution very well and wrinkles when drying. I had good results with index cards and water colour paper.


    [1] : The New Cyanotype Process (http://www.mikeware.co.uk/mikeware/New_Cyanotype_Process.html)

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

  • Chemistry 15.05.2013 No Comments

    A few years ago I saw a video about ferrofluid on YouTube. A ferrofluid or magnetic fluid is a stable suspension of magnetite nanoparticles which reacts to magnetic fields in interesting ways. Naturally, I wanted to make some ferrofluid myself.

    There are three easy ways to produce Magnetite (Iron(II,III)-oxide, Fe3O4), at least that I know of. Both are based on the precipitation of an iron salt in an ammonia solution. The first [1] uses Iron(II)-chloride and Iron(III)-chloride as precursors whereas the second[2] uses Iron(II)-sulfate. The third, the one I tried, is explained in this YouTube Video.

    Synthesizing the Precursors

    All three iron precursors are easy to manufacture by dissolving iron wool in hydrochlorid acid and sulfuric acid, respectively.

    Fe+HCl

    Solutions of Iron(III)chloride and Iron(II)chloride

    Solutions of Iron(III)chloride and Iron(II)chloride

    Iron(II)chloride turns to Iron(III)chloride when left in contact with air for some time. The conversion from Iron(II)- to Iron(III)-chloride can be greatly accelerated by adding the oxygen in the form of hydrogenperoxide. The iron wool and the acid is weighed to produce an approximately known concentration of the products.

    Producing the Magnetite

    After the iron has completely dissolved, the solutions are filtered and then then mixed together in a 2:1 ratio of Iron(III)chloride to Iron(II)chloride. This mixtured is then added to a 25% solution of ammonia. The magnetice particles will start to fall out immediately and colour the solution a dark brown or black.

    Preparing the Suspension

    The video instructions said to boil the excess ammonia off and then add oleic acid which should act as a surfactant for the magnetite particles. Unfortunately, this step did not work for me. The particles did not bind to the oleic acid and repeatedly settled on the bottom of the flask when trying to dissolve the resulting black goo in kerosene.

    Perhaps one of the other to methods or using a different surfactant will produce better results in the future.


    [1] : Synthesis and Some Physical Properties of Magnetite(Fe3O4) Nanoparticles (Int. J. Electrochem. Sci.,7 (2012)5734 – 5745)

     

    [2]: Room Temperature Synthesis of Magnetite (Fe3-δO4) Nanoparticles by a Simple Reverse Co-Precipitation Method (IOP Conf. Series: Materials Science and Engineering18(2011) 032020)

     

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