Archive for June, 2006

Meta: Upgraded WordPress

Friday, June 30th, 2006

I’ve upgraded my WordPress blogging software from version 1.5 to 2.0.3. I’m seeing a lot of changes behind the scenes, but not much in the up-front display. If you notice anything that doesn’t seem to be working right, just add a comment to this post and I’ll look into it.

I’m trying to find a way to remove all of the sub-pages (Roomba, PowerBook, etc.) from the sidebar, so they don’t clutter up every view but you can still access them from their master index page. It looks like there may be a way to do it with page templates and customizing the theme, but GAAAAHH!!! Surely someone else has done it by now???

Follow-up:

I’ve found Daniel Schindler’s Exclude Pages plugin, which lets me enter the IDs of pages to exclude from the list.  It’s clumsy and I’d much prefer something that has a flag on the page’s own editing screen–but it works, and that’s enough for now.

LED Clock: List of Posts

Friday, June 30th, 2006

Yesterday I created a page with a list of all the posts about the LED clock in one place.

LED Clock: Daylight Savings Time

Sunday, June 25th, 2006

I hadn’t even considered DST until just now, when I dug out my “eBay special” logic analyzer to see if I could figure out how it works, and noticed that its clock is an hour off.

The timekeeping chips I’m considering don’t (as far as I know) have any facility for DST. However, they do record month, day, and day of week. If I can find the specification for when DST starts and ends, I should be able to increment the hour by 1 during DST, and use the straight hour value during DWT. I’m talking about translating in the display software–I don’t want to monkey with the actual time setting on the RTC if I don’t have to.

Since the clock won’t display the date (at least as currently envisioned), the translation is pretty easy–literally just add 1 to the hour, without worrying about a carry to the day and month fields.

LED Clock: Numbering Order Reanimated

Saturday, June 24th, 2006

This is it.

And by “it,” I mean both the revised image, and the way it’s gonna be.

How Jeremy Animated

Paintshop. Take your original image (layer 1), add a background solid black (layer 0) (you can’t see this layer, because your layer 1 diagram covers it up), copy bright looking light from another file, paste it in on a new layer (layer 2) in LED position one, make layer 1 invisible, save file to JPG (flattens image to visible layers), make layer 1 visible, move pasted image to position two, make layer 1 invisible, save file, rinse, repeat. Then reconstruct the JPGs into an animated GIF in Ulead. All I had to do for this new one was change the order of the JPGs.

LED Clock: Numbering Order Animated!

Friday, June 23rd, 2006

Jeremy rose to the challenge and animated the LED sequences I put together. Here they are, the way I laid out the diagram, and again with a black background the way they’d appear behind a smoked bezel.

And that’s exactly what I needed to see. I don’t like the look of the first 2-3 LEDs popping around the corner–it looks clumsy to me. I’d like to see it again, starting with the one I had second, and picking up the first one on downstroke. That is, start with the middle left, up and around the top loop, left-left-down-left through the midde, and down and around the lower loop.

Of course, that means completely redoing the entire schematic and PCB that I finished today . . .

Jeremy? ‘Nother animation, please?

LED Clock: LED Numbering Order

Thursday, June 22nd, 2006

The Question

This totally doesn’t matter, and OTOH it’s a little aesthetic touch I want to get right. What should be the order that the individual LEDs are numbered within one character?

This impacts two things: circuit layout and LED test patterns. I’m ready to start laying out the circuit, which is why I’m thinking about it now. I’ve thought about LED test patterns, which is why I’m thinking about it at all.

The LED drivers shift in their data bit by bit, while shifting their current contents out in the same fashion. So if you want to enter 11111111 into a driver currently containing 00000000, it works like this:

00000000 ← 11111111
00000001 ← 1111111
00000011 ← 111111
00000111 ← 11111
00001111 ← 1111
00011111 ← 111
00111111 ← 11
01111111 ← 1
11111111

The Impact

This means it’s very easy to do moving marquee type of effects by shifting a single 1 bit or a short row of 1 bits through a display:

0000000000000000
0000000000000001
0000000000000011
0000000000000111
0000000000001110
0000000000011100
0000000000111000
0000000001110000

Just shift a few 1 bits into the register, then keep clocking it and latching the input register to the output register on every clock cycle.

Now, granted, the 6276 is so fast compared to human vision that I could shift in an entirely new pattern from scratch, then latch it, way faster than you could possibly see. But there’s a certain elegance in taking advantage of the driver’s architecture for the design of a test pattern. So I’d like to arrange the LEDs to do just that–make a pleasing test pattern when activated in order from D0 through D30. (Not a typo–only 31 LEDs in the design.)

