Flipping Back to Basics - Wiry Tetris

16 April 2016

It's been exactly 23 months since I started writing this post. I packed everything up when I moved house have only just unpacked my electronics stuff. I can't remember all that I was going to put in those posts so I'll aim to pick things up again in further posts as I remember them.

TLDR

The unfinished symphony

Expanding on my last post about controlling a single dot I wanted to control all 240 of them. As I'm writing this post with the everlasting wisdom endowed by hindsight it will mostly be a success story. I discovered that the Farnell trade counter is but 5 minutes from my house and so I was able to pick up appropriate components as needed. Free coffee makes it a worthwhile visit.

Shift Driving Sinks

Last time I used 4 transistors, 2 to drive current to the row and column, and 2 to sink current from the row and column. These are known as discrete components, each transistor is packaged individually. Scaling this up to 30 rows and 8 columns would result in 76 transistors and a very messy and unmaintainable circuit. Integrated circuits can help to reduce the clutter here by packaging an array of transistors up into a single package, tying the common leads together into a single pin.

The source drivers I'm using are Micrel 2981's, they have 8 outputs but each one is a lot more than a single transistor. Here's the schematic for a single output. Single output circuit in Micrel 2981

There are 8 of these in a package just 21mm long, which fascinates me even though I know there are much more densely packed components around. Unlike the discrete PNP transistors, which had to have the base (input) pulled low to allow current to flow, this circuitry means that taking the input high will enable current to flow. The integrated circuit takes the circuit from being analogue, with concerns about resistors and saturation points, to being digital, with concerns only about 1's and 0's. I like this, I can count to 1, I'm employed for my ability to do so.

The sink drivers are similar but with a few less components per pin, it's still taking an input high in order to enable the output and let current flow through it to ground. 8 outputs per package means I have to use 5 of each type, with a few outputs spare.

This takes care of the high current requirements of the display, I still have 76 inputs to address from the microcontroller. This is where those shift registers come into play that I mentioned a few posts ago. I found that I could use 3 outputs from the microcontroller to shift data into along a daisy-chain of these components to achieve as many outputs as required.

Toasted Chips

This worked, sometimes, I found that on occasion when powering it up nothing would happen but several of the driver chips would get a bit toasty. I'm not going to lie, I burnt myself a few times. Investigating the source of this problem I read in the datasheet that all unused inputs should be held high or low, rather than just floating, as the behaviour is otherwise undefined. My suspicion was that the outputs of some of the shift registers were enabled and causing short circuits between the drivers.

The shift registers have a pin to enable the output and connecting this to 5v, via a resistor, disables the outputs during power up. A fourth pin on the microcontroller can then be used to override this, pulling the output enable pin low, and enable the output of the shift registers.

Software

With Tetris being my end goal the display is going to be updating fairly regularly as pieces fall and rotate. I didn't want to be cycling through every dot each time to ensure it's in the correct state. This means only cycling through the dots that need to change state, which means keeping track of what the current state of each of them is. This is achieved by abstracting the hardware aspect, similar to a driver on a PC, and keeping track of the state within that. I have a Display class for this. The higher level application interacts with this by writing out its current display requirements into an instance of a Buffer class. The display then iterates through each dot in the buffer and compares it to its internal state. If it requires an update to the display it will make that change, otherwise it will move on to the next dot. Using this technique allows a fairly fast refresh rate of the display.

void Display::SetDisplay(const Buffer &buffer)
{
    for (uint8_t x = 0; x < 30; ++x)
    for (uint8_t y = 0; y < 8; ++y)
    {
        bool oldSet = frontBuffer.columns[x] & (1UL <<  y);
        bool newSet = buffer.columns[x] & (1UL <<  y);
        if (oldSet != newSet)
        {
            SetDot(x, y, newSet);
            frontBuffer.SetDot(x, y, newSet);
        }
    }
}

Flipping Back to Basics - Transistor Trickery

19 April 2014

After working out in my last post that I wouldn't be able to control these dots directly from a microcontroller I'm going to take a look at the PCB that's connected to it.

Using the continuity checker on the multimeter I can map the 70 pins on the display panel connector: 70 pin connections on display panel

The right-most 16 pins don't seem to be connected to anything.

I can also map the relevant pin connections on the attached PCB: Annotated PCB on the attached board

This looks like both the row positive and negative are managed on another separate board. The columns, however, are managed on this board. The 4 A2982SLW's on the right are the current source for the columns, meaning the 30 little 6-pin components on the left must provide some way to sink the current.

Both the current sources and sinks are switched from the shift registers at the top of the board. These shift registers are connected to one side of the 6 jumper pins at the top right. The jumper allows the main control board to address a column on any of the 3 display panels that make up the whole by sending the serial data over the correct pin.

Due to the rows being managed back on the main control board I can't interface purely with this board to control the dots. I'm going to change my approach slightly and build my own replacement to this board that will talk directly to the 70 pins on the display panel.

Transistors

