LED grow light - Page 1
Forum section: electronics / projects

author: tooki
author_rank: Super Contributor
timestamp: February 08, 2016, 11:48:20 am
content: For years, I've had problems with my houseplants (mostly chiles, but also some citrus) perishing over winter indoors. I had chalked it up to just having a black thumb, but my roommate thought it was insufficient light. So we started just turning on a desk lamp at night to shine on the plants. Lo and behold, that seems to be it! The plants are now beginning to grow new baby leaves to replace all the ones they shed. So I began thinking about building some kind of grow light, probably using LED strips as the light source.Anyway, I stopped at a local electronics shop to pick up a broken LCD monitor I had intended to salvage optical films from fora different project. The 32 inch TV that was all they had in their junk bin ended up not having the optical films I needed. But its old-school CCFL backlight box is the perfect size and shape to make a light panel to illuminate the plants, and has a lovely thick, robust diffuser panel. Unfortunately, the power supply board in this TV appears to be shot (I suspect that's why it was thrown out to begin with), so I can't use its CCFL lighting to hold me over until the LED strips arrive.So my plan at this point is to rip out the CCFL tubes and glue a bunch of LED strips inside. The Tim the Toolman Taylor in me of course wants to line the thing completely with LEDs, but a back of the envelope calculation said that'd be about 240 W, which would probably set the plants on fire. A more realistic plan is to line it with two different types of LED strips:white LEDs for when humans are inhabiting the room, and red and blue ones as more energy-efficient grow light for when it's just the plants.(I actually found some neat LED strips on eBay that contain dual-color warm white/cool white LEDs so you can tweak the color temperature.) I was thinking that somewhere in the ballpark of 30 W each for white and red/blue would be more than enough.I know that in theory I could use RGB LEDs to cover both use cases, but I really hate the sickly white of RGB, which is why I want to have the option of true white LEDs.Other than making sure I have an adequately specced power supply, is there anything I'm missing? I haven't decided whether to use off-the-shelf remote control modules, a bank of manual power switches, or even an Arduino to control the brightness. I'm open for suggestions if anyone has experiences to share.On the subject of power supplies: obviously you can get cheap Chinese made power supplies, but that's probably a bad idea. Thelocal electronics distributorsells both open-frame and laptop-style power supplies from both TDK-Lambda and Mean-Well. The cheapest models don't have great efficiency, and they don't specify there no-load power draw. Would I be correct to assume that it's higher than the <0.5 W no-load power draw specified in the better models? Are there any advantages or disadvantages of one brand over the other, or of open-frame versus laptop-style?Edit:Added bolding to show people that I am very aware that white LEDs are inefficient for photosynthesis, since people keep reminding me of this despite me explaining repeatedly that a) I know this, and b) the reason.

author: nowlan
author_rank: Frequent Contributor
timestamp: February 08, 2016, 12:47:35 pm
content: Easiest would be to get some T8 led tubes.I wouldnt worry about red/blue leds. White lets are blue with phosphor. There is a lot of information about corals/weed using led lights. I would just look at someones build. Get some crees and a meanwell power supply. Supplement the day hours.

author: rs20
author_rank: Super Contributor
timestamp: February 08, 2016, 01:04:27 pm
content: Plants reflect green (source: I just looked outside), so red and blue is ideal if all you care about are the plants:White LEDs are questionable because they're typically blue LEDs withyellowphosphors. Whether the yellow light is within the "red" range that plants accept is not something I know. It's certainly not reasonable to just assume that'll work well though.The T8 led tubes will have this same potential problem. Red/blue LEDs, or real fluorescent lights (like, nice $8 high-CRI ones, not the $2 crap at the supermarket), or indeedred/bluefluorescents are preferable. 600mm and 1200mm both available.Plug: fluorescents don't flicker either if you use a proper electronic ballast. Did I mention that I think fluoros are underrated?