The Proposal

Here’s what I’ve come up with, drawn a couple of different ways:

LED Order LED Order

The test pattern starts in the middle of the digit, loops through the upper half clockwise and the lower half counterclockwise, springs off the right edge to the top of the colon, and drops down into the period. The possible issues are:

  • Is this even the right kind of pattern to do?
  • Is that the right starting point, in particular with respect to the extra LED inserted in the lower half to smooth out the 2?
  • Is it right to skip the middle-right LED on the way down, and leave it for the end before jumping up to the colon? Or should it be included on the way down, and skipped on the way to the colon?

I’m open to suggestion, but I’m also afraid that it’ll be hard to evaluate the visual smoothness of the effect for sure until a digit is prototyped–and I can’t prototype on a breadboard; it’ll require a custom PC board to do it. I guess if I were sharp enough with computer animation, it shouldn’t be that hard to do this in software; but at this point, I’m not sure I’m up to it. Maybe I should pull out my old C-64 . . .

LED Clock: Enough Controller Pins?

Wednesday, June 21st, 2006

Last night, while programming the LogoChip A6276 interface, I started to become concerned about having enough LogoChip pins to connect to everything I want to wire up to make the clock work. So I just did a quick sanity check to see whether I’ll have enough pins, or whether I need to double up digits together.

Here are the LogoChip pins:

Available Pins
A0 – A2
A3 – A5 ?
B0 – B7
C2
C6 – C7

I’m not sure whether A3 – A5 are available or not. They’re ghosted (grey) on the LogoChip sticker, and I’m not sure why. But because of that, I think I didn’t provide sockets for them on my Curiously Strong LogoChip, which may pose challenges while prototyping. Additionally, A0 – A2 didn’t work for driving the 6276, so maybe not even all of the available pins will work.

Anyway, here’s a tentative pin assignment.

Chip Lines Count Possible LogoChip Lines
A6276 LED driver serial data in
clock
latch (each character)
2
.
6-8
A0 – A1 (didn’t work)
   or B0 – B1
B0/2 – B8
Dallas clock chip data
clock
enable?
2-3 A0 – A2 (didn’t work for A6276)
PC serial port? TD
RD
2 C6 – C7

