Olin, what have you been talking about so long? Was it in few words: At full load: the PWM duty cycle =3D PWM Period, say 255 At each step when dimming divide PWM duty cycle by some value,=20 say 2. (255,127,63,...) Loop until LED brightness will get less then=20 brightness of an environment (you may use A/D with photosensor=20 to catch the level) .=20 By the way, the divider value may be modified at each step to get=20 desired curve. You style is really cool: ... > 1 1 > 2 1.06 > 3 1.12 > 4 1.18 > 5 1.25 ... > Of course you will have to round the output values above. =20 Of course we will, and what do you suggest we'll get? Mike. SomebodyWhoIsAlmostNeverMentioningWhomHeRepliesTo wrote: > The preceived brightness is essentially the logarithm of the actual > brightness, and the actual brightness of LEDs is reasonably linear to > current. First you have to decide what dynamic output range you can > produce, then map that to the non-zero intended brightness values > logarithmically. Since the log will never let you get to zero, you > arbitrarily assign 0 input value to LED completely off. Note that you > will lose resolution in the conversion, but how many different brightness > levels do you really need? >=20 > Let's do an example. You are using 8 bit PWM output, so the linear > brightness can vary from 0 to 255, with 0 completely off and 255 > completely on. The dynamic range of the non-zero output values is 255/1. > Now map this range logarithmically to the non-zero range of input number. > If the desired perceived brightness values are 0-100, then 1-100 maps to > output values 1-255 lograithmically. In other words, each single step up > in the 1-100 range increases the output value by a fixed *multiple* (fixed > increment would be linear). There are 99 steps from 1-100 to cover the > dynamic range ratio of 255. The step multiple is therefore the 99th root > of 255, or >=20 > StepRatio =3D DynamicRange ** (1 / NSteps) > =3D 255 ** (1 / 99) > =3D 1.057568 >=20 > The output value resulting from each non-zero input value is then: >=20 > output =3D StepRatio ** (input - 1) > =3D 1.057568 ** (input - 1) >=20 > Since logarithms don't go to zero, you arbitrarily assign input 0 to > output completely off. So here are a few sample input and output values: >=20 > INPUT (0-100) OUTPUT (0-255) > 0 0 > 1 1 > 2 1.06 > 3 1.12 > 4 1.18 > 5 1.25 > 10 1.65 > 20 2.90 > 30 5.07 > 40 8.87 > 50 15.53 > 60 27.18 > 70 47.56 > 80 83.25 > 90 145.70 > 100 255.00 >=20 > Of course you will have to round the output values above. >=20 -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body