A transistor, as I understand them, can be used to amplify current in a switch type manner. There are 2 types: NPN and PNP. NPN transistors are used to switch on the low voltage side of the load, whereas PNP transistors are used to switch on the high voltage side of the load. The load, in this case, will be the coil on each dot. I don't know why the 2 different types are used differently but I'm going to stick to this as it's what I've read.

They each have 3 connectors: emitter, base, and collector. When the base of an NPN transistor is connected to a positive voltage, it allows current to flow from the collector through to the emitter. Conversely, when the base of a PNP transistor is connected to ground, it allows current to flow from the emitter through to the collector.

With this in mind, the following circuit should be able to flip a single dot back and forth: Single dot circuit schematic

When switches A1 and A2 are closed, the dot should flip one way. Closing B1 and B2 should flip the dot back again.

I've built the circuit on a breadboard, replacing the 4 switches with 4 pins on a microcontroller.
Single dot circuit on a breadboard

Code

const uint8_t columnVcc = 1 << PORTD7;
const uint8_t columnGnd = 1 << PORTD4;
const uint8_t rowVcc = 1 << PORTD5;
const uint8_t rowGnd = 1 << PORTD6;

void resetPins()
{
    PORTD = rowVcc | columnVcc;
}

void on()
{
    PORTD |= rowGnd;
    PORTD &= ~columnVcc;
    _delay_ms(1);
    resetPins();
}

void off()
{
    PORTD |= columnGnd;
    PORTD &= ~rowVcc;
    _delay_ms(1);
    resetPins();
}

int main(void)
{
    DDRD = 0xFF;
    resetPins();
    off();
    _delay_ms(250);

    while(1)
    {
        on();
        _delay_ms(50);
        off();
        _delay_ms(50);
    }
}

By default, all of the general purpose input/output pins are high impedance. This means they are essentially disconnected from the circuit. The positive lines to each side of the coil go through a PNP transistor, which require a low base to turn on. Taking the base high should turn them off. Likewise the negative lines to each side of the coil go through an NPN transistor which requires a low base to turn them off. The resetPins function takes care of this.

Next Step

I'm going to make things a little less boring than a single dot. That is all.

Flipping Back to Basics - Current Situation

25 March 2014

I'm eager to get a microcontroller hooked up to these dots now that I know how to address individual pixels. The microcontrollers I have to hand are ATmega48PA's and they have 23 input/output pins. To control all 240 dots I need to be able to control 46 wires so as it stands I could only control 7 columns of 8 rows, as a row takes up 2 wires.

Fortunately I have a couple of 8-bit shift registers, these take 3 connections as input and offer up to 8 as ouput. They are serial in parallel out (SIPO) and can be daisy-chained, meaning that the same 3 connections can control any multiple of 8 outputs. Having 2 of these means I get an extra 16 outputs by sacrificing 3, allowing me to control a total of 20 columns of 8 rows. That's two thirds of the display so I'm happy with that for a first attempt.

These microcontrollers are delicate things so I want to be sure I'm not going to break them. I made a reading of the current across the coil of a single dot to be 53mA. The datasheet for the ATmega48PA says it can only handle 40mA on any pin though.

Maximum ratings from the ATmega48PA datasheet

Bad times. Fortunately Ohm's Law states that I = V/R, that is, current is equal to voltage divided by resistance. This can be rearranged to R = V/I, meaning that if I know the desired current and voltage I can work out what resistance I need in total. The current is 0.04A, voltage will be 4.5v, so 4.5/0.04 = 112.5, meaning I need a total resistance of 112.5Ω. The multimeter tells me the resistance of the coil by itself is 83.6Ω, 112.5 - 83.6 = 28.9, the closest resistor I have is 27Ω so I'll measure some values using that in series with the coil to see what current is drawn.

It only draws 41mA, which is great, I'm happy to risk that tiny bit extra with the microcontroller. Unfortunately at that current it doesn't activate the dot and perform any flipping action.

That would explain what these boys are doing on the connecting PCB that I've not yet looked at much. 4 source drivers on adjoining PCB These are 8-channel source drivers. They allow 8 low-current inputs to drive 8 high-current outputs. 4 of them make 32 high-current outputs which is just enough for the 30 columns.

Next Step

I'm not going to be able to control the dots without the extra components on the adjoining PCB. I'm going to have to follow the same process again with that in order to work out how to control that which will in turn control the display dots.

Flipping Back to Basics - Multiplexing

24 March 2014

Last time I deconstructed the dots to find out how they work, and was able to flip a single dot back and forth by applying a voltage across 2 connectors. Now I'd like to know how 240 dots, with 4 connections each, are controlled from just 60 wires.

Tracing

I'm ignoring the existence of the LEDs for the time being and focussing on the flipping side of things. Using the multimeter to check for continuity I'm able to construct the following trace of connections up on the rear of the display panel PCB. I'm not fantastic at editing images so please bear with me throughout this.

Rear of display PCB with connections traced

Columns are made up of one end of the electropermanent magnet coil. Rows are made up of the other end of the coil. The rows are passing through a tiny IC, visible in the zoomed box, and whilst I have no idea what this is all about just yet, this still looks to me like multiplexing. I've seen examples of multiplexing LEDs before and it's a fairly basic concept. All the anodes in a row are connected together, and all the cathodes in a column are connected together. This enables the addressing of individual LEDs by applying a positive voltage to the desired row, and grounding the desired column. This leaves just a single route for the current to flow, like so:

Diagram showing current flow through multiplexed LEDs

This multiplexing has 2 wires per LED, one positive and the other negative. The traced connections on the display, however, reveals 3 wires per coil. I need to dig in to multiplexing a bit further to see if I can make sense of this.

Multiplexing

One of the reasons multiplexing works is that LEDs only let current flow in one direction. If this was done with bulbs instead of LEDs then all of them would be illuminated since the current could freely travel through the connected circuit. The coils that control the flipping in this circuit will let current flow in either direction so without some further magic there would be no way to address one by itself. This suggests to me that the little IC is perhaps some sort of diode, but diodes have only 2 leads, one anode and one cathode. Multimeter to the rescue again with its diode tester.

Dual diode IC with diodes traced

The little IC houses 2 diodes arranged as in the above amendment to the original trace. This is becoming clearer now. The double connections to each row are to allow the multiplexing to take place with current flowing in either direction. When we want to turn a dot on we apply a positive voltage to the rows red wire and connect the columns green wire to ground. To turn the dot back off we apply a positive voltage to the columns green wire and connect the rows blue wire to ground. I've (tried to) illustrate this below. Current flow to turn dot on Current flow to turn dot off

The designers of this board could easily have given the columns 2 wires and a diode and had the row use only 1 wire, but there's a good reason for how it's done. With 30 column wires plus 16 (2 8 rows) row wires, there is a total of 46 connections required in order to address every single dot individually. If we turn it round and calculate the alternative, we get 8 row wires plus 60 (2 30 columns) column wires giving a total of 68 connections required. Clearly the former, with fewer required connections, is more efficient.

Next step

Now that the mechanics of addressing individual dots are known I want to construct a simple circuit connected to this board and turn some dots on and off using a microcontroller. This should be a bit of fun and give some nice visible results.

Flipping Back to Basics - Deconstruction

23 March 2014

Last time I was able to work out the make-up of a message to the display over RS-485, there are still many unknowns in the protocol though. The main one that concerns me is the apparent reset of all the dots after 50 seconds. The next logical step, therefore, is to discern what the different control characters are used for.

Software is logical, I am not.

My overall goal is to control arbitrary dots, rather than just send text messages, so I'm going to dive into the other end of this now and focus on the display hardware. By understanding what flipping a dot entails I hope to be able to control them without the use of the RS-485 interface. I'll be working backwards, starting with the visible parts and tracing them back through the circuitry.

Deconstruction

The 90x8 display I used last time is the victim, it doesn't put up much of a fight as I fiddle with its nuts and cables. Inside it's made up of the main control board which has the RS-485 and power connectors. Connected to this board, by a single 60 ribbon cable with multiple connectors, are 3 panels containing the dots. I'll take one of these panels out to inspect further.

Single 30x8 display panel

The Dots

The dots are the visible portion of the panel and are very simple things. Each dot is a black plastic square with one half painted a nice fluorescent yellow. On the fluorescent half there is a small hole in the corner to allow light to shine through from the LED underneath.

5x1 plastic dots removed from the panel

There's then a small piece of plastic, half the size of the square, pivoted about the centre. One side is painted fluorescent yellow such that when flipped correctly the entire dot appears either yellow or black. The key to their functionality is a small permanent magnet near the pivot point, this enables it to be flipped using magnetic force very easily.

Electromagnets and LEDs on the panel

The plastic dots clip on to these little things. Each one of those is a coil of wire wrapped around a magnetic core creating an electropermanent magnet. Electropermanent magnets work by using the coil to change the polarity of the magnetic core. This means that the magnet will continue attracting or repelling after power is cut and so current only needs to flow through it for a very short period of time.
Next to each coil is the LED that shines through the hole in the plastic dot.

Flipping Out

Turning this display panel over allows us to see the connections for both the electropermanent magnet and the LED. I've highlighted them on the diagram that follows. Connections for a single dot on the PCB The electropermanent magnet is connected at 1 and 2, the LED is at 3 and 4

I want to find out how much voltage needs to be applied for the dot to flip but I don't want to damage anything by using too much. I've got a variable transformer with 1.5v intervals so I can start out low and move up until I get it to flip.

We get some flips at 4.5v. The dot flips to show the yellow side when the current flow is from 2 to 1, and back to black when the current flows in the opposite direction, from 1 to 2. I measure the current draw for a single coil at 4.5v to be 53mA.

Next Step

The next step I want to take is tracing the circuit connections backwards from the dot to see some of the techniques used to control 240 dots, with 4 connections each, from just 60 wires in the ribbon cable.