author: Siwastaja
author_rank: Super Contributor
timestamp: February 08, 2016, 01:26:17 pm
content: Quote from: rs20 on February 08, 2016, 01:04:27 pmYou are on the right track; the yellow phosphor isn't inside the desired range. Quite the opposite, the "red" that the plants want is on the longer side, which is why "deep red" 660 nm LEDs are used. White LEDs optimize by not providing these long wavelengths which give too little visible lumens to the eye per watt.White leds make absolutely no sense. If something is going to be DIYed, then it's just easiest to pick those deep blue and deep red (i.e., 445/450 nm and 660 nm) LEDs. There are specific "grow light" LEDs which are like white leds, but with red phosphor, but I can't see the convenience in using just one type of LED.

author: tooki
author_rank: Super Contributor
timestamp: February 08, 2016, 02:13:41 pm
content: Quote from: nowlan on February 08, 2016, 12:47:35 pmWhy would LED "tubes" be preferable to LED strips that are so easy to work with?Cree LEDs (I assume you mean the high-wattage COB types) would certainly work, but they'd be a lot more work to assemble and ensure cooling for, and would ultimately create less even light than the strips. The white LED strips I'm looking at are about 10W/meter, with a 5m strip costing a whopping $7 or something, and are already evenly spaced on adhesive and don't require additional cooling. If I get the special grow light strips (660nm deep red + 445nm blue), they're around $35 for 5m.Quote from: rs20 on February 08, 2016, 01:04:27 pmFluorescent can be good indeed, but given that I want to be able to dim them down so they're not blinding me when I'm in the room, LED is probably much, much easier to deal with. (Dimmable fluorescent ballasts cost a fortune anywhere, and here in Switzerland, 10 fortunes.)Besides, the lightbox is only about 2cm thick, so T8 tubes wouldn't fit inside anyway.But speaking of flicker: If I did decide to use PWM dimming (either via an off the shelf controller, or a DIY Arduino solution), and I found flicker to be objectionable, is there any reason I couldn't use some electrolytic caps to smooth it out? I've done that on a small scale (LED backlight dimming on an LCD module) but don't know how well that would scale up to a multi-watt scenario. If I don't do PWM, I'd simply have switches to switch x amount of the strips on or off. (Assuming I installed the full 5m, it's enough for 7 strips across the panel.)Quote from: Siwastaja on February 08, 2016, 01:26:17 pmAs I said, the reason for having switchable whiteandred/blue LEDs is that since the plants indeed cannot use green light for photosynthesis, it means that theoretically 1/3 of white light is simply wasted. (And that would be assuming white LEDs had a fairly even spectral energy distribution, which they don't necessarily.*)So the idea is that when nobody is in the room, the light panel can be set to photosynthesis-optimized red/blue, and when humans are in the room and don't want to be inside a giant magenta chamber, switch it to white, which works as both room lighting and inefficient (but better than nothing) plant lighting.*There are three types of white LEDs:- RGB (i.e. three chips, seldom seen today except as the multi-leaded type intended for multi-color use. There were for a while RGB LEDs that had just two leads, to be used only as white.- blue LED with yellow phosphor (apparently the most common)- UV LED with white phosphor (and of course, the phosphor here could have any of a number of compositions, just as in the white phosphors of fluorescent tubes)

author: Zero999
author_rank: Super Contributor
timestamp: February 08, 2016, 03:00:48 pm
content: Quote from: tooki on February 08, 2016, 02:13:41 pmNo, it will increase the power consumption and could even damage the transistors.Also note that PWM is not a very efficient way to control the brightness. LEDs are more efficient at lower currents so it's more efficient to just reduce the forward current. PWM is often used because it's more convenient and the spectrum of some phosphor coated LEDs can change with the forward current so sometimes it's better to keep it constant and reduce the duty cycle.

author: Fungus
author_rank: Super Contributor
timestamp: February 08, 2016, 04:09:45 pm
content: Quote from: nowlan on February 08, 2016, 12:47:35 pmWhite is the totally wrong color for photosynthesis (it will work but you're throwing energy away...)The lamps they sell on eBay seem to have 2 orange LEDs for every blue LEDeg.http://www.ebay.com/itm/131585886673Edited to insert the proper quote...

author: tooki
author_rank: Super Contributor
timestamp: February 08, 2016, 04:26:14 pm
content: Quote from: Fungus on February 08, 2016, 04:09:45 pmI guess you didn't read either my original post nor the reply...

author: Fungus
author_rank: Super Contributor
timestamp: February 08, 2016, 04:30:35 pm
content: Quote from: tooki on February 08, 2016, 04:26:14 pmYou're assuming that was what I was replying to.(I messed up the quote... now fixed)Do you need a different color for when humans are in the room? Won't it be enough to just switch on the LEDs when the humans are away? That would simplify things a lot (you even could have a light sensor and turn off the LEDs when there's enough normal light in the room)

author: tooki
author_rank: Super Contributor
timestamp: February 08, 2016, 04:37:34 pm
content: Quote from: Hero999 on February 08, 2016, 03:00:48 pmThanks! I've seen reference to using caps (well, a simple RC network) to convert the PWM to analog, and then using that to drive a FET to control the load. Would that work here, or would I just be burning off the excess voltage as heat? (Cuz indeed, my intent was to make this thing brighter than needed in everyday use, such that it would normally be driven well below its maximum.) Or is there a better approach I'm not thinking of (dimmable CC source??)?

author: tooki
author_rank: Super Contributor
timestamp: February 08, 2016, 04:48:39 pm
content: Quote from: Fungus on February 08, 2016, 04:30:35 pmAh, okay!Quote from: Fungus on February 08, 2016, 04:30:35 pmIt's a sort of nice-to-have, easy-to-do thing. I'm often awake late at night, so there's significant overlap between the times the room is occupied and when the plants need extra light. (Here in Switzerland, at winter solstice there are less than 8.5 hours of daylight, so even if I weren't a night owl, adding artificial pink light to the end of the day would still be an issue.)One could, of course, have a motion sensor to detect human presence and automatically switch from the pink grow light to white when people are around. :pIn any case, my questions aren't really dependent on the color of LEDs in question. We can think of this as two entirely distinct LED panels that will happen to share a single housing for convenience reasons. Besides, this being an engineering forum, I think we can all appreciate "Because I can!" as a reason to do something unnecessarily complicated.

author: Fungus
author_rank: Super Contributor
timestamp: February 08, 2016, 05:10:27 pm
content: Quote from: tooki on February 08, 2016, 04:48:39 pmYou mean like one of those new offices where you have to stand up and wave your arms every ten minutes to keep the lights on and not freeze to death?Quote from: tooki on February 08, 2016, 04:48:39 pmSure.The motion-sensor part in particular could get easily become... "interesting".

author: tooki
author_rank: Super Contributor
timestamp: February 08, 2016, 05:51:45 pm
content: Quote from: Fungus on February 08, 2016, 05:10:27 pmOh dear god, perish the thought!! (I chill easily when seated doing office work.) On the other hand, forcing me to stand up and wave every 10 minutes would be really, really good for my repetitive strain injury (my docs have ordered me to take very frequent stretching breaks from desk work)!Of course, here in Switzerland, people areobsessedwithairing outrooms("It's stuffy!"), so in the dead of winter when it's -5C out, they'll fling open the ultra-efficient triple-glazed, rubber-gasketed windows and air out the office for 20 minutes, so then I freeze anyway. (Not hyperbole. I've experienced this countless times.) Of course, when it's summer and warm and finally a cool breeze decides to gently blow, they complain that "it's drafty!" and shut the windows...Quote from: Fungus on February 08, 2016, 05:10:27 pmAye. But it would first require settling on a dimming method.

author: Fungus
author_rank: Super Contributor
timestamp: February 08, 2016, 05:58:56 pm
content: Quote from: tooki on February 08, 2016, 05:51:45 pmAye. But it would first require settling on a dimming method.If they're cheapo 12V LED strips with built-in resistors then use an Arduino and a logic-level MOSFET.If they're high-power LEDs then use an Arduino and an LED driver which has aPWM input.The Arduino gives you all sorts of possibilities for sensors, remote controls, etc.

author: mazurov
author_rank: Frequent Contributor
timestamp: February 08, 2016, 06:14:03 pm
content: White LED are less efficient for grow but they are so much cheaper, especially when you want to build something bright, like this ->https://www.circuitsathome.com/diy-2/high-power-led-grow-light-a-build-log. This light is now ~3 years in operation; combined with hydroponics it gives outstanding results. Peppers are very happy.Another thing I'm experimenting with are lightweight fanless fixtures made with small 100 mA emitters. I hang some of the lights vertically around the plant to provide intra-canopy illumination.

author: tooki
author_rank: Super Contributor
timestamp: February 08, 2016, 06:52:06 pm
content: Quote from: mazurov on February 08, 2016, 06:14:03 pm$20-30 for a 5m strip of 660/445nm grow light LEDs (totaling 72W) doesn't seem that expensive to me. Yes, it's a lot more than white LEDs, but given how much more efficient it must be, probably makes sense in the end.

author: mazurov
author_rank: Frequent Contributor
timestamp: February 08, 2016, 07:26:50 pm
content: QuoteYou also need 620nm. Then you need to look at specific emitters - I have some Chinese 10W "620" which are in fact white with red filter in front of the phosphor. Real ones are quite a bit more expensive. For example, quarter watt LXM3-PD01 costs ~$1.5/pc today when you buy 1000pcs; for 72W fixture you'll need 24 of those which gives you $36 just for 660 band.QuoteThis depends of where you place "the end". When I was doing cost analysis the break even point appeared to be around 70 years from now, at current rate of change of electricity prices where I live.Prices in US dollars.

author: tooki
author_rank: Super Contributor
timestamp: February 08, 2016, 08:13:16 pm
content: Quote from: Fungus on February 08, 2016, 05:58:56 pmHence my still unanswered question: Could one use an Arduino to create PWM, smooth that to analog, and then use that to drive a MOSFET or whatever to allow flicker-free control of the LEDs? Or were you suggesting PWM all the way to the LEDs?Quote from: Fungus on February 08, 2016, 05:58:56 pmI've stated consistently throughout this thread that my intent is to use 12V strips. That's because individual high-power LEDs a) are mechanically/thermally more complicated, and b) would not be as diffuse a light.

author: dfmischler
author_rank: Frequent Contributor
timestamp: February 08, 2016, 08:18:56 pm
content: I know you know all this. It's for everybody else reading this.Plant Productivity in Response to LED Lighting

author: rs20
author_rank: Super Contributor
timestamp: February 08, 2016, 10:54:59 pm
content: Quote from: Hero999 on February 08, 2016, 03:00:48 pmSo one solution is to use a smoothing capacitorin combination with an inductor, right? That way you're basically making an open-loop buck converter; the transistors are OK because the inductor prevents current spikes, you get the efficiency/current boosting effect of a buck converter, and the LEDs are running on a nice constant current.Incidentally, there are specially designed LED buck converter chips which do all this for you, although you can just PWM it from a MCU too.

author: rickey1990
author_rank: Regular Contributor
timestamp: February 09, 2016, 12:02:30 am
content: Well a project of mine last year, also been experimenting with cheap super caps and a hand crank for instant bright light. Using a modified camera flash circuit out of a disposable camera. Four led bulbs being driven from a 1.5v battery. Obviously the battery doesn't last to long but running off a solar charger bumped down to 1.5v's there not too bad. 60LEDS on each bulb.

author: Fungus
author_rank: Super Contributor
timestamp: February 09, 2016, 05:57:10 am
content: Quote from: tooki on February 08, 2016, 08:13:16 pmYoucoulddo that but it's tricky and there's no need.Quote from: tooki on February 08, 2016, 08:13:16 pmPWM all the way to the LEDs.The standard Arduino "analogWrite()" function outputs a 1kHz PWM signal so you're not going to see any flicker.

author: Siwastaja
author_rank: Super Contributor
timestamp: February 09, 2016, 07:21:09 am
content: Just PWM the LEDs. Filtration doesn't make any sense.LED efficiency is practically constant unless you are near or exceeding recommended maximum current rating. Maximize efficiency, lifetime and ease thermal design by running the LEDs at slightly below recommended maximum current. PWM at high enough frequency so that you don't visually see the flicker. Anything above, say, 200-300 Hz, works. I guess the Arduino library uses something around 1 kHz which is optimal.

author: tooki
author_rank: Super Contributor
timestamp: February 09, 2016, 11:54:35 am
content: Quote from: Fungus on February 09, 2016, 05:57:10 amUnfortunately that's incorrect. It's around 490Hz, which at low duty cycles causes very obvious flicker. If one is willing to sacrifice accuracy of internal timers, it's possible to raise it, though.Can you summarize the trickiness that would be involved in doing the smoothing -> MOSFET route?Quote from: Siwastaja on February 09, 2016, 07:21:09 amBecause LEDs react instantly to being turned on or off, the flicker thresholds that worked for CRTs and other things do not apply to LEDs. At low duty cycles, PWMd LEDs flicker perceptibly at frequencies far, far higher than people think. That's why LED driver chips use PWM frequencies from the tens of kilohertz all the way beyond a megahertz. LED-backlit LCDs also use PWM at over 200KHz (or analog dimming).I know from personal experience that I readily see annoying flicker with Arduino's 490Hz PWM at duty cycles below about 30%. I also routinely notice (and am annoyed by) flicker in dimmed LED lighting at bars and restaurants here, which I assume are using COTS LED dimmers. My concern about flicker, and willingness to go to significant lengths to avoid it, are because I know I am sensitive to it and know that it annoys the living shit out of me.

author: Fungus
author_rank: Super Contributor
timestamp: February 09, 2016, 05:07:08 pm
content: Quote from: tooki on February 09, 2016, 11:54:35 amUnfortunately that's incorrect. It's around 490Hz on 8-bit timers but980Hzon 16-bit timers.Ref:https://www.arduino.cc/en/Reference/AnalogWriteAnd ... you caneasilyhave frequencies much higher than that. It's one line of code: Just subtract a value or two from the clock divider on the corresponding timer (Warning: timer0 generates the millis() interrupt so millis() will run faster if you do this on timer0).Quote from: tooki on February 09, 2016, 11:54:35 amIf you can see flicker the Arduino hardware isn't the problem, the problem is with the code. The Mega328 chip is capable ofmuchmore than Arduino's "easy-for-total-newbies-to-use" libraries expose.(nb. make sure you can drive your MOSFET gate hard enough at the chosen frequency - that's the real limiting factor to the highest frequency you can drive the LEDs at).

author: Zero999
author_rank: Super Contributor
timestamp: February 09, 2016, 08:01:38 pm
content: Quote from: tooki on February 08, 2016, 11:48:20 amWhat's the temperature where you're growing the plants?Perhaps it's too warm. When it's warm, the plants will be expecting there to be enough light to grow so won't go dormant, which could be causing them to die. Reducing the temperature to the minimum acceptable, without causing any damage to the plant tissues, may help by making them dormant, so the extra light isn't needed to keep them alive.Citrus plants should be fine down to 5oC. I don't know about chillies though. If you can keep the temperature below 18oC, then the growth will stop and the extra light won't be needed.

