Jump to content

For y'all logical minds...


Chad

Recommended Posts

I am trying to come up with a simple method to calculate the number of rows and colums that result from distributing a given number of points into a given area.

 

Basically, if I have 48 LEDs and a tank size of 48" x 12", what logic steps will get me to 12 columns and 4 rows with an x and y spacing?

 

What I have right now does this:

I input Length, Width, and the number of LEDs

 

Ratio = Length / Width **Calculate the length to width ratio

Area = Length * Width **Calculate the total area of the space

areaLED = Area / numLED **Calculate the area allotted to each LED

xSpace = Integer of ((areaLED * Ratio) ^ 0.5) **Calculate the x spacing by turning the square root of the area per LED and length-width ratio into an integer

ySpace = areaLED / xSpace **Using the spacing for x and the area per LED, find the space for y

numCol = Length / xSpace **Using the x spacing and the length, find the number of columns

numRow = Width / ySpace **Using the spacing for y, find the number of rows.

 

This works for some lengths, widths, and numbers of LEDs, but falls apart when the x or y spacing does not equally divide into the Length or Width.

 

What do y'all think?

Link to comment
Share on other sites

(edited)

I'm very logical, but I don't get this. :unsure: i'm not technical, though.

Edited by Jan
Link to comment
Share on other sites

If you are going for even spacing between rows and between columns...

 

I would go for something that solves for the set of divisors that match both length and width. For this example,

 

3, 4, 6 and 12 divide into both...

 

If you had 3 rows, you would have 16 per row.

If you had 4 rows, you would have 12 per row.

If you had 6 rows, you would have 8 per row.

If you had 12 rows, you would have 4 per row.

 

There are some boundary conditions to that, but you could throw away partials.

 

The other option is to go with what you have and just round.

Link to comment
Share on other sites

My son and I are dinking with writing a java program to compute this but wondered about an additional data point...width of separation.

 

Is there any data on this? How far apart these lights want to be? Is there any correlation to this datapoint with measure of light beamed down into the tank?

If I want a certain PAR reading could I affect that by changing width and number of bulbs

 

thx

 

 

 

Link to comment
Share on other sites

You want LED's within 2-3" of each other for good spread.

 

 

 

Of course this is a rule of thumb, and how high you hang the fixture will matter some.

 

 

green eggs and ham sam i am lmfao

Link to comment
Share on other sites

LOL, it's not that bad! Get into arduino programming for your DIY LEDs... you'll be neck deep in all of this!! :)

 

(though this is for a side project)

 

If you are going for even spacing between rows and between columns...

 

I would go for something that solves for the set of divisors that match both length and width. For this example,

 

3, 4, 6 and 12 divide into both...

 

If you had 3 rows, you would have 16 per row.

If you had 4 rows, you would have 12 per row.

If you had 6 rows, you would have 8 per row.

If you had 12 rows, you would have 4 per row.

 

There are some boundary conditions to that, but you could throw away partials.

 

The other option is to go with what you have and just round.

 

Thats sort of along what I am thinking... and how I modified it after posting... now I have:

 

Ratio = tLength / tWidth
Area = tLength * tWidth
areaLED = Area / numLED
xSpace = (areaLED * Ratio) ^ 0.5
ySpace = areaLED / xSpace
numCol = Int(tLength / xSpace) + 1
line5:
numRow = numLED / numCol
If ((Round(numRow, 1) <> numRow)) Then
   	numCol = numCol + 1
   	GoTo line5
End If

 

Which works... the code no longer eats itself and now comes up with the first answer that works... not necessarily the best answer

 

In my messing with it just to see what works, I am working with length = 60, width = 12 and 12 LEDs. It comes up with the first good answer, which is 4 columns and 3 rows. However, looking at it, a 6x2 makes more sense in this case...

 

My son and I are dinking with writing a java program to compute this but wondered about an additional data point...width of separation.

 

Is there any data on this? How far apart these lights want to be? Is there any correlation to this datapoint with measure of light beamed down into the tank?

If I want a certain PAR reading could I affect that by changing width and number of bulbs

 

thx

 

Sweet!

 

Not sure, but I think the width of separation is the same as what I am using xspace or yspace for. After my initial "guess" at what xspace and yspace should be, rows and columns are calculated, then xspace and yspace should re reassigned.

 

Um, maybe some answers, I think. Width along with the optic angle provides the amount of "mixing" of various LEDs. There is most certainly a correlation between this datapoint and the total light measure, and potentially a correlation to a PAR reading. Actually, what you hit on there is precisely what icecool and I are working on with this.

Link to comment
Share on other sites

Ratio = Length / Width **Calculate the length to width ratio

Area = Length * Width **Calculate the total area of the space

areaLED = Area / numLED **Calculate the area allotted to each LED

xSpace = Integer of ((areaLED * Ratio) ^ 0.5) **Calculate the x spacing by turning the square root of the area per LED and length-width ratio into an integer

ySpace = areaLED / xSpace **Using the spacing for x and the area per LED, find the space for y

numCol = Length / xSpace **Using the x spacing and the length, find the number of columns

numRow = Width / ySpace **Using the spacing for y, find the number of rows.

 

Chad, why (in the fourth step) do you take the integer? It seems that xSpace is floating point. If you leave it as such, then

 

x = l/sqrt(n) and x = l/sqrt(n)

