Archiv | MAKE RSS für diesen Abschnitt

1 Watt constant current LED driver shootout

1 Watt LED drivers

As many electronic hobbyists, I have always been fascinated by LEDs, especially the really bright ones. I could now ramble on about 50W or 100W LEDs, but to connect to the story of my previous post, I will talk a little about driving 1 Watt LEDs, the ones that come on a star shaped heatsink (e.g. the first Luxeon generation). While you could connect those with a current limiting resistor as you do with the small 20mA LEDs, it is not a really wise thing to do as you would need large resistors, withstanding an unhealthy amount of heat. So the device of choice is a constant current source – in this case one that provides 350mA constant current. I have three different ones and took some time to evaluate them from a users perspective (meaning ease of use, etc. – I will not talk about output ripple, stability, surges, etc.).

The good, the bad and the ugly?

1 Watt constant current LED driversI going to look at three different constant current sources:

They all work pretty straight forward, you supply them with a voltage between 9V and 30V (+/-) and they output 350mA of current with which you can drive one or more 1Watt LEDs in series (provided the combined forward voltage doesn’t exceed your input voltage). No suprise here, they all do that and work just fine. But what about dimming the LEDs? Each of the drivers has a dedicated pin for that. And here it get’s complicated…

Meanwell LDD-350L

This one is the most uncomplicated of the bunch. To use the dimming pin, simply apply a PWM signal (in my case from an Arduino), and the driver will dim the LED according to your PWM duty cycle. 10% duty cycle = 10% current (which is not neccesarily 10% brightness as the relationship between brightness and current is not linear with these LEDs), 50% duty cycle = 50% current, 100% duty cycle = 100% current. You catch my drift. The driver will align the output to the duty cycle (and even the PWM frequency) of the DIM pin.

LDD350L with 50% duty cycle on Arduino pin 5

LDD350L with 50% duty cycle on Arduino pin 5

 

LDD350L with 50% duty cycle on Arduino pin 3

LDD350L with 50% duty cycle on Arduino pin 3

Since pins 3/9/10/11 and 5/6 (on the Arduino UNO compatibles) use two different PWM frequencies, this is reflected in the above wave forms.

ANVILEX CCS2

As mentioned in the previous post, the ZETEX chip an this current source is a little odd with regard to PWM control. In my tests, I found out that a duty cycle between 0% and about 45% gives you current control from 0% to 100% (using a 5V PWM signal). If you raise the duty cycle to more than 45%, the driver will exponentially increase the output current, thus overdriving the LED. A duty cycle of 55% will yield more than 520mA output current, guaranteeing premature ageing and death of your LED. So be careful. This driver also copies the PWM frequency from the input source, which is exactly what the datasheet said: Depending upon the control frequency, this will provide either a continuous (dimmed) or a gated output current. Since the PWM frequency is above 300Hz, we see a gated output waveform on the oscilloscope:

Anvilex CCS2 with 40% duty cycle on Arduino pin 3

Anvilex CCS2 with 40% duty cycle on Arduino pin 3

To work with this driver, you have to make sure to limit the PWM duty cycle to a maximum less than 50%, otherwise you might fry your LED (and maybe more…). This driver also produces hissing noises varying on the PWM duty cycle which may annoy you depending on your use case.

No-Name (with XLSemi XL4001 chip)

This is one of the cheap LED drivers you can get on ebay for just a couple of Euros. It has almost the same components as the CCS2, namely input/output smoothing caps, schottky diode, an inductor and some resistors to configure the chip. The only real difference is the XLSemi XL4001 chip that is used on this module. It it not per se a LED driver, it is a multipurpose DC/DC buck converter, but it features a current control loop, so that it can be used as a constant current source too. This driver can be dimmed using PWM as well, but the output waveform has nothing in common with the input waveform. In fact, it looks a little odd:

XLSemi XL4001 output waveform

XLSemi XL4001 output waveform

Dimming this driver offers some pitfalls: the PWM pin is the ENABLE pin of the chip, which is inverted. This means a PWM duty cycle of 0% will cause the driver to output a current level of 100% and a duty cycle of 100% will shut the driver down. Just keep that in mind when designing your sketch or whatever. The other thing: although the datsheet says, that the default state of the ENABLE pin is low, it will not return to that state if the chip already received a PWM signal and the signal wire is disconnected afterwards. Instead, it will spiral upwards, causing the output off excessive amounts of current to the LED, slowly killing it. So when experimenting with it, be sure not to pull out any wires while the circuit is still live.

Conclusion

There is no winner to be named here, these drivers all do what they were made to do. If I had to pick a favorite, it would be the Meanwell LDD-350L because it is *so* uncomplicated to work with and there a no suprises. You can work with the others as well, but be sure to read up on the special traits of each driver/chip so you can avoid nasty surprises.

How to blow up electronics #1 – with power LEDs

So the other day I started working on a custom high power LED strip, using red, green and blue 1 Watt power LEDs. Nothing really fancy, just 7 LEDs in series per color, each driven by a 350mA constant current source at about 24 volts. I decided to throw in an Arduino for brightness control, since the cc sources have PWM dimming capability. Fun fact: I didn’t need to buy any additional components, everything I needed I had lying around somewhere (don’t ask…).

The setup

The setup is pretty straight forward: the thing is powered by 12V DC which is then boosted to 24V by some beefy boost converter. Those 24V are then hooked up to three Anvilex CCS2-350 constant current drivers. Each string of 7 LEDs – with blue haven the highest forward voltage, thus 7×3.5V ~= 24V – is connected to one of these drivers.

Arduino power LED control box

Power LED control box

Dimming with the Arduino

Enter the Arduino: for testing purposes I added a classic Freeduino (Duemilanove clone), connecting it to the 12V input voltage and attaching the PWM ports to the DIM ports of the CCS2s. There are some caveats using the CCS2 and the data sheet doesn’t make it very easy to understand them (either this or I am a rather slow learner…). Anyway. The CCS2 uses the Zetex ZXLD1366 LED driver chip and this chip provides the DIM pin. This pin is some sort of „jack of all trades“ and accepts analog voltages, PWM modulated voltages or PWM gating.

Fun with the ZXLD1366 specs

The ADJ pin will accept either a DC voltage or a PWM waveform. Depending upon the control frequency, this will provide either a continuous (dimmed) or a gated output current. — from the ZXLD1366 datasheet

What the hell does that mean? It means you can either

  • suppy a true analog voltage or
  • a PWM signal which will cause
    • true analog current control at a low frequency (< 300 MHz) or
    • gated output control (meaning „chopped“ on/off/on/off cyles relation to your PWM signal)

Since the lowest PWM frequency you can get on the Arduino is 490 MHz (not using any timer manipulation or soft PWM), we will have gated output control.

That doesn’t sound so bad – but there is another drawback to trip over: the DIM pin can withstand voltages up to 6 volts, BUT the output current will reach the designated maximum value (in my case 350mA) at a voltage of 1.25V. The chip will shutdown to power saving when the voltage drops below 0.2 volts. And (here it comes): anything between 1.25V und 2.5V will further increase the current output up to twice the maximum (700 mA). Voltage increases above 2.5V have no further effect.

Congratulations, we have just found the means of blowing up our LEDs. So I had to limit the PWM range to 0-63 (256 steps/5 Volts * 1.25V ~= 63). No problem here, we are just losing some resolution.

Blowing stuff up

I wrote a small test sketch to see if everything worked an it surely did. I the replaced the bulky Freeduino with a soldered in Pro Mini that will actually fit inside the enclosure. I fired everything up again and there it was: a well audible bzzzt and then silence. Followed by some erratic flashing on the power LED side. The Pro Mini had gone out with a bang (you have to see volume in relation to the size of the components…). But why? Frantically checking everything it turned out the Atmega328 was fried. Interestingly enough, also one of the power LEDs got killed in the process. I realised that when I connected the Freeduino again and the red LED string wouldn’t come on anymore.

I replaced the faulty LED and ran everything again and it all worked fine. I then replaced the Freeduino with another Pro Mini and measured everything without the LEDs attached and it surely would work. I then reattached the LEDs and … bzzzt. Another Pro Mini dead. And another power LED. WTF?

Once more measuring everything after hooking up the Freeduino again. This time I also used my trusty pocket oscilloscope. And what did I find? I was betrayed by my love for cheap components…

WTF? Why?

Some electronic components I fried

The components I fried

So, here’s what happened: I am using a rather cheap 30W 12V power supply. It is supposed to power 21 Watts of LEDs and assuming that to boost converter operates at an optimistic 85% efficiency rate, it would need to provide a least 25 Watts of power. And it does. During a brief period when the circuit is already powered and the Arduino has booted, the CCS2 will power the LEDs at full brightness (I guess that’s by design). So the whole thing draws 25 Watts right from the start. The power supply compensates for the sudden demand, but there is a slight voltage spike of ~13V as it does. That spike is no problem for the 7805 on the Freeduino and it would also be no problem for the MIC5205 (up to 16 Volts VIN) on the Pro Mini had I been using a genuine one and not some cheap clones. The clones come with a MIC5219 or some other cheaper regulator that allows only 12 Volts at VIN.

So the regulator was fried by the voltage spike. That in turn damaged the Atmega chip and made it send more than 2.5V to the DIM pins. The LED current was doubled and one LED sacrified itself so that the others could survive. On the second attempt, uregulated voltage was flowing everywhere and even killed one of the constant current sources. Yay! No…

Lessons learned

So, what do I take with me from this whole mess? Well, I guess I could have avoided those mistakes by thinking a little bit more before soldering. Measure twice, cut once they say. I say: But cutting is more fun than measuring :-). So better luck next time. Here are the two major learnings:

  • Don’t rely on the linear voltage regulator of your Arduino, especially not on tiny, cheap Arduino clones. Either use a standalone 7805 regulator or – and that is the preferred way – use a switching step-down (or even a really fancy step-up/step-down) converter such as the Pololu D24V5F5 or the S10V4F5. They can take at least 18 Volts and are have builtin safeties.
  • Use a voltage divider circuit for the PWM signal on the DIM pin. This gives you the full resolution of 256 steps on the PWM (although atmittedly you really can’t see any difference in brightness using only a single step) and it protects the DIM pin – and your LEDs – against over-voltage/current.

Solarenergie marsch – Meine Solar-Inselanlage

Ich versuche eigentlich schon seit Jahren meinen Stromverbrauch zu senken und grüner zu gestalten. Und ich würde sagen, ich habe schon einiges erreicht: meinen Strom selber beziehe ich von Naturstrom, den Standby-Verbrauch meiner ganzen Elektronik habe ich durch abschaltbare Steckdosen oder Funkschalter drastisch gesenkt, im Keller werkelt ein A++-Gefrierschrank und alle meine Lampen nutzen entweder Energiesparlampen oder LED-Leuchtmittel. Aber da musste doch noch was gehen. In erster Linie aus Experimentierfreude und Spieltrieb habe ich daher vor kurzem meine eigene Solar-Inselanlage in Betrieb genommen.
Inselanlage bezeichnet dabei ein System, das nicht am normalen Stromnetz angeschlossen ist. Da ich ja nur Mieter bin, fällt eine große Festinstallation natürlich flach, aber auch in kleinem Maßstab lässt sich was machen. In meinem Fall ist das für den Anfang eine kleine Anlage mit folgenden Bausteinen:

Please specify a Flickr ID for this gallery

Aufbau und Verkabelung

Das Solarpanel findet zwischen Sofa und Balkonfenster Platz und ist somit fast genau gen Süden ausgerichtet. Für wärmeres Wetter werde ich die Solarzelle vermutlich auf den Balkon stellen, die Zuleitungen sind jedenfalls lang genug und einen passenden Halter habe ich auch schon aus OpenBeam-Komponenten zusammengeschraubt.

Um alle Komponenten und auch meine Bude gegen Überlast, Kurzschluss und Brand zu schützen, habe ich die ganze Verkabelung nach Anregung eines Energy Matters-Videos über entsprechende Sicherungsautomaten auf einer DIN-Schiene geleitet. Sicherungsautomaten finden sich in jedem Haushalt im Sicherungskasten und bieten zwei Funktionen: zum einen Trennen sie den Stromkreis bei Überlast und zum anderen kann man sie zusätzlich als Schalter benutzen. In meinem Fall habe ich folgende Sicherungen verbaut:

  • 6A zwischen Solarpanel und Laderegler
  • 20A zwischen Laderegler und Batterie
  • 20 A zwischen Batterie und Wechselrichter

Die 6A dienen primär als Schalter, denn selbst eine Verdoppelung der Solarleistung würde noch nicht an die 6A heranreichen (größter Strom, den ich bisher gemessen habe, waren 2,7 Ampere). Die 20A zwischen Regler und Batterie sind eine großzügig dimensionierte Sicherheitsmaßnahme, denn solange die Solarzelle nicht annähernd 20A liefert werden auch keine 20A Ladestrom erreicht. Die Sicherung zwischen Batterie und Verbraucher hingegen ist notwendig. Der Wechselrichter ist nur für 150 Watt ausgelegt und hat einen Wirkungsgrad von etwa 80-85%. Läuft der also unter Volllast, muss er sich 150 / 0,8 = 187,5 Watt aus der Batterie ziehen. Bei 12 Volt Spannung sind das ~ 15,6 Ampere. Sofern der Wechselrichter also nennenswert überlastet wird, schützt ihn der 20A Sicherungsautomat. Die Batterie selber könnte natürlich sehr viel mehr Strom liefern.

Damit nicht die Verkabelung selber der Schwachpunkt ist, benutze ich Anschlussleitungen mit 4-6mm2 Querschnitt. Sollte ich mal einen Wechselrichter mit mehr Leistung anschließen wollen, muss der Querschnitt noch größer werden – das ist einer der Nachteile von Gleichstrom, bei Wechselstrom käme man mit viel kleineren Querschnitten hin. Die Klemmen auf der DIN-Schiene kommen damit immerhin klar, die verkraften 10mm2 Querschnitte und 57A Strom. Bei großen Verbrauchern kommt man allerdings nicht mehr umhin, diese direkt an die Batterie anzuschließen, weil kein Zwischenstück das sonst verkraften würde.

Erste Ergebnisse

Auch wenn es noch früh im Jahr ist, konnte ich schon ein paar Erfahrungen mit der Anlage sammeln. Bei guter Sonneneinstrahlung liefert das Panel fast die 50 Watt, für die es nominell gebaut ist. Ist es bewölkt, bricht die Leistung allerdings direkt dramatisch ein und es tröpfeln nur 5-8 Watt in Richtung Batterie. Es macht auch kaum einen Unterschied, ob das Panel direkt auf dem Balkon steht oder hinter dem Fenster im Zimmer, bei voller Sonneneinstrahlung verliert man dadurch nur ein paar Watt. Das kommt mir entgegen, ich habe nämlich keine Möglichkeit, die Zuleitungen permanent nach draußen zu legen. Aber im Sommer ist es ja warm 😉

Eine Sache, die ich aber jetzt schon feststelle, ist die zu geringe Größe der Batterie. Selbst kleinere Geräte (wie z.B. die Energieschleuder in Form des Telekom-Sat-Receivers) mit „nur“ 30 Watt Stromaufnahme lassen sich damit keine 24 Stunden lang betreiben. Die Reserven sind also eher klein und man muss die Verbraucher wirklich selektiv an- und ausschalten.

Oh, und übrigens: die urbane Legende, dass ein Schraubenschlüssel, den man versehentlich an beide Pole der Batterie hält, dort festgeschweißt wird, ist wahr…

Ausbaumöglichkeiten

Mehr geht bekanntlich immer. Als erstes werde ich mit Sicherheit eine größere Batterie kaufen, 100-120Ah sollten es schon sein. Man muss übrigens darauf achten, keine Batterie zu erwerben, die im Betrieb ausgasen kann. Das ist für den Inneneinbau extrem gefährlich. Es kommen daher eigentlich nur Blei-Gel- oder AGM- (Absorbent Glass Mat) Batterien in Frage, die allerdings recht schnell recht teuer und auch schwer werden. Autobatterien hingegen sind ein absolutes No-Go.

Der Laderegler selber hat genug Reserven und eignet sich auch für 24-Volt-Systeme, so dass die Solarkapazität noch bequem erhöht werden kann. Nochmal 50-100 Watt sollten kein Problem darstellen (ok, dann brauche ich einen anderen Sicherungsautomaten, aber die kosten unter 10 Euro).

Wiederum richtig Geld kann man für den Wechselrichter ausgeben. Mit 150 Watt macht man keine großen Sprünge, so ab 500-600 Watt reicht es dann aber für Fernseher etc. Man unterscheidet zwischen den günstigen Wechselrichtern, deren Ausgangsspannung nur eine angenäherte Sinuswelle ist, mit der empfindliche Geräte nicht klar kommen und solche, die eine reine Sinuswelle produzieren. Nicht schwer zu erraten: letztere sind teurer. Der Kauf eines größeren Wechselrichters macht aber erst Sinn, wenn ich eine größere Batterie habe, denn was nützen mit 600 Watt Leistung, wenn ich die nur für 30 Minuten aufrechterhalten kann?

Mehr zu dem ganzen Thema vermutlich in Kürze.

Quadcopter fast flugbereit

Ich denke, ich sollte mal ein paar Worte darüber verlieren, warum es mit dem Status Monitor zur Zeit nicht so richtig weiter geht. Ich habe die Zeit, die ich so für Projekte aufwenden kann für eins verwendet, das ich schon seit fast einem Jahr plane: den Bau eines Quadcopters.

Um überhaupt ein einigermaßen flugtaugliches Gerät bauen zu können, habe ich das Ganze vorher mit dem xcopterCalc durchgerechnet. Der Antrieb besteht aus folgenden Teilen:

  • 4x Turnigy Park 300 1080kv Brushless Outrunner
  • 4x Turnigy Plush 25A ESC
  • 4x 10×4.7 Slow Flyer Propeller
  • 5800mAh 2S LiPo-Batterie

Der Rahmen ist ein Eigenbau mit 50cm Rotorabstand. Er besteht aus Aluminiumrohr für die Arme, Platinenmaterial für alle Platten und Rohrklemmen und wiegt mit Antrieb und Batterie etwa 1 Kilogramm. Leider fehlt mir noch die Steuerelektronik, denn neben einem reinen Funkempfänger braucht der Copter noch eine Steuerplatine, die den komplizierten Teil der Steuerung übernimmt.

Der Plan ist es, ein HobbyKing Multi-Rotor Control Board V3.0 als Steuerung einzusetzen. Für dieses recht universelle Board auf Atmega32-Basis existieren vergleichsweise viele gut entwickelte Firmwares, z.B. QuadControl v4.7 von KapteinKuk. Als Fernsteuerung kommt eine Futaba T8FG mit einem R6308SBT Empfänger zum Einsatz (oder vielleicht erstmal ein billigerer Ersatz, gemessen an dem Grad der Wahrscheinlichkeit eines Unfalls…)

Wenn die Platine kommt, werde ich mal zum Jungfernflug aufbrechen und dann wieder hier posten. Ich würde mal auf folgende Wahrscheinlichkeitsverteilung tippen:

  • 40% Chance, dass die Konstruktion zu schwer ist und überhaupt nicht fliegt
  • 25% Chance, dass der Copter beim Erstflug abstürzt und Schaden nimmt (ich habe eine Menge Ersatzrohr und Ersatzpropeller auf Lager, just in case)
  • 15% Chance, dass der Copter beim Erstflug abstürzt und in Flammen aufgeht (LiPo-Akkus haben unvorstellbarer Feuerpotential…)
  • 5% Chance, dass ich mich an rotierenden Propellern verletze
  • 10% Chance, dass das Ding fliegt aber jede Menge an Trimmung und anderen Einstellungen braucht, bis er gerade fliegt
  • 5% Chance, dass alles auf Anhieb funktioniert wie gedacht

Ich lasse mich überraschen…

Presenting the ICMI MAX7219 Arduino library

For my current project, the ICMI Service Status Monitor, I have chosen the Maxim MAX7219 IC to drive the indicator LEDs. This little chip comes with several nice out of the box features such as adjustable LED current, 16 level brightness control, special decode mode for seven segment displays and so on. The main reason I chose it is because it contains a multiplex scan mechanism implemented in hardware. This frees my own code from a lot of additional complexity that I would encounter if I chose to implement multiplex scanning in software (which is not impossible of course and I’ve already done it – check the code samples for my ICMI Seven Segment Board – but it’s nice not having to do it and besides that, the focus of this projects lies more on the PC/Arduino communication).

Control issues

The downside of using the MAX7219 is the more complex communication with the chip required to make things work. The IC uses various registers to store its configuration state and when sending data, you also have to address the proper register and pass the data in a format specified in the data sheet. To make things easier, I chose to implement this communication in form of an Arduino library that makes using the MAX7219 a whole lot easier by hiding the complexity behind a neat API. Others have implemented such a library before more of course and some of them also offer additional functionality such as multi-chip configuration or CODE B digit decoding. I do not intend to compete with them (at least not yet), I merely took the opportunity of extending my skills.

The code for this library along with example code is available on github at https://github.com/hmbusch/ICMI-MAX7219-Arduino

API description

This section describes the methods available to the user when importing this library. Again: don’t get confused by the uint8_t data type – it is the same as byte in Arduino and can hold an integer value between 0 and 255.

Constructor Max7219(uint8_t dataPin, uint8_t clockPin, uint8_t loadPin, uint8_t digitCount)

This constructor is used to create a new „control instance“ for the connected MAX7219 chip. The IC required 3 Arduino pins – the data pin, the clock pin and the load pin (pins 1, 13 and 12 of the MAX7219) that you need to pass to the constructor. In addition, you have to tell it, how many digits (when using seven segment displays) or rows (that’s what we want) are connected to the driver. This value is used internally to verify the parameters of later method calls. Example (Arduino connected with pins 5, 6 and 7):

 

Method void enable(boolean enable)

The whole LED driver can be shutdown by disabling it. All its settings and the current state are preserved, the chip just ceases to operate. After a power reset, the chip is disabled by default so you will need to call max7219.enable(true) (assuming the control instance was constructed with the name  max7219  as in the constructor example above) if you want it to show something. If you omit this call, all your configuration commands will still configure the chip but you simply won’t see it. Enabling and disabling the driver can also be used to flash the whole display.

Methods void setDigitRaw(uint8_t which, uint8_t value) / void setRow(uint8_t which, uint8_t value)

These two methods are actually only one method with two names. I introduced these names so a user could call whichever method best fits in the context of his program. If your program controls a LED matrix, calls to setDigitRaw() might seem a little strange so you could use setRow() instead.

This is the method that actually tells the driver what to display. You have to specify the index of the row/digit that you want to set (ranging from 0-7, limited by the row/digit count you gave in the constructor) and the value you want to set it to. To make things easier, the method performs a bit level translation of the value from your value to what the MAX7219 expects. This way, the bit order equals the segment or column order. Bit 0 (the rightmost bit, also called the least significant bit) corresponds to segment A (column 1), bit 1 corresponds to segment B (column 2) and so on. To display the number 7 on the fourth digit of a seven segment display, you would pass 3 as the index and  B00000111  (segment A-C lit).

Although the MAX7219 supports it, the library currently does not offer a way to pass a BCD number to the chip. When using BCD mode, you could display a 7 by actually passing a 7 as value and the chip will take care of the decoding to segments. This feature may be included in future releases. The current lack of this feature is the reason why this method is called  setDigitRaw()  and not just setDigit() .

Method void setIntensity(uint8_t level)

The MAX7219 offers a built-in brightness control for the display with a 16 step resolution. This method allows you to set the brightness level for the display and accepts value from 1 (darkest) to 16 (brightest). Any value below 1 will be treated as 1, any value above 16 will be treated as 16. It is not possible to switch off the display, even the darkest setting is still visible and does not stand for „off“. If you want to turn of the display, call  enable(false)  instead. The constructor will set the chip to the highest brightness. This is a sort of safety precaution I created, because the IC’s initial brightness setting defaults to the lowest level. During testing, I wrecked my head trying to figure out why the LEDs were so dim, not realising the brightness settings. For others to avoid this mistake, I reversed the default brightness value in my library implementation.

Method  void testDisplay(boolean testDisplay)

This method can be used to toggle the internal test mode of the MAX7219 on and off. When enabling test mode, the IC switches on all LEDs (regardless of the row/digit count passed to the constructor) and sets brightness to maximum. Enabling the test mode will not overwrite any settings made before entering the test mode, which means when switching back to normal mode, the display will revert to the exact setting that it hade before entering test mode. This method is useful for verifying your LED display and to be able to quickly switch to a fully lit LED panel without having to change each row and saving the state of the display in order to return to that state later.

Method void clearDisplay()

This method does exactly what the name promises: it clears the display by turning all LEDs in all rows off. This operation cannot be undone, that means once you clear the display, you have to reprogram it again, you cannot simply switch back to a previous state.

Method uint8_t version()

In order to provide some hint to a users program regarding the compatibility of the library, this method returns the current version number of the library. This can be used to check programmatically, if the user needs to update to a newer version and it can be used to prevent incompatibility issues.

Using the library

Using this library for your own projects is a two-step process. First, you need to install the library to your Arduino IDE and then you need to import it into you sketch.

Installing the library to the Arduino IDE

Use a file manager to navigate to the directory where your Arduino IDE resides (e.g. D:\Development\Arduino-1.0). Go into the folder called libraries and create a new folder there called ICMIMax7219. Copy the Max7219.cpp and .h files as well as the examples folder into the newly created directory. If your IDE was running at that time, you have to restart it for the changes to take effect. After the restart, go the File => Examples menu. If everything succeeded, you should see and entry called ICMIMax7219 and you can open the BasicFunctionExample from there.

Note: If you have another library for the MAX7219 installed, you may encounter naming clashes when the files of the other library are also named Max7219.*. When encountering this, remove the other MAX7219 library from your Arduino IDE. I will address this problem in the second release of the library.

Using the library in your code

To use the library in your own sketch, you need to import the header file. Do this by placing the line

at the very top of your sketch. This enables you to access the libraries functionality. In order to do so, you need to create an instance of the Max7219 class somewhere in you project. You can do this by calling the constructor as follows

First, the example defines some integer constants to represents the Arduino pins the IC is connected to and the digit/row count. The last line then creates an instance with the name max7219 which can subsequently be used to control the IC with calls like

In order to see a full, working sketch that uses the library, please refer to the BasicFunctionDemo sketch in the examples folder. The video embedded at the start of the post shows you what the output of this sketch will look like on an 8×8 LED matrix.