author: tooki
author_rank: Super Contributor
timestamp: February 10, 2016, 03:10:08 am
content: Quote from: Fungus on February 09, 2016, 05:07:08 pmDude, is it really necessary for you to bicker about irrelevant details (whether it's 490Hz or 980Hz is inconsequential; either is much too low) and ignore the questions that would actually help me complete the project?? I really cannot tell if you're doing this unintentionally, or if you're trolling me.Your original statement was:Quote from: Fungus on February 09, 2016, 05:57:10 amI said it's incorrect because that WILL cause me to see flicker. I know this cuz I've tested it, and the fact that LED PWM is often done at massively higher PWM frequencies (100s of KHz - 1MHz) is because many people perceive PWM flicker on LEDs at low duty cycles.Quote from: Fungus on February 09, 2016, 05:07:08 pmAnd this remark, repeating what I already said in the post you're responding to, helps further the discussion how?Quote from: Fungus on February 09, 2016, 05:07:08 pmThe Arduino platform is the combination of the AtMega chips and the libraries and IDE. You are correct that the Mega328 can be manually driven to bit-bang much higher PWM speeds (I knew that before starting this thread), but I am not a programmer and going deeper than the Arduino libraries probably goes beyond what I can code and debug.I'd still love to find out what it would take to Arduino-control a true analog output that could in turn do true analog control of the LEDs, if somebody is willing to indulge me.

author: tooki
author_rank: Super Contributor
timestamp: February 10, 2016, 03:13:30 am
content: Quote from: Hero999 on February 09, 2016, 08:01:38 pmYou're certainly right, but since I live in a 1 bedroom apartment, there's no way to reduce the temperature of the plants' environment without also changing my own environment to temperatures decidedly outside my comfort zone! (It's about 21C in here, and that has me hiding under a blanket.)

author: rs20
author_rank: Super Contributor
timestamp: February 10, 2016, 05:26:08 am
content: Quote from: tooki on February 10, 2016, 03:10:08 amI already told you:Quote from: rs20 on February 08, 2016, 10:54:59 pm

author: Fungus
author_rank: Super Contributor
timestamp: February 10, 2016, 02:18:49 pm
content: Quote from: tooki on February 10, 2016, 03:10:08 amThen:a) You tested it wrong, orb) You have superhuman eyes and should go and see a specialist to be studied for posterity.Quote from: tooki on February 10, 2016, 03:10:08 amNo it isn't:https://encrypted.google.com/search?q=led+pwm+frequencyThe frequency response of human eyes is well studied:https://en.wikipedia.org/wiki/Flicker_fusion_threshold

author: Fungus
author_rank: Super Contributor
timestamp: February 10, 2016, 02:22:23 pm
content: Quote from: tooki on February 10, 2016, 03:10:08 amAs I said before, it's one line of code (and I'll be happy to tell you what that line is, all I need to know is what pin you're using for PWM).Quote from: tooki on February 10, 2016, 03:10:08 amAll you need is a big inductor and a current sensor connected to your Arduino.Make a feedback loop, ie. turn MOSFET on if there's too little current, turn if off if there's too much.Code:if ( analogRead(CURRENT_SENSOR) < preset_value ) {digitalWrite(MOSFET,1);}else {digitalWrite(MOSFET,0);}That's it.If that loop is running very fast then the effect is constant-current at the defined value.Quote from: tooki on February 10, 2016, 03:10:08 amI thought you said you were an engineer who wanted a challenge...

author: tooki
author_rank: Super Contributor
timestamp: February 11, 2016, 04:21:14 am
content: Quote from: Fungus on February 10, 2016, 02:18:49 pmSorry, you're wrong. I did not "test it wrong". I had the LED hooked up, and a scope as well, measuring the frequency and duty cycle. The fact is, at 490Hz I can readily detect flicker at low duty cycles, as many people can. (Just Google "led pwm flicker" - you'll find plenty of people who agree.)The flicker fusion threshold applies to an unmoving light source. The problem is, we don't stare at light bulbs in normal use. They're around us, and we look at things, which we do by moving our heads, and our eyes within them (saccades). The second you move your eyes quickly, a frequency that was fine without motion suddenly breaks into a series of flashes precisely because we have a certain amount of persistence of vision. You know those displays that go on car tires and display messages and stuff? That's precisely the effect in action. If you took one of those wheel displays and looked at it when not moving, you'd see a bunch of unblinking, unflickering LEDs. But move them quickly and it breaks into discrete dots of light. THAT is the flicker people like me perceive in slow PWM lighting. It's annoying as fuck, it's not imaginary, and it's entirely reproducible.http://www.tftcentral.co.uk/articles/pulse_width_modulation.htmhas an image that illustrates the problem, precisely as I experience it.And this discussion on stackexchange goes into it more, and suggests that to successfully eliminate it, PWM frequencies of as high as 15KHz are necessary:http://physics.stackexchange.com/a/19056I looked at the LED driver chips again, and must confess that I misread one datasheet and confused its buck converter switching frequency with its PWM frequency. The PWM frequency is "only" 20KHz.Quote from: Fungus on February 10, 2016, 02:22:23 pmI want to learn electronics engineering, not software engineering. (Indeed, one of the reasons for me getting back into electronics is to be doing something more physical, because I have RSI problems that require me to limit computer use.) I'm willing to do the minimum in software that is necessary to complete a project, but it's expressly what I don't want to be doing! :pI've said twice already that I know how to tweak Arduino's PWM, and that I know what other consequences that has. What I definitely don't want to do is the other approach, which is to circumvent the Arduino PWM (analogWrite) altogether and bit bang it by writing directly to registers or something, for the aforementioned reason that I lack the skills to debug that. (And I don't want to acquire that skill either, lest I spend even more time at the computer and ruin my hand even more...)I think I understand what you're saying with the feedback loop. Let me refresh my knowledge on inductors (something I've never used in any project so far, so something I'm very green on) and get back to you.

author: tooki
author_rank: Super Contributor
timestamp: February 11, 2016, 04:23:16 am
content: Quote from: rs20 on February 10, 2016, 05:26:08 amSo you did! I somehow managed to overlook that part.I'll do my homework and come back with my inevitable questions, ok?

author: Fungus
author_rank: Super Contributor
timestamp: February 11, 2016, 08:24:32 am
content: Quote from: tooki on February 11, 2016, 04:21:14 amIs writing to registers bad? I must inform Atmel.Quote from: tooki on February 11, 2016, 04:21:14 amTheentirecode for increasing the PWM frequency of pins 9+10 on an Arduino Uno would be this (do it once in your setup() function):Code:--TCCR1B;Pins 3+11...?Code:--TCCR2B;You can do very precise frequency control if you know what you're doing, but ... if you just want it to go a lot faster then that will do the trick. You want even more? Do it twice.Quote from: tooki on February 11, 2016, 04:21:14 amThey just try to keep constant current using their magnetic field as a buffer.You can do the same feedback-loop thing with a comparator if you want but a microcontroller makes everything a bit easier to fiddle with all the levels. And you wanted remote control. Microcontrollers are good at that.

author: tooki
author_rank: Super Contributor
timestamp: February 11, 2016, 12:19:38 pm
content: Quote from: Fungus on February 11, 2016, 08:24:32 amOh my god, dude, what is your damage? I never said it's bad. I saidI don't wanna do itbecause it exceedsmycoding and debugging skills and aspirations. Stop putting words in my mouth and then twisting them into nonsense.Quote from: Fungus on February 11, 2016, 08:24:32 amYeah yeah I get it, you wanna show off your l33t h4x0r coding skills. Whooptie-shit. I've saidrepeatedlythat I have the info already. (And this isn't the bit banging to which I was referring. That's a different approach altogether.)Quote from: Fungus on February 11, 2016, 08:24:32 amI didn't say Iwantedremote control. I only said I was considering trying an off-the-shelf controller, and those are practically all IR or RF remote control. I also said that the alternatives were a bank of switches or an arduino.Quote from: Fungus on February 11, 2016, 08:24:32 amThanks. But is there a reason why in each reply, you provide one little nugget of helpful info, and 10 nuggets of trolling and distraction? Seriously, if you don't wanna help without being a dick, just don't help.

