{"id":300,"date":"2007-02-24T18:58:57","date_gmt":"2007-02-24T18:58:57","guid":{"rendered":"http:\/\/diversifiedcuriosities.com\/2007\/02\/24\/cylon-detector\/"},"modified":"2017-08-18T18:03:01","modified_gmt":"2017-08-18T18:03:01","slug":"cylon-detector","status":"publish","type":"post","link":"https:\/\/blog.nearfuturelaboratory.com\/2007\/02\/24\/cylon-detector\/","title":{"rendered":"The Ersatz Cylon Detector: A Hardware Sketch To Illuminate The Inner Workings of the MAX6953 Integrated Circuit"},"content":{"rendered":"
An on-going project that requires the display of alphabetic and numeric characters using a 5×7 LED matrix turned me towards a chip by Maxim IC<\/a> \u2014 the MAX6953<\/a>. The chip, while expensive (~$8), has lots of built-in features that mitigate the damage to my purse, trading such in kind for time-saved. It will directly drive up to 4 5×7 LED matrices<\/a> with direct control from a microcontroller over a two-wire interface (TWI\/I2C)<\/a>, can manage varying intensities (16 or 32 degree scales), has a built-in Arial-like font set with a reasonably full-range of characters, diacritics and symbols, and allows me to create 24 characters of my own design.<\/p>\n Here’s my Eagle PCB library of the MAX6951 and MAX6953<\/a>; feel free to use it.<\/p>\n \n My first attempt at mucking with the chip used the DIP version, which is ginormous and requires such patience and diligence with wiring the thing up \u00e2\u20ac\u201d\u00c2 all those lines going to the pins of the LED matrix \u00e2\u20ac\u201d that I pretty much gave up after it didn’t work the first time. I decided that I’d just go ahead and design a PCB for the thing and continue to hone my skills with Eagle<\/a>, while also learning how to work with the MAX6953.<\/p>\n I sent a design off<\/a>, it came back, I stared at it for a few minutes, looked for the MAX6953’s in my bin of samples and realized I didn’t have any. I managed to coax a bunch from Maxim’s sample guy, which is great. (Thanks whoever you are, wherever you are.) A couple of weeks later, when my plate was relatively clear, I assembled one of the boards, using a yellowish\/orange 5×7 matrix LED<\/a> I purchased from Digikey<\/a> and manufactured by LiteOn<\/a>. I wanted small, but the closest I got to small was 0.7″, which still seems big to me. (The story of it’s assembly<\/a> and problems therein is instructive if you’re curious about surface-mount PCB work..and the problems therein.)<\/p>\n I powered the thing up and, naturally enough, it didn’t illuminate at all. I poked through the spec sheet and figured out that there’s a whole start-up ritual you’ll want to go through, such as the test mode and negating the shutdown bit, which defaults to “shutdown enabled.” After an hour or so of puzzling, I managed to get it displaying characters while hooked up to my usual Arduino<\/a> test harness thing.<\/p>\n While I was assembling the board, I realized I wasn’t sure what the proper orientation of the LED device should be. I looked for markings to indicate pin 1 and found nothing definitive. I looked at the product data sheet and they had an arrow pointing at pin 1 but nothing that clearly told me how to determine which of the pins was the first. Now, the holes I put in for the LED device in Eagle were a bit snug \u00e2\u20ac\u201d too snug, really. It required a bit of jiggering to get the LED device to fit. (I went back and made the holes slightly bigger in the design.) But, I realized this could be an advantage given my current pin alignment peril \u00e2\u20ac\u201d\u00c2 the snugness would allow the LED device’s pins to make contact with the through-holes’ platings! In other words, I could fit the device one way and not solder the pins to see if I had the thing right-way-around.<\/p>\n Well, that worked. A consequence of it working was that some of the columns and rows didn’t illuminate quite consistently \u00e2\u20ac\u201d\u00c2 they’d flicker and such \u00e2\u20ac\u201d and a mysterious character appeared \u00e2\u20ac\u201d\u00c2 an evil rabbit was the first thing I saw.<\/p>\n I ran through a few code gyrations and got characters to show, right-way-around, so I went ahead and soldered the LED device permanently to the board, easy-peasy.<\/p>\n Thinking of a few possible ways to make this learning project fun to share for the show-and-tell session of the weekly luncheon I have with some friends, I decided that I’d make a combination Magic 8 Ball<\/a> \/ Cylon Detector<\/a>, the idea being that one could reasonably ask the Magic 8 Ball if one were a Cylon \u00e2\u20ac\u201d\u00c2 I mean..why not? \u00e2\u20ac\u201d which would be a lot easier than what Baltar<\/a> was trying to construct, and wouldn’t require blood samples or anything. You could just ask yourself, in the privacy of your own home or a public restroom, and then choose whether or not you wanted to share your result.<\/p>\n So, I hooked it up to an accelerometer that detects the normative shaking motion one inflicts on the Magic 8 Ball..the evil rabbit then divines the response.<\/p>\n Anyway, it definitely works.<\/p>\n The Ersatz Cylon Detector is meant for entertainment purposes only. It does not purport to factually report whether or not individuals are Cylons, except for Don Milvio. (He’s definitely a weird hybrid Franco-Italian Cylon thing.) The results are for home amusement and cannot be used for discovery or detection of actual Cylons, their friends or family. The results cannot be used for legal purposes, nor as a sanction for physical violence. The Ersatz Cylon Detector and its results are not endorsed by the producers of Battlestar Galactica, The SciFi Channel, or its affiliates and their station managers.<\/span><\/p>\n Arduino Code<\/em><\/strong><\/p>\n #include <Wire.h><\/font><\/strong><\/font> \/\/ http<\/font>:<\/font>\/\/wiring<\/font>.org<\/font>.co<\/font>\/reference<\/font>\/libraries<\/font>\/Wire<\/font>\/index<\/font>.html<\/font> char<\/strong> mAnswer_1<\/font>[<\/font>19<\/font>]<\/font> =<\/font> {<\/strong><\/font>‘S’<\/font>,‘i’<\/font>,‘g’<\/font>,‘n’<\/font>,‘s’<\/font>,‘ ‘<\/font>,‘p’<\/font>,‘o’<\/font>,‘i’<\/font>,‘n’<\/font>,‘t’<\/font>,‘ ‘<\/font>,‘t’<\/font>,‘o’<\/font>,‘ ‘<\/font>,‘y’<\/font>,‘e’<\/font>,‘s’<\/font>,0x00<\/font>}<\/strong><\/font>;<\/font><\/a><\/p>\n
<\/a><\/p>\n\n
<\/a><\/p>\n\n
<\/a><\/p>\n
<\/a><\/p>\n
<\/a><\/p>\n
<\/a><\/p>\n
<\/a><\/p>\n
<\/a><\/p>\n
\n
\n#include <math.h><\/font><\/strong><\/font><\/p>\n
\n\/\/ On<\/font> the<\/font> Arduino<\/font> board<\/font>, Analog<\/font> In<\/font> 4<\/font> is<\/font> SDA<\/font>, Analog<\/font> In<\/font> 5<\/font> is<\/font> SCL<\/font>
\n\/\/ These<\/font> correspond<\/font> to<\/font> pin<\/font> 27<\/font> (<\/font>PC4<\/font>\/ADC4<\/font>\/SDA<\/font>)<\/font> and<\/font> pin<\/font> 28<\/font> (<\/font>PC5<\/font>\/ADC5<\/font>\/SCL<\/font>)<\/font> on<\/font> the<\/font> Atmega8<\/font>
\n\/\/ The<\/font> Wire<\/font> class<\/font> handles<\/font> the<\/font> TWI<\/font> transactions<\/font>, abstracting<\/font> the<\/font> nitty<\/font>–<\/font>gritty<\/font> to<\/font> make<\/font>
\n\/\/ prototyping<\/font> easy<\/font>.
\n\/\/ This<\/font> sketch<\/font> has<\/font> two<\/font> TWI<\/font> devices<\/font> connected<\/font> to<\/font> it<\/font> \u00e2\u20ac\u201d a<\/font> LIS3LV02DQ<\/font> tri<\/font>–<\/font>axis<\/font> accelerometer<\/font>
\n\/\/ and<\/font> the<\/font> MAX6953<\/font> 5x7<\/font> matrix<\/font> LED<\/font> driver<\/font>. The<\/font> MAX6953<\/font> is<\/font> at<\/font> address<\/font> 0x50<\/font>, and<\/font> the<\/font> LIS3LV02DQ<\/font> is<\/font>
\n\/\/ at<\/font> address<\/font> 0x1D<\/font>.<\/p>\n
\nchar<\/strong> mAnswer_2<\/font>[<\/font>4<\/font>]<\/font> =<\/font> {<\/strong><\/font>‘Y’<\/font>,‘e’<\/font>,‘s’<\/font>,0x00<\/font>}<\/strong><\/font>;<\/font>
\nchar<\/strong> mAnswer_3<\/font>[<\/font>12<\/font>]<\/font> =<\/font> {<\/strong><\/font>‘M’<\/font>,‘o’<\/font>,‘s’<\/font>,‘t’<\/font>,‘ ‘<\/font>,‘l’<\/font>,‘i’<\/font>,‘k’<\/font>,‘e’<\/font>,‘l’<\/font>,‘y’<\/font>,0x00<\/font>}<\/strong><\/font>;<\/font>
\nchar<\/strong> mAnswer_4<\/font>[<\/font>16<\/font>]<\/font> =<\/font> {<\/strong><\/font>‘W’<\/font>,‘i’<\/font>,‘t’<\/font>,‘h’<\/font>,‘o’<\/font>,‘u’<\/font>,‘t’<\/font>,‘ ‘<\/font>,‘a’<\/font>,‘ ‘<\/font>,‘d’<\/font>,‘o’<\/font>,‘u’<\/font>,‘b’<\/font>,‘t’<\/font>,0x00<\/font>}<\/strong><\/font>;<\/font>
\nchar<\/strong> mAnswer_5<\/font>{<\/strong><\/font>16<\/font>]<\/font> =<\/font> {<\/strong><\/font>‘Y’<\/font>,‘e’<\/font>,‘s’<\/font>,‘,’<\/font>,‘ ‘<\/font>,‘d’<\/font>,‘e’<\/font>,‘f’<\/font>,‘i’<\/font>,‘n’<\/font>,‘i’<\/font>,‘t’<\/font>,‘e’<\/font>,