-
-
Notifications
You must be signed in to change notification settings - Fork 500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Suggestion] PWM for Led driver dimming #262
Comments
Good suggestion, How do you envision it being integrated into Mycodo? That is, what is your desired use? Such as x% at 8am, y% at 10am, etc.; response from sensors (conditional- if light sensor is x, set LED output to y, some sort of integration into the relay menu so relay actuation can somehow change brightness/color, or other? |
I use mycodo for the cultivation of microalgae. In the first stage the culture has a low density and requires little light. Excessive brightness inhibits growth. As cell density increases the luminous intensity must be increased. Then from day to day the luminous power increases. When cell density is at its maximum, microalgae are stressed with maximum intensity to make a red pigment. I need a function that gradually increases the brightness during the first 15 days. For an outdoor culture to have the ability to compensate for the loss of brightness by a cloud would be really very interesting to have a stable, climate-independent production. I would like to use mycodo to a marine aquarium. For the coral it takes a function of sunrise and sunset every day. The PWM output function can be integrated in the relay menu. |
Here is what I currently think would work best for the 15 day cycle:
For the sunrise/set, moon phase I could add a new type of controller that can calculate the sunrise/set and lunar phase for a given set of coordinates (and optional time offset to have a complete configuration), where there can be PWM output based on sunrise, midday, sunset, then switch to PWM for moon phase during night period. There could also be actions that can be taken at sunrise or sunset (or periods surrounding those using a time offset, such as "2 hours before sunrise" or "20 minutes after sunset", activate relay x to ON, set relay y PWM to 70% duty cycle, etc.) |
That will be great ;) Do not forget the function of modifying the brightness of the LEDs according to the ambient brightness to maintain a constant luminosity in real time. There is a lot of work. |
How are the LEDs duty cycle changed? |
I know that the frequency of pulsed light can have a beneficial effect on photosynthesis. This frequency depends on the color (wavelength). I have to do some research on the subject.
|
I was asking how is the hardware (LEDs) modulated by the software. And what software or code is used for that? I need a starting point as I don't have any hardware for LED PWM control. |
I think we can have the information in the datasheet of the driver. I am in the bed, I can find tomorrow.
|
driver datasheet : Applying additive 10V PWM signal (frequency range 100Hz ~ 3KH) you can test mycodo with 1 led and 1 resistor like that : |
@kizniche Is the same thing i ask you last year if you can integrate a PWM output function in PID control . Can be 2 main forms of controll PID output (relays and PWM). Relays can do a good job for normal control ,but for fast changes below 1 second , relays just simply cant. I can handle with C but unfortunately my programming skills in Phyton and Flask are very low. (I'm hardware engineer) , software are just a passion. |
The RPI.GPIO module has PWM and I think it would be somewhat easy to add it as a PID output (as the other use mentioned in this thread appears more difficult), now that I have a bit more experience with Python and the framework is more logical and accessible. What would be any additional PID options or changes needed to use PWM as an output? I'd assume I would essentially need to convert the PID output to a percentage, for use in defining the duty cycle. Any other suggestions would be appreciated, as I rarely work with PWM and don't currently have any devices that use it (though I can test the operation with my oscilloscope). |
Yes Kyle , now i see, Pi is the same, software PWM (not hardware) and i assume can be selected as output any RPI pin. That would be great. Here is a tricky part. If controll is in one dirrection (raise or lower , usualy the temp) PWM output will be as percentage 0 - 100% and if the controll need to be in both dirrection can be in two ways : |
@kizniche Also i can made a schematic for each one of the metods (2 pins or single RPI pin) and for the two power sources (alternating and countinuous ). You can fit into the help page after you finish. |
Sounds great. I can understand the 0-100% PID for a single relays (one 0-100% up, one 0- - 100 down), or just up or just down. However, I'm not fully understanding the other method you suggest. Schematics and descriptions would help. Thanks. I'm out right now, but plan to do some research when I get home later. |
We can use the solid state relays instead of classic coil relay. That for heat sources load . Actualy is not to much difference between techniques of relays use. Classic relay can modulate in on and off (they can"t open or close only 30% or 66%) and solid state relays can work with PWM modulation . Thats mean if the power source wil be 120v AC , and relay is comanded with 50% duty cycle at 1kHz based frequency , the heat source will get 60v AC . |
What about a PWM IC? I found two examples. They can be controlled by either I2C or SPI. |
@Ryobidelacroix That's IC are specialised only for LED PWM , If the code will be made like @kizniche suggestion http://raspi.tv/2013/rpi-gpio-0-5-2a-now-has-software-pwm-how-to-use-it the aplication will be general purpose , not only for LED. The native RPi pin"s can be used on any application. |
Ah, even better! |
I completed about 75% of the PWM implementation last night, including the web interface and the PWM controller. Last is to test the operation and enable it as a new PID option. Then we can get into more complex uses. |
I made a simple swap PWM code to simulate the output of PID on RPi . Schematics are for AC and DC load. |
I pushed the latest commit for what appears to be a working implementation of PWM. I say appears because everything responds as though it's working but I haven't actually tested the pin output. I'll check with my oscilloscope tomorrow. There may very well be issues with this PWM_support branch, as I haven't tested if current relay/PID functionality has been affected. This commit only brings in the ability to add and configure a PWM output on the output's page (previously "relay" page), and turn on/off PWM. PID output will come next once I confirm there is indeed a PWM being output and normal relay/PID functionality hasn't been broken. |
… as it does not yet work in the backend) (#262)
Great! I'll add them to the manual. I've never really used PWM besides simple uses with microcontrollers, so this is all relatively new to me. |
Is just the principle , if you have a osciloscope is easy to fully understand how it's works and the hudge advantage than relays. With PID and PWM , dont stress the relays , the loads . Is almost linear . After you will finish the PWM code , i will upload the full real schematics (ISIS can't simulate the complex hardware, to much math for him), but only after i will test on my rPI . I use that for years on my old dsPIC MCU"s before discover your software. |
That last commit should have all parts of the system working with PWM, including PID output. I have my oscilloscope with me so I can test when I get home. |
Is strange . I let be tested and when i wake up , Mycodo still running but i can't acces the webserver . Also SSH dont working. I try on differents PC. Seems was orking on PRi web interface itself. I look in logs , no daemon logs, but some lines on HTTP log.
that was before to restart
And that after i restart.
The influxDB was downgraded , as you suggest. |
I just noticed that influxdb 1.3.1 was released 3 days ago (without updating their changelog for me to notice). I just upgraded and it appears to be working. I used the following to upgrade: wget https://dl.influxdata.com/influxdb/releases/influxdb_1.3.1_armhf.deb
sudo dpkg -i influxdb_1.3.1_armhf.deb
sudo service influxdb restart
rm -rf influxdb_1.3.1_armhf.deb |
Hello, |
I'm not sure what that is. Currently, only PIDs can output a PWM signal. If your device can accept a 3.3-volt PWM from 0% to 100% duty cycle, it will work out of the box. Otherwise you'll need to adjust your hardware accordingly. |
Its a standard 12v 4wire computer fan. Wiring: 12v, ground, tachometer, PWM. |
I have followed this development too, for the exact same purpose, i.e. for controlling fans. |
Will this work with fans? Would be great to be able to PWM drive an inline AC fan (RVK125A) for extraction! |
v5.3.4 released today includes the ability to create timers that output a PWM signal based on a method. Just make sure your method stays between 0 and 100 (%), and select it in a PWM Timer to use it. |
Regarding PWM commanding AC inductive motors (Fans), according to RVK it can be done using stepless thyristors:
Reference: |
Lets just say - controlling large motors is out of scope I think. Indeed, many things can be done with proper signal conditioning and isolation from the big, bad motor. The problem is that as you try to scale the solution (engineer to reality) you figure out you started from the wrong perspective. Tiny 3.3v digital signals need optoisolators at a minimum and the power stage is a challenge to get done well. At that point you couldn't care less about what wiggles the control signal. I would try to find an engineered solution that takes a 3.3v control signal first then consider building my own if that option isn't feasable if I want to integrate with Mycodo. There is only so much of the effort that Kyle can sustain, I think. |
Not sure if I should post here, or start a new issue. However, the original comment talked about dimming some Meanwell LED drivers, which required 0-10V for the PWM. I have the same use-case (Meanwell LED dimming using PWM) - Raspberry Pi's do 0-5V for PWM, right? What are you all using to convert that to 0-10V PWM? The post did mention some converter, however, the link there is dead. |
There have been a few discussions about generating 10 VDC PWM signals, but these same hardware solutions can also do 5 VDC. https://forum.radicaldiy.com/t/schematic-using-pwm-to-generate-a-0-10v-control-signal/1098 https://forum.radicaldiy.com/t/can-i-control-the-speed-of-motors-and-fans-with-a-pwm-signal/65 |
@leoneo Thanks for the link - but just to clarify - that is a digital potentiometer board, right? Not for converting a 5V PWM to 10V PWM? Is the idea that we use this for one of the other non-PWM Meanwell dimming modes? @kizniche Cool - thank you for that as well. The second link, which then links to a OSHPark PCB seems like exactly what I want. Sorry if these are basic questions - but my electronics knowledge is fairly basic. But to confirm, I can just:
And then it should just work as-is to dim Meanwell drivers via PWM, right? Do you know if anybody has tried or confirmed this circuit with Meanwell drivers? |
@kizniche I've just ordered a few of your board from OSHPark =). Sorry to bother you - but just to confirm - this should just work with the Meanwell 0-10V dimmers, right? Is there anything special I need to adapt your board for this use-case? |
Correct
On the right side of the board, you will connect 5 VDC (instead of 10 VDC), ground, and the 5 VDC PWM signal will be generated on the PWM pin. Devices are either controlled by a 0 to some voltage signal OR a PWM signal, not both. This will generate a PWM signal at whater input voltage you use, either 5 VDC or 10 VDC. |
I just received the PCB's today =) - yay! As far as I can tell, the Meanwell PWM LED dimming mode needs a 10V PWM signal:
The one part I still don't get is the right-hand side connectivity 😕. @kizniche You mention an input voltage - does this mean I need to supply a 10V voltage to the board, on the right hand side connectors somewhere, for it to convert the Raspberry Pi 5V PWM to a 10V PWM signal? Ugh, if so, that could be a problem. Where do people normally get this, if they just use a Raspberry Pi? |
If using a Pi, you're not converting from 5 VDC. GPIO pins output 3.3 VDC. Usually the device can provide the higher DC voltage. For instance, my Terrabloom and AC Infinity fans that can be speed controlled via 10 VDC PWM have 10 VDC as one of the wires of the control wire bundle (GND, 10 VDC, PWM signal in). You could use the 5 VDC of the Pi if you don't want to use an external power source. |
Thanks so much for your help so far =). You're right, Raspberry Pi PWM output is 3.3V, not 5V (I think Arduino is 5V?) I've checked - the Meanwell LED dimmers don't appear to supply 10VDC anywhere for me to tap into. Ah - so you're thinking of taking 5VDC from pin 2 or 4 on the Raspberry Pi, right? I'd need to connect 5V and GND from the Raspberry Pi to the 10V and GND pins on the right-side of the board, correct? But that means my resulting PWM output will be 0-5V, right? There's no way to get that to 10V? |
GND is common across all GND points on the board, so it doesn't matter where you connect it.
Like I mentioned previously, you can either produce a varying voltage signal, e.g. 0 - 10 volts (other boards), or a PWM signal (this board). You cannot do both. PWM signals are one single, static voltage. There are no drivers that I know of that require a varied voltage PWM signal, it's just not a thing. |
Got it - really appreciate the explanation. So double-checking the Meanwell spec sheet again, it seems I just need a 10V PWM signal (100Hz to 3KHz). Is there any way of getting that 10V PWM using just this board, and a Raspberry Pi, without a separate 10V power supply? Or is that an impossible ask? |
Not that I know of. If the device doesn't give you 10 VDC already, you're going to need an external power supply, which should be between $5 and $10. You can get one with the lowest current rating, since this application uses a negligible mount of current. You can also use that single 10 VDC power source for multiple PWM boards. |
I did do some research before, and came across one thread which seems to offer a solution using just the Raspberry Pi and no separate supply - I confess I don't quite understand all of the details yet: which references this earlier Reddit thread:
So there's a 10V differential across the Meanwell DIM+ and DIM- pins. Is there some way to connect that to your circuit board? =) |
So there is 10 VDC? You've verified by measuring the voltage? Also, from the datasheet: "Please DO NOT connect "DIM-" to "-V"", so it may cause an issue if you connect to ground. I'm not 100% sure how your circuit will respond with the PWM board. |
Hello Kyle,
I would like to control the brightness of 3 led strips (red, blue, white) in the time.
For example function 1 : day 1 = 10%; day 2 = 15%; day 3 = 20 % ... day 15 to day 30 = 100%
function 2 : sunrise start at 6:30AM with 0% to 100% in 30min / sunset start at 8:30PM with 100% to 0% in 30min.
There are led drivers dimmable with 0-10Vc PWM input and with a 0-5V 0-10V PWM Converter Module it is theoretically possible with the Raspberry Pi to control the brightness.
https://raspberrypi.stackexchange.com/questions/298/can-i-use-the-gpio-for-pulse-width-modulation-pwm
http://www.meanwell.com/productPdf.aspx?i=300
http://www.uctronics.com/0-5v-0-10v-to-0-100-voltage-to-pwm-converter-module.html
Please can you add a PWM output function in Mycodo ?
Thanks
Leo
The text was updated successfully, but these errors were encountered: