View Full Version : Seeking MS Excel help for an LED head challenge
Ulophot
13-Dec-2022, 11:08
I have a problem that it would seem MS Excel can handle easily with the right macro(s). Perhaps someone here would be willing help.
I need to map intensity values from an LED panel of 16x16 individually adjustable LEDs and align them to computer coding. The purpose is to be able to make the outer edges of the panel brighter than the center, with some arrangement of intensity tapering inwards, to even out the light a little better than I’ve been able to achieve so far.
My LED-head-builder friend is using an Arduino computer and Visual Studio code, if that makes any difference. He’s understands code; I understand enlarging.
A simplified example, in which the outer LEDs in a panel of 9 are at full intensity and the center one at 50% (0.5 in coding) )would look like this:
1 1 1
1 0.5 1
1 1 1
The complication is that the panel indexes the LEDs in a snaking, sequential order:
1 2 3
6 5 4
7 8 9
From my friend: “If you could create some sort of an Excel script that could take your intensity values and map them to a list like this {i1, i2, i3, i4, i5,..., i256}, we could copy and paste said list into the code, recompile it, and you'd be good to go.”
So, the trick, I’m guessing, is to identify each LED as part of a range of LEDs that all have the same brightness, with each range representing one square of LEDs in the matrix. For example, the outermost range would be the 58 LEDs around the outside border; the next range would be the next square of rows in; and so forth. Please see image below, indicating the outer two ranges at full intensity, the innermost two ranges at a much lower one. Each range ("square row") could then be assigned a brightness value. Again, I’m guessing as to how to make this work in Excel.
233626
In any case, the result should allow me 1) assign a value to each range, and 2) to copy the values of i1, i2, i3…i256 from Excel to the coding program, plug my computer into the Arduino, apply the code, and then test the result in a print.
I can try an Excel forum, but explaining enlarging to folks who only know computers, I have learned, can be an unexpected challenge.
sharktooth
13-Dec-2022, 12:59
I don't think you need macros to do what you're describing. You just need to put in formulas with absolute cell references.
In your 3 by 3 example, it would easier to create a single list if your matrix was set up like this:
123
456
789
It just makes it easier to copy the absolute cell references into a single line.
With your 3x3 example, you could choose a reference cell to store the light value of the outer ring, and different reference cell to store the light value of the middle LED
To get the single string of the whole matrix, you'd copy cell references from the matrix to a single row. You'll need to understand a bit about formulas and cell references in Excel, but it's definitely not hard to do.
ic-racer
13-Dec-2022, 15:58
I'd create a LUT (Look up table). For example, any time the software needs the LED number for column 13, row 2, you use the table and in that position, (13,2) store the value "20" etc.
Graham Patterson
13-Dec-2022, 16:21
If your required intensity map is symmetrical, then it doesn't matter that the LEDs 'snake'.
For a 16 LED row, the sequence 0-7 is the same as the sequence 15-8 (I assume the Arduino is using a zero-based array).
So it does not matter if a row counts up or down. Each row down to half way is the same sequence as the bottom up to half way. Each row is a modulus of 16 for a 16 by 16 grid.
So you need the pattern for half the LEDs, each row fills 16 positions until you get to the middle, and then use the pattern in reverse.
Do you plan on having multiple brightness patterns, or just one? For a single pattern it would pay to define a fixed array. With multiple pattern I'd probably look at loading the working array from a sequence of possible rows. There are trade-offs in computational time versus storage capacity. Personally, I'd probably work out one quadrant by hand on squared paper.
If you use Excel you do a quadrant and then just need to replicate each cell with the right horizontal or vertical offset. Save that as your template and fill in one quadrant to get the full pattern. Each edit in the first quadrant will replicate to the other three.
Ulophot
15-Dec-2022, 10:47
Thank you all for your replies. I truly appreciate your help. Unfortunately, I don't see how they solve my problem.
sharktooth, I am familiar with assigning specific cell references, but I'm looking for a way to avoid one by one, which is the problem I have also with ic-racer's.
Ic-racer, I can relearn how to create a lookup table, but I’m trying to avoid value-by-value creation, which is why I mentioned ranges—maybe not the right Excel term. For example if all the outer border “row” LEDS are part of one “range,” and I can assign a single value to each LED in that “range” with a single entry, I can do the same for each of the other 7 concentric squares, adjusting the value of each square, through testing, to maximize evenness.
I’m afraid I’m pretty much lost with yours, Graham; it seems to assume that I know much more about Excel than you think. To answer your question, I want one pattern; once I have it optimized for what I have, I’ll leave it. But what a modulus is or how a quadrant with one set of numbers can be replicated with a completely different set of numbers, or how this would connect to setting values for complete, concentric squares, I'm afraid is beyond my ken.
So, I was looking for some way to do this efficiently, rather than having to create the grid, fill in the numbers row by row and then assign each cell a value. I’m sure there’s a way to do it; maybe in Graham’s solution that I don’t understand.
Is there an ideal formula which describes the light intensity circle? If so it seems like the thing to do is calculate the ideal light intensity circle and then basically map that to the "pixel values" (i.e. LED units). It could be done by projection, basically for each LED map where it would be located on your ideal light intensity circle and then translate that to concrete values driving the LEDs. The advantage to this approach over a LUT is that you could change the parameters of the Light Intensity circle at any time without having to go back and reference a static LUT.
sharktooth
15-Dec-2022, 11:53
Thank you all for your replies. I truly appreciate your help. Unfortunately, I don't see how they solve my problem.
sharktooth, I am familiar with assigning specific cell references, but I'm looking for a way to avoid one by one, which is the problem I have also with ic-racer's.
Ic-racer, I can relearn how to create a lookup table, but I’m trying to avoid value-by-value creation, which is why I mentioned ranges—maybe not the right Excel term. For example if all the outer border “row” LEDS are part of one “range,” and I can assign a single value to each LED in that “range” with a single entry, I can do the same for each of the other 7 concentric squares, adjusting the value of each square, through testing, to maximize evenness.
I’m afraid I’m pretty much lost with yours, Graham; it seems to assume that I know much more about Excel than you think. To answer your question, I want one pattern; once I have it optimized for what I have, I’ll leave it. But what a modulus is or how a quadrant with one set of numbers can be replicated with a completely different set of numbers, or how this would connect to setting values for complete, concentric squares, I'm afraid is beyond my ken.
So, I was looking for some way to do this efficiently, rather than having to create the grid, fill in the numbers row by row and then assign each cell a value. I’m sure there’s a way to do it; maybe in Graham’s solution that I don’t understand.
I think at this point you need to bite the bullet and spend some time going through some Excel tutorials to figure this out. With Excel, there are usually several ways to achieve the desired result, so it's better if you find a method that "clicks" for you, so you can envision how to use it for what you want to do.
Graham Patterson
15-Dec-2022, 13:11
Cell A1 maps to P1. Row 1 maps to row 16. So, P1 =A1, O1 =B1, etc. where the cell contains =A1 to make the contents equal to the contents of cell A1.
A16 = A1, etc.
One you have row 1 in place, you can copy and paste the first cell in each column into the block below - Excel takes care of the cell references.
You only have to fill in data for cells A1 to H8 (the upper left quarter (quadrant)). The cell formula will replicate the other three quarters. This assumes that your pattern is fully symmetrical.
I don't know how you get the data to the Arduino program - using a CSV export possibly.
Ulophot
15-Dec-2022, 19:07
Thanks again, all. I'll work this out.
(Domaz, I don't know where circles enter into this, so I'm baffled by your approach.)
Nigel Smith
16-Dec-2022, 00:34
not sure if I can upload an excel file but here goes... had to make a zip file...
in the attached, I have created a matrix (I used 2 loops but was having trouble getting it to do the whole grid in one go so ended up just doing the upper left quadrant and then using cell references to duplicate as Graham pointed out... should have read that better earlier!). I remodeled that macro (didn't need it anymore) to create the numbering and create the sequential list. Don't need to re-run that (although you can) because the sequential list just VLOOKUPS the value from the table of values (Col Z). I've just used equally spaced values (1/8) for that however you can replace with whatever value you want.
You could just compute the distance of each LED from the center of the grid and then compute the desired intensity based on this distance. For that purpose you'd need to set up an array of locations for each LED e.g. in a row/column format, or just hard-code an array of distances in the C++/Arduino code that you pre-compute in Excel using the COLUMN() and ROW() functions. You can then parametrically compute the intensity of the LEDs in code, which makes it a little easier to adjust the code to adjust the light intensity increase as you'd just have to change a single parameter in the code that computes the intensity based on distance-to-center. I don't see a need in any case to do this distance calculation with macro's/VBscript in Excel; seems to me it'll work just fine with normal functions - although Nigel's solution is nicely made for sure.
My main concern would actually be the underlying question why this exercise is necessary and how it fits into the larger context. So apparently, there's a problem with light distribution, which brings up the question of the design of the optical path. Assuming this is a diffusor/condensor setup or even a pure diffusor, it seems to me that the easiest solution would just to make a decent light mixing chamber. Increase the distance between the light source and the lens a little, insert a ground glass between light source and lens, construct mixing chamber that's matte white on the inside etc. Work out a combination of these that gives even lighting without reducing baseboard light intensity too much. Given today's LED technology it's pretty easy to get way sufficient light output anyway.
When I built my current LED head I contemplated puzzles like these (I actually saw the same concept being applied in semiconductor lithography equipment, using MEMS mirror arrays conceptually similar to those in DLP projectors), but figured it would basically just be a workaround to a problem that has a more straightforward solution anyway. Think about it - if Ilford managed to get even light output on their 500 heads with two halogen bulbs, it's not much more difficult to achieve the same or better evenness with a LED array without having to resort to intensity-mapping.
If you go this route of intensity-mapping, make sure to test all film formats and enlarging lenses you're going to use as the mapping might be sensitive to these parameters. You don't want to be caught in the situation where your setup works great for 4x5" but turns out to be problematic on 6x6cm or 35mm.
Good luck, sounds like a fun project :)
Ulophot
16-Dec-2022, 08:43
Wow! Nigel, thank you! This is exactly what I had in mind. I trust it was relatively quick for you to do, though it couldn't have been all that quick, with all the work involved. I am very grateful, and it is wonderful to log in this morning and find this, like a present under the Christmas tree.
I have two questions about changing the values.
1. My builder advises that my grid is indexed to zero, rather than one. Is there a quick way to subtract 1 from all the numbers in the relevant place -- I assume it's the top left grid rendered in colors, so that the go 0-255? I can't quite understand the cell references in the column at the far right that have $A$B.
2. I think I understand that the macro has to do with replicating the quadrant, which is no longer needed. To change the value of one of the concentric squares, i simply need to change the value in column Z.
I understand your hardware mapping as a "snake" but I'm lost at how you are going to input the "range values". I think if you could describe what you would like to input in Excel the it would be easier to understand how to get your output.
Ulophot
16-Dec-2022, 09:48
Koraks, thank you. I am going to go with Nigel’s solution, which appears to be what I need. However, in response to your question, and at the risk of boring those who have read my previous posts on this project (who can stop reading this now), here is the reason for the design chosen.
It started when I could not find a commercially available LED head to replace my Zone VI coldlight, which was starting to flicker when powered but not fully on. The man behind Modern Enlargers, who had made several models of die cast LED heads for $400, and whom I contacted, had moved on. I am electronically and constructionally challenged, shall we say, and could not, myself, build one of the DIY models, such as elgatosuizo’s (aka Mark, a member on this board who has generously provided specs for free). In my blithe ignorance, I suggested that someone with skills and time could build one from plywood, making it modular so that an upper module could be made to fit the lower, “business” module to various enlargers. I have a D2. I figured that at about $400, someone could make a decent profit supplying folks like me on a very small scale. (I was advised otherwise by knowledgeable members here.) I had not heard of the Heiland; it may not have been available then, but it’s way out of reach for me anyway.
A new friend, met a year ago, volunteered to build me one using 3D printing. I suggested he use Mark’s design. An IT guy, he chose a different coding language as well as other modifications; he is not a photographer and had no idea of how enlarging works. Many design bumps in the road were encountered and resolved along the way, in spare time, stretching out the time involved. The remaining significant problem was light falloff at the edges of the field projected for a full-frame 4x5 negative through my 135mm lens. Medium-format and 35mm evenness using 80 and 50 mm lenses, respectively, is fine.
The head is a diffusion design, using a single, 1/8-inch-thick acrylic panel spaced appropriately below the LED panel of 256 individually adjustable RGB LEDS (used only as white light as I‘ve always had; I use Ilford contrast filters). The panel is 6x6 inches, the diffuser “window” is 4.5 x 5.5 and, like the round coldlight one, sits about 1/8 inch above the negative carrier when the head is lowered. My 4x5 carrier was modified by Alan Ross and has a 1/16-inch diffuser in the top plate, used for masking.
Some of the drop-off is expected, and some additional amount is due to my having a 135 rather than 150 lens – always have; maybe I’ll be able to replace it sometime. Through testing, however, I found the drop-off excessive. My friend used some formula that relied on circles from the corners to taper the light intensity toward the center. We got it to a point of marginal acceptability for me, but I remained convinced that a scheme such as the one I described and Nigel has provided, would be a more efficient approach, allowing better evenness while increasing overall intensity.
Overall intensity and exposure time are a challenge with the tapering. I believe my approach will allow optimizing the trade-off. As you suggest, another approach could have obviated this. Using the far more powerful green and royal blue LEDs others have recommended, in some array, would have been great. I suggested this and provided several general models to my friend; he chose the panel instead, citing the cost of aluminum heatsinks and related engineering complications. I can’t comment on it and am at his mercy, so to speak; he is building it for free and I am paying for materials, so I just order what he requests. I should add that he thought last January that this would be a weekend project. He will be coming today to wire up the controller he built. He has stuck with the project despite all the trials, and I am most grateful.
Once I optimize the evenness, I’ll post some photos. The design of head and control box, 3D printed, is handsome. Although my friend has expressed interest in making more (though not for free) for others with D2s who might be interested, he has other fish to fry now. If and when he becomes ready to do so, I’ll let folks know.
Ulophot
16-Dec-2022, 09:52
Havoc, I am not a coder, so I don't think I can answer any better than what I quoted several post above from my builder/coder friend. He is using C/C++ coding in Visual Studio. There may be some more figuring out to get the information in Nigel's solution into the code he needs, but it appears that the major work has been done.
Tin Can
16-Dec-2022, 10:02
Perhaps this is the time to show what Intrepid is selling
I just got one
https://intrepidcamera.co.uk/collections/darkroom
Ulophot
16-Dec-2022, 16:22
1. My builder advises that my grid is indexed to zero, rather than one. Is there a quick way to subtract 1 from all the numbers in the relevant place -- I assume it's the top left grid rendered in colors, so that the go 0-255? I can't quite understand the cell references in the column at the far right that have $A$B.
2. I think I understand that the macro has to do with replicating the quadrant, which is no longer needed. To change the value of one of the concentric squares, i simply need to change the value in column Z.
Hi, Nigel. Thank you again for your elegant solution.
RE: the above quoted:
1. My friend came over and found a quick way to make the data from your worksheet a simple copy/paste into the code. No need to change the 1-256.
In addition to question 2, I do have a remaining question. When I went to try changing the values in column Z, changing the top one changed all the ones below. What I need to do -- and perhaps I did not make this clear, so I apologize -- is to change the concentric square independently. I don't know what the final values will be for each square, but, for example, if may be that 1,2, and 3 can all be 1; 4 and 5 0.75, etc. I'll only know when I test. What do I need to do, please, to make these independent? I don't understand the formula =Z2-$AB$2; I'm not familiar with cell references that includes two column references, i.e., $AB (mistakenly written as $A$B. in the quote.
Nigel Smith
17-Dec-2022, 05:12
Uploading the spreadsheet was a bit rushed and not explained much :)
I've changed the LED numbering to 0-255. The macro (you click the button "Run Macro") numbers each cell in the grid A1-P16 and puts that value in the sequential list in column U. It also grabs the corresponding LED REF number from the grid below (A21-P36). Column V does a lookup to the table in cells Y2-Z9. It uses the LED REF number to gets the value (the 'Power factor') you want to assign that LED REF number. The table was set to flow the 8 values from 0-1 roughly (I didn't really check that, just divided 1 by 8 to get the step between each). The $ in the $A$B formula locks that part of the formula so when you copy it down the page, it doesn't change, always referencing that exact cell. You can type anything you want in cells Z2-Z9 (highlight in orange now) and they will be reflected in the list. I've removed that in this latest version and just have numbers in those cells. Also, the shading of the grid is not related to Power factors that you input, that is just equally spaced shades of gray.
@Philip, gotcha; it's great that someone is willing to invest their time in this to help you convert to LED :)
The head is a diffusion design, using a single, 1/8-inch-thick acrylic panel spaced appropriately below the LED panel of 256 individually adjustable RGB LEDS (used only as white light as I‘ve always had; I use Ilford contrast filters). The panel is 6x6 inches, the diffuser “window” is 4.5 x 5.5 and, like the round coldlight one, sits about 1/8 inch above the negative carrier when the head is lowered.
Personally I would have opted to make the diffusor aperture slightly bigger and raise the light source a bit. Some testing (cardboard & duct tape work miracles) would easily show at what point you get good evenness.
Then again, the software route can work out as well, albeit in a Rube Goldberg kind of fashion.
Make sure to verify you get the contrast you need in day to day printing. The RGB LEDs likely won't be able to hit a true grade 5 and remain stuck at 4.5 or even 4 because the blue is generally of too long a wavelength. The practical implication may not be problematic, so just give it a go and see how it pans out. If at some point you find the light source is lacking in the highest grades, you'll know where to look for possible improvements.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.