author: tooki
author_rank: Super Contributor
timestamp: February 11, 2016, 02:07:58 pm
content: Quote from: mazurov on February 08, 2016, 07:26:50 pmThat's probably overkill for my purposes. I just need for the plants to not die every winter, I'm not running an indoor plantation. :pQuote from: mazurov on February 08, 2016, 07:26:50 pmEww, lame.

author: Fungus
author_rank: Super Contributor
timestamp: February 11, 2016, 05:30:24 pm
content: Quote from: tooki on February 11, 2016, 12:19:38 pmIn that case it's a strange choice of word: "Circumvent" is usually associated with doing something dishonest, or something against the rules.Quote from: tooki on February 11, 2016, 12:19:38 pmNope. I'm just showing you that itreally isvery simple and that you won't need to spend hours debugging anything or hurting your hands.The best way to do that? By providing the complete, working code needed to do what I was suggesting. That way you can make a fully informed decision about the complexity (or simplicity) of the software side.(Here's me thinking I'm helping ...)Quote from: tooki on February 11, 2016, 12:19:38 pmNope. That's just your interpretation of it.Quote from: tooki on February 11, 2016, 12:19:38 pmGood advice. I'll be following it to the letter.

author: tooki
author_rank: Super Contributor
timestamp: February 12, 2016, 01:53:44 pm
content: Quote from: Fungus on February 11, 2016, 05:30:24 pmFirst of all, my apologies for being so reactive. It's just been frustrating getting the same info over and over, while questions that are more pressing to me remain unanswered. Nonetheless, I actually do appreciate your taking the time to reply.I think there's a misunderstanding about what I said. Your code is for changing Arduino's timers to allow faster PWM. But that's not what I was talking about.There aretwodistinct, unrelated ways to get faster PWM on an Arduino, as far as I can find:1. Speed up the Atmel's timers to speed up the existing PWM function.2. Circumvent the Arduino libraries (i.e. analogWrite, digitalWrite) entirely and bit-bang directly to the port registers with your own code.I said early on that I know how to do #1, which is the approach you illustrated. But I clearly said it was #2 that exceeded my coding and debugging skills and aspirations. (I can't find the discussion about this approach, as it was months ago that I read it, but it went sorta in this direction:https://www.peterbeard.co/blog/post/why-is-arduino-digitalwrite-so-slow/) It's been so long, it might even have been assembler or something. I think people were doing that to achieve far higher PWM frequencies, at the expense of resolution. (E.g. 500KHz at just 16 PWM levels.)Sorry about PMSing there for a moment!

author: rs20
author_rank: Super Contributor
timestamp: February 12, 2016, 02:27:21 pm
content: One option, in between your options 1 and 2, is to use the TIMER registers directly. You can set your frequency to a precise, calculated value, you can make use of the full 16 bits -- it's just better. That way, you're not second-guessing what analogWrite is doing, nor are you using up the CPU resources of bit-banging.It's not really programming per se, it's just reading the right section of the MCU datasheet, and figuring out the magic numbers to plug into those registers. I enjoy doing this, although I gather I'm unusual in that respect...

author: Fungus
author_rank: Super Contributor
timestamp: February 12, 2016, 02:49:14 pm
content: Quote from: rs20 on February 12, 2016, 02:27:21 pmI do it too. It's not rocket science but there's an awful lot of timer modes and pin output modes to wade through in the datasheet. It isn't for the faint-hearted.If all you want is "faster" then changing the clock divider works.