[Ewww, I don't like what the WordPress stylesheet does to the table text alignment.]

Looks like everything should work out, assuming that I can use all the pins the way I intended. In fact, if the clock is only six digits, I can use B0 – B1 for the 6276 data and clock lines and B2 – B7 for the digits’ latch lines, fitting the entire display driver into one I/O port. Tidy.

The Dallas timekeeping chip will need either two or three pins, depending on whether I use the DS1340 with I2C or the DS1302 with “simple” three-wire interface.

The LogoChip already connects to the PC’s serial port on pins C4 and C5; however, receiving data halts a running program. That means that while uploading control data to the LogoChip, although the real-time clock chip would continue to keep time, the display would freeze and stop updating; and that every data transmission would need to be followed by a command to restart the display program.

Since I may want to be able to send updates to the LogoChip while it’s operating (time corrections, commands to change display mode, etc.), I’m thinking of using the PIC’s built-in UART on C6 and C7 for run-time serial communication.

Anyway, the bottom line is that as long as I can figure out how to use the A port lines for digital I/O, and as long as we’re only making a six-character clock (HH:MM:SS without .TH), there are enough lines. Good deal.

LED Clock: Programming the A6276 LED Driver

Tuesday, June 20th, 2006

Banging Bits

I got the LogoChip controlling the A6276 tonight. I programmed from the bottom up, writing code to bang the bits first, and ending up with . . . not much more than code to bang bits. It’s really pretty easy–put the bit on the line feeding the serial data input, strobe the clock line (active high), and when you’re ready strobe the latch line (also active high) to copy the data to the output register.

I started out using pins A0 – A2 for the control lines, and for some reason I still haven’t figured out, they didn’t work. I could set the data bit (A0) high; but every time I toggled the clock line (A1), the data line fell low again, preventing me from shifting a 1 into the input register. Huh?? When I moved the lines to B0 – B2, they worked fine without any other changes to the code. Huhuuuhhhh?????

Strobing Clock and Latch Lines

Given that the 6276 can shift data at 10Mhz, the LogoChip PIC is running on its internal 10MHz oscillator, each PIC operation takes at least one clock cycle, and each Logo instruction probably takes several PIC operations, I should be pretty safe toggling the clock and latch lines high on one instruction and low on the next without a delay in between. I did test with mwaits in between, but it really didn’t make any difference except to slow it down. I guess conceivably I could see problems when I’m trying to shift real data later, so I’ll keep it in mind.

The Code

Here’s what I ended up with:

  • a6276.txt – Program to control Allegro MicroSystems A6276 LED driver

Here’s the code:

;   a6276.txt
;
;   20-Jun-2006  Keith Neufeld
;
;   Drive an Allegro MicroSystems A6276 constant-current LED driver chip.
;   The chip takes three inputs:
;
;   A0  serial data in (SDI)
;   A1  clock (CK)
;   A2  latch enable (L)

;------------------------------------------------------------------------------
;   Debug system
;------------------------------------------------------------------------------

constants [[debug 0]]
;constants [[debug 1]]

;------------------------------------------------------------------------------
;   Section to manipulate A6276.
;------------------------------------------------------------------------------

constants [
    [a6276-sdi-port portb] [a6276-sdi-ddr portb-ddr] [a6276-sdi-bit 0]
    [a6276-ck-port portb] [a6276-ck-ddr portb-ddr] [a6276-ck-bit 1]
    [a6276-l-port portb] [a6276-l-ddr portb-ddr] [a6276-l-bit 2]
]

;   Push one bit into input register.
to a6276-bit :bit
    ;   Put bit on data input port.
    ifelse :bit [
        if debug [ prs "setbit ]
        setbit a6276-sdi-bit a6276-sdi-port     ;   set 1 output
    ] [
        if debug [ prs "clearbit ]
        clearbit a6276-sdi-bit a6276-sdi-port   ;   set 0 output
    ]

    ;   Clock it.
    setbit a6276-ck-bit a6276-ck-port   ;   rising edge
    clearbit a6276-ck-bit a6276-ck-port ;   falling edge
end

;   Latch input register to output register
to a6276-latch
    setbit a6276-l-bit a6276-l-port     ;   rising edge
    clearbit a6276-l-bit a6276-l-port   ;   falling edge
end

;   Turn off all LEDs.
to a6276-off
    repeat 16 [ a6276-bit 0 ]
    a6276-latch
end

;   Initialize port settings and turn off all LEDs.
to a6276-init
    clearbit a6276-sdi-bit a6276-sdi-port       ;   zero data input
    clearbit a6276-ck-bit a6276-ck-port ;   zero clock
    clearbit a6276-l-bit a6276-l-port   ;   zero latch enable

    clearbit a6276-sdi-bit a6276-sdi-ddr        ;   set pins as outputs
    clearbit a6276-ck-bit a6276-ck-ddr
    clearbit a6276-l-bit a6276-l-ddr

    a6276-off                           ;   turn off all LEDs
end

;------------------------------------------------------------------------------
;   Routines to tie it all together
;------------------------------------------------------------------------------

to init-all
    a6276-init
end

to powerup
    init-all
end

to startup
    init-all
end

Oh, and One More Thing . . .

The blue LEDs are still bright.

LED Clock: Testing the A6276 LED Driver

Monday, June 19th, 2006

Parts Arriving

While I was away directing camp, several things came in the mail. I now have my A6276 LED driver samples, my DS1302 real-time clock samples, and my 32kHz crystal oscillator samples. The DS1340 RTC samples are awaiting factory approval (whatever that means). My LEDs left Hong Kong on Saturday, and don’t yet show up in the USPS tracking system.

I’ve been studying the datasheets to start figuring out exactly how to interface with the different chips. That includes learning about the I2C (Inter-Integrated Circuit) bus used by the timekeeper chip with the integrated crystal. There’s a nice technical overview of I2C over at the Embedded Systems Academy that’s helping a lot–it looks like I2C should actually be really easy to do in the LogoChip.

LED Drivers

I wanted to start testing with the 6276 LED drivers, since I know I’m going to use them no matter what. (I’m not sure I want to start interfacing to the 1302 and 1340 until I have both sets of samples.) The 6276es are also pretty simple to work with, as shown by my horrible test circuit.

A6276 Constant-Current LED Driver Circuit

The green wire is the data input, which I’m plugging directly to ground or +5V to set a level. The two buttons (salvaged from a dead CD-ROM drive–seriously, I don’t buy anything I don’t have to) are the clock input, which shifts the data into the input register; and the latch input, which latches the current input register into the output register. Yes, the switches “bounce” and generate multiple electrical pulses–it only takes a few presses of the clock button to fill the input register with 1s. C’est la vie. Since that’s what I was trying to accomplish anyway–demonstrate that this chip can turn LEDs on and off–it works out.

Mmm, housekeeping. The clock and latch inputs don’t have internal pull-up or pull-down resistors, so I added external pull-downs. (The inputs are active high, so I tied them to ground to use with my normally open pushbuttons.) The black wire in the upper section is the active-low output enable, tied to ground to activate the output all the time. And the orange potentiometer is the reference resistor to set the LED current. The 5V leads from my bench power supply connect off to the left of the picture.

It makes the LEDs light! It’s as simple to use as the datasheet makes it it look! And the LEDs are bright, as Jeremy and I had already discovered. I accidentally looked at them from up close, and literally couldn’t see what I was doing while swapping them out for some that I’d manipulated for broader viewing angle.

The only drawback is that my 5mm LEDs don’t fit side by side in the .1″ breadboard. If I cared enough, I could bend the leads so they fit in a /\/\/ zigzag pattern, or prototype a PCB just for playing with the 6276. But I think I’ll wait to cut a board until I’m ready to make the first digit.

Cool. Next: software control via the LogoChip.

LED Clock: LED Control Bus Architecture

Friday, June 9th, 2006

Circuit Layout

The same time alone in the car solidified my thinking about the bus architecture I want to use to get the control lines from the microcontroller to the 16-channel LED drivers.

Each digit of the clock will have 28 LEDs, plus two for inter-digit colon and one for decimal point; hence 32 channels / two driver chips per digit. Probably six of those banks in the whole clock, for HH:MM:SS or MM:SS.TH, depending on the operating mode.

I’ve settled on this plan: Each digit will be independently addressed. The two A6276 chips within each digit will be chained together in serial, but all the different digits will fan out in parallel. That means strobing 32 bits of font data for every character change, which is (1) the minimum required, because that’s how many it takes to change the data anyway; and (2) a nice maximum, compared to strobing all 192 every time.

Here’s where it gets fun, and where my time spent growing up studying 8-bit microprocessor circuits pays off. It takes three lines (data, clock, and latch) to operate a series-chain of 6276es, so at first glance this plan looks like an 18-line architecture; and that’s more pins than I have available on the PIC18F2322 LogoChip.

But the way the drivers work, it doesn’t matter what’s in the serial-in buffer until you enable the latch to that chip, which captures the serial-input buffer it into the parallel-output buffer. Ergo use a single data/clock output pair from the LogoChip to all the characters at once, and only use six separate lines for the latch controls. Yeah, it seems a little odd to deliberately shift meaningless data into all the chips all the time, but there’s really no harm in it. Tee-hee.

It boils down to having a system-wide data bus with enable lines to select which chip listens, which is how every multichip computer (even the ones old enough for me to comprehend their design :-) ) is built.

I’m even going to be a good boy and check the fanout, to make sure the LogoChip can drive that many 6276 inputs (or whether I’ll need to interject a buffer).

Board Layout

I’d like to start drawing out the circuit in EAGLE, but it doesn’t have a library entry for the 6276, and I haven’t checked on the DS1302 and DS1340 yet. I’ll probably have to design symbols for them.

Another set of questions revolves around whether the entire display will be a single ~2″ x ~12″ PCB, or a set of adjacent smaller PCBs that tie together. I kind of like the aesthetics of a single PCB; I kind of like the maintainability of smaller PCBs that permit swapping out single digits if LEDs fail, which gets the clock running again quickly. Hm, if I did do that, I’d want some kind of test harness that was ready and waiting to plug in and drive the lone digits.

Either way, I picture laying out the board as individual modules, with a control bus that extends across the entire width. Then the design isn’t dependent on the decision, and we can make it pretty late in the process.

One other consideration is manufacturing the PCB. I had assumed I’d use EAGLE; but of course the free version only edits boards up to about 3″ x 4″, which wouldn’t be nearly big enough for the full board. Maybe it’s time to learn to use FreePCB, which has always been my plan for laying out larger boards.

Also, I assume I’ll hand-draw and hand-etch the board rather than have it produced commercially, and my friend Joel’s drilling machine only has a travel of about 12″. If the display board is monolithic, I might have to produce drill files such that I could drill half the length of the board, flip it end for end, and drill the other half. I obviously wouldn’t get perfect alignment, but I think I could get close enough to be satisfied. It’s still a significant extra hassle, as is coming up with a much larger etching tank than the plastic case I’m currently using.

Ultimately, though, I want to make as many decisions as possible based on what’s right for the project, not what’s easiest to get away with. I don’t feel bad about DIY frosting the narrow-angle clear LEDs, because I think the result is about the same. But that’s not true of the difference between a single long board and a bunch of plug-in modules, whichever way we decide would be better.