Then, xy = wl/n = a, where

 

x = xSpace

y = ySpace

n = numLED

l = length

w = width

A = xy = area of heatsink

a = A/n = area per LED

Link to comment
Share on other sites

Let me add this:

 

The INT argument is (a/R)^0.5 where a = A/n and A = lw and R = l/w. Making substitutions, I arrive at

(a/R)^0.5 = (A/nR)^0.5 = (lw^2/nl)&0.5 = w/sqrt(n);

likewise the other becomes l/sqrt(n)

Link to comment
Share on other sites

I concur!!!! ;)

 

Let me add this:

 

The INT argument is (a/R)^0.5 where a = A/n and A = lw and R = l/w. Making substitutions, I arrive at

(a/R)^0.5 = (A/nR)^0.5 = (lw^2/nl)&0.5 = w/sqrt(n);

likewise the other becomes l/sqrt(n)

Link to comment
Share on other sites

I think, though, by assuming that the aspect ratio of the heat sink per LED is the same as that for the entire heatsink, that you set yourself up for a possible problem where the number of LED's in one dimension is the same as in the other. You may not want that. That is, if I'm reading this right.

 

Perhaps a better solution can be had by envisioning a pattern of juxtapositioned circles with an LED at the center of each circle. This may be better for heat distribution, too.

Link to comment
Share on other sites

Get an estimate and then just saw off the remaining heatsink to make it fit the model. :biggrin:

Link to comment
Share on other sites

The initial "make it an integer" in line four was a mistake, which I caught shortly after posting... it should have been on the column calculation, which I switched in my above post.

 

Tom, you are exactly right on maintaining the aspect ratio and running into problems... that's how I originally had it. However, I think it sets you up for a better initial guess than just (area per LED)^.5

 

I have it working well now since it always gives a good answer (i.e., non-decimal rows and columns), but it's not always the answer I want.

Link to comment
Share on other sites

I have it working well now since it always gives a good answer (i.e., non-decimal rows and columns), but it's not always the answer I want.

Try circles. In the end, though it won't be perfect. Estimation is probably adequate unless you're trying to dense-pack them. In this case, try establishing the max fit using hexagons and establish an aspect ratio. Then, make allowances for the fact that the heat sink aspect ratio may not be perfect match.

Link to comment
Share on other sites

Got it.

 

	ratio = tLength / tWidth
Area = tLength * tWidth
areaLED = Area / numLED
xSpace = (areaLED * ratio) ^ 0.5
ySpace = areaLED / xSpace
numCol = Int(tLength / xSpace)
line5:
numRow = numLED / numCol
If (Int(numRow) <> numRow) Then
	numCol = numCol + 1
	GoTo line5
End If
If ((numCol / numRow) < ratio) Then
	numCol = numCol + 1
	GoTo line5
End If
xSpace = tLength / numCol
ySpace = tWidth / numRow

Link to comment
Share on other sites

More lines of code than I wanted, but it does do what I want it to in all ways I could think to test it.

 

Prime numbers of LEDs give funny answers... but that's a low risk.

Link to comment
Share on other sites

Interesting iterative approach. It looks like you first find a candidate numCol before qualifying it with your numRow estimate. And, if it doesn't qualify, then you increment numCol and continue to find something acceptable. This works but assumes numRow * numCol = numLED from the outset. That's acceptable, I assume - or the requirement?

 

Since the algorithm seems to assume that numRow * numCol = numLED, while assuming numLED at the outset, you need only determine the set of factors for numLED and compare the set of corresponding ratios. Right now, it looks like your algorithm stops at the first acceptable ratio.

Link to comment
Share on other sites

Interesting iterative approach. It looks like you first find a candidate numCol before qualifying it with your numRow estimate. And, if it doesn't qualify, then you increment numCol and continue to find something acceptable. This works but assumes numRow * numCol = numLED from the outset. That's acceptable, I assume - or the requirement?

 

Since the algorithm seems to assume that numRow * numCol = numLED, while assuming numLED at the outset, you need only determine the set of factors for numLED and compare the set of corresponding ratios. Right now, it looks like your algorithm stops at the first acceptable ratio.

For example, 48 LEDs. The paired-factors are: (1, 48), (2, 24), (3, 16), (4, 12), (6, 8), etc. You can readily calculate the ratios, then select the option that best fits your needs.

 

Edit: The best option may not be the one identified by the algorithm as the algorithm identifies the first ratio that falls below the heatsink aspect ratio. The next adjacent one may be better. You may want to compare and minimize the error from the ideal aspect ratio for the best fit.

 

More edits: For example, if the heatsink were 60 x 12, the ratio is 5. Do you pick the 16/3 = 5.33 distribution which is off by 6%, or go with the 12/4 = 3 ratio, which is off by 40% but is the one that meets the test criteria of 3 < 5?

 

Why are you doing this on an Arduino?

Link to comment
Share on other sites

That may be a better way to go about it and may eliminate my "first guess." Mostly, though, I just want a number that is around the one that I would choose and is not a decimal.

 

Tom, Im sending you an email.

 

(not doing it on arduino, just relating to the thing some folks may relate to).

Link to comment
Share on other sites

(not doing it on arduino, just relating to the thing some folks may relate to).

Whew. That's a relief. And here I thought you were doing it for the challenge. :biggrin:

 

Engineers. What can you say?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...