Reef-Pi build for a tropical vivarium

OP
OP
Mandelstam

Mandelstam

Well-Known Member
View Badges
Joined
Oct 29, 2017
Messages
688
Reaction score
1,117
Location
Malmö, Sweden
Rating - 0%
0   0   0
Pi's own two pwm channels (generally GPIO 18 and 19) can provide upto 19.2 MHz. For more pwm pins, we have to support some kinda external IC. you can use arduino or something else, but all of that will require some coding/driver support. I think a simple 555 timer ic can generate upto 10KHz pwm signal. I'll look out for some pre made solutions.. keep us posted

I'm about to setup reef-pi soon and I thought I might as well enable those two pwm pins and change the frequency. Do you do that in a config file outside reef-pi?

I sort of get the concept of what I need to do, divide the clock frequency with the right value so I end up somewhere between 21-28kHz. But I'm not sure about what I should choose for the duty cycle range, my guess is that that could have impacts on something else too? And I've only seen duty cycle specified in percent before...
1601737771294.png


This is the spec for the pwm signal I need for the fans.
1601737937229.png
 

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,843
Reaction score
17,058
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
I'm about to setup reef-pi soon and I thought I might as well enable those two pwm pins and change the frequency. Do you do that in a config file outside reef-pi?

I sort of get the concept of what I need to do, divide the clock frequency with the right value so I end up somewhere between 21-28kHz. But I'm not sure about what I should choose for the duty cycle range, my guess is that that could have impacts on something else too? And I've only seen duty cycle specified in percent before...
1601737771294.png


This is the spec for the pwm signal I need for the fans.
1601737937229.png
In the configuration section you just have to specify the pi pwm frequency and reboot. Let me know if that’s not working as expected.
 

theatrus

Valuable Member
View Badges
Joined
Mar 26, 2016
Messages
1,974
Reaction score
3,366
Location
Sacramento, CA area
Rating - 0%
0   0   0
Soldering cables into the right length takes time haha! Next bigger project like this I'm going to buy a good crimping tool and empty dupont housings and crimps. And wire strippers...:rolleyes:

Layout and cable wiring/management is almost done. I put the Arduino Uno in there just to make room for it if I ever need it to solve the 25kHz pwm signal.
1601723299230.png


I put this little rail together to connect up the sensors. On the left is where the data line from the ds18b20 connects up. Pullup 4.7k to 3.3v. The VCC from the sensor will go to the 5v rail. I'm going to run quite long cables and I read that doing it like this should help with longer cable runs. And it should be safe for the Pi.

On the right the DHT31-D sensor(s) will hook up with SCL/SDA and 3.3v. The SDA/SCL is connected to the PCA9685 board which is connected to the Pi (not in the picture yet though).
1601723516607.png



On the front of the enclosure I'm going to have a few status leds for when different equipment is running. I got some 3mm green leds for that.
1601724005594.png


The leds will run on 5v and be connected to the output pins on the ULN2803 and so will light up whenever a signal is going to the relay board.
1601724190612.png

The enclosure is looking very nice! Cable management is an art form
 
OP
OP
Mandelstam

Mandelstam

Well-Known Member
View Badges
Joined
Oct 29, 2017
Messages
688
Reaction score
1,117
Location
Malmö, Sweden
Rating - 0%
0   0   0
The enclosure is looking very nice! Cable management is an art form

Thank you!

And yes, it's so satisfying to see installations where someone has put in the time and effort. And when you've tried to do it yourself and realize how hard it is, it's even more impressive.
1601755573628.png
 
OP
OP
Mandelstam

Mandelstam

Well-Known Member
View Badges
Joined
Oct 29, 2017
Messages
688
Reaction score
1,117
Location
Malmö, Sweden
Rating - 0%
0   0   0
I'm soon ready to move on to software installation, just a few little things left to do on the hardware side. Cutting those leads to the internal pullups on the PCA9685 board and putting in a pullup for the I2C lines. Going to go through and check connections with the multimeter on continuity setting. Connect the status leds. I'll probably discover a few other things to do as well.

I also planned out which GPIOs to use and for what. Just makes it easier when putting in all connectors to the pi. Most pwm:s will go via the PCA9685 board but thanks to Ranjib I realized I can use the hardware pwm channels on the Pi to get 25kHz pwm to control my fans. And 2 signals is all I need for that really. I know I saw somewhere that the max pwm frequency on the pi was something like 8kHz but didn't double check. I should have.
The rest of the fans will run on static voltage off the buck converters so I can dial them in to a nice quiet level.

1601755985184.png
 
OP
OP
Mandelstam

Mandelstam

Well-Known Member
View Badges
Joined
Oct 29, 2017
Messages
688
Reaction score
1,117
Location
Malmö, Sweden
Rating - 0%
0   0   0
Well everything is installed and tested. Only issue I discovered was with my rail of mosfet drivers for my lights. Seems to be some interference between a few of them. Some humming and things going on. I think I just put them all too close together on the breadboard or something. I'm going to redo that part and put them on a little bigger board.

Software install was easy and everything seems to be working there. Big shout out to all the devs. :)


1602172054866.png
 

theatrus

Valuable Member
View Badges
Joined
Mar 26, 2016
Messages
1,974
Reaction score
3,366
Location
Sacramento, CA area
Rating - 0%
0   0   0
Well everything is installed and tested. Only issue I discovered was with my rail of mosfet drivers for my lights. Seems to be some interference between a few of them. Some humming and things going on. I think I just put them all too close together on the breadboard or something. I'm going to redo that part and put them on a little bigger board.

Software install was easy and everything seems to be working there. Big shout out to all the devs. :)


1602172054866.png


Humming may be indicative of some self-oscillation or other issues. What does that part of the circuit look like and how much current is running through various parts? You can dampen oscillations on longer leads to FET gates by adding some series resistance, 10-100 ohms or so. This will slow down the switch on speed but avoid the whole thing becoming a an oscillator.
 
OP
OP
Mandelstam

Mandelstam

Well-Known Member
View Badges
Joined
Oct 29, 2017
Messages
688
Reaction score
1,117
Location
Malmö, Sweden
Rating - 0%
0   0   0
Humming may be indicative of some self-oscillation or other issues. What does that part of the circuit look like and how much current is running through various parts? You can dampen oscillations on longer leads to FET gates by adding some series resistance, 10-100 ohms or so. This will slow down the switch on speed but avoid the whole thing becoming a an oscillator.

It behaved quite weird actually. There are 5 mosfet drivers on the board, driving 5 lights. Wired as a low side switch as below with a 10k resistor between the gate and ground, the ground wire from each light connected to the drain, source connected to ground:
1602225443716.png


Signal to gate is 3.3v PWM coming from the PCA9685.
Mosfets are IRLZ44NPBF, 55V 47A.
The lights (led strips) are 24v and each light draws around 1.7A (40W)

The drivers are put quite close together on a small perf board to be able to fit them all (5 + 1 moonlight). Those metal parts sticking up with a hole in it, they are so close they are touching each other. I didn't think this would be an issue but maybe it is? I believe I've seen a bunch of fets screwed to a common heat sink and that's what made me think that it wouldn't be an issue if those parts were touching. Last night I saw this picture below though. Is that part actually part of the drain?
1602226683056.png

What happened was that the first pair of drivers worked fine and behaved as they should when playing around with the pwm signal on reef-pi. When I turned on the third one it actually lit up 3 lights instead of 1 and started to hum. Humming frequency changed with the pwm duty cycle. When I gently pushed and touched the wires coming from the board and the fets themselves the lights flickered like there was a bad connection somewhere and that is what I thought it was. Bad soldering or something touching something that it shouldn't.
 

theatrus

Valuable Member
View Badges
Joined
Mar 26, 2016
Messages
1,974
Reaction score
3,366
Location
Sacramento, CA area
Rating - 0%
0   0   0
It behaved quite weird actually. There are 5 mosfet drivers on the board, driving 5 lights. Wired as a low side switch as below with a 10k resistor between the gate and ground, the ground wire from each light connected to the drain, source connected to ground:
1602225443716.png


Signal to gate is 3.3v PWM coming from the PCA9685.
Mosfets are IRLZ44NPBF, 55V 47A.
The lights (led strips) are 24v and each light draws around 1.7A (40W)

The drivers are put quite close together on a small perf board to be able to fit them all (5 + 1 moonlight). Those metal parts sticking up with a hole in it, they are so close they are touching each other. I didn't think this would be an issue but maybe it is? I believe I've seen a bunch of fets screwed to a common heat sink and that's what made me think that it wouldn't be an issue if those parts were touching. Last night I saw this picture below though. Is that part actually part of the drain?
1602226683056.png

What happened was that the first pair of drivers worked fine and behaved as they should when playing around with the pwm signal on reef-pi. When I turned on the third one it actually lit up 3 lights instead of 1 and started to hum. Humming frequency changed with the pwm duty cycle. When I gently pushed and touched the wires coming from the board and the fets themselves the lights flickered like there was a bad connection somewhere and that is what I thought it was. Bad soldering or something touching something that it shouldn't.
TO-220, unless sold as an isolated tab, has the center pin connected to the tab electrically. All the FETs are basically in parallel if they’re electrically joined at the tab. If people bond them to a heat sink the method is to use an insulated Silpad and a mica washer to isolate them.

FETs are also super sensitive on the gate. If the gate is floating or not connected to anything touching it usually is plenty to charge them up and turn them on or off. The gate is basically a 100-1000pF capacitor.
 
OP
OP
Mandelstam

Mandelstam

Well-Known Member
View Badges
Joined
Oct 29, 2017
Messages
688
Reaction score
1,117
Location
Malmö, Sweden
Rating - 0%
0   0   0
TO-220, unless sold as an isolated tab, has the center pin connected to the tab electrically. All the FETs are basically in parallel if they’re electrically joined at the tab. If people bond them to a heat sink the method is to use an insulated Silpad and a mica washer to isolate them.

FETs are also super sensitive on the gate. If the gate is floating or not connected to anything touching it usually is plenty to charge them up and turn them on or off. The gate is basically a 100-1000pF capacitor.

Thanks a lot for explaining that! I'm going to redo the drivers on a bigger board and my guess is that it should be fine after that.
Making mistakes is the best way to learn haha!
 
OP
OP
Mandelstam

Mandelstam

Well-Known Member
View Badges
Joined
Oct 29, 2017
Messages
688
Reaction score
1,117
Location
Malmö, Sweden
Rating - 0%
0   0   0
Good and bad news. I redid the mosfet drivers for the lights and they all seem to be working fine.
1602418737121.png


Bad news is that the humming is still there but I figured out where it's coming from, it's coming from the Meanwell PSU. As soon as two or more lights are on the humming/buzzing starts and gets louder as more lights I turn on. Is it faulty and should be returned?

1602418773292.png
 

theatrus

Valuable Member
View Badges
Joined
Mar 26, 2016
Messages
1,974
Reaction score
3,366
Location
Sacramento, CA area
Rating - 0%
0   0   0
Whats your PWM frequency?

This usually means "add capacitors" since you're hearing the harmonics of something, which could be oscillations on the wire, from the supply regulation, etc etc.

I'd add some bulk capacitance (100uF-1000uF electrolytic or tantalum as a start) and a higher frequency capacitor (1-4.7uF ceramic or film) at the power input to the FET board.
 
Last edited:
OP
OP
Mandelstam

Mandelstam

Well-Known Member
View Badges
Joined
Oct 29, 2017
Messages
688
Reaction score
1,117
Location
Malmö, Sweden
Rating - 0%
0   0   0
Whats your PWM frequency?

This usually means "add capacitors" since you're hearing the harmonics of something, which could be oscillations on the wire, from the supply regulation, etc etc.

I'd add some bulk capacitance (100uF-1000uF electrolytic or tantalum as a start) and a higher frequency capacitor (1-4.7uF ceramic or film) at the power input to the FET board.

PWM frequency is 1kHz.

If I add capacitors, where exactly do I place them? Between source and ground?
 
OP
OP
Mandelstam

Mandelstam

Well-Known Member
View Badges
Joined
Oct 29, 2017
Messages
688
Reaction score
1,117
Location
Malmö, Sweden
Rating - 0%
0   0   0
Whats your PWM frequency?

This usually means "add capacitors" since you're hearing the harmonics of something, which could be oscillations on the wire, from the supply regulation, etc etc.

I'd add some bulk capacitance (100uF-1000uF electrolytic or tantalum as a start) and a higher frequency capacitor (1-4.7uF ceramic or film) at the power input to the FET board.


I played around with the pwm frequency a bit. Humming disappears at lower f's. At 50Hz it's not noticeable (except for flickering lights lol), at 100 it starts to be noticeable but quite low.
 
OP
OP
Mandelstam

Mandelstam

Well-Known Member
View Badges
Joined
Oct 29, 2017
Messages
688
Reaction score
1,117
Location
Malmö, Sweden
Rating - 0%
0   0   0
Thinking if using hardware pwm at 25kHz would solve this by pushing the humming above audible levels.. Like I know they do with pwm controlled fans... I could use the Pi's two channels and split the lights in two channels instead of the 5 I have now...
 

theatrus

Valuable Member
View Badges
Joined
Mar 26, 2016
Messages
1,974
Reaction score
3,366
Location
Sacramento, CA area
Rating - 0%
0   0   0
PWM frequency is 1kHz.

If I add capacitors, where exactly do I place them? Between source and ground?

Supply voltage and ground to the lights - I am assuming the lights are powered by the same supply? I'd put them close (same board) as the PWM switch if you can, even if it means running the +V supply lead to the board as well. Having wire run in every direction creates inductive loops, which means it starts humming away at certain frequencies.

You can push the frequency up as well.
 
OP
OP
Mandelstam

Mandelstam

Well-Known Member
View Badges
Joined
Oct 29, 2017
Messages
688
Reaction score
1,117
Location
Malmö, Sweden
Rating - 0%
0   0   0
Let there be light!

I changed from using the PCA9685 for PWM to the Pi's hardware pwm channels. Set the frequency to 25kHz and used those two channels for the lights instead. No noise, no humming. All seems good.
It's a bit of a bummer though cause I was planning on using those two channels for a couple of fans inside the vivarium and control them via pwm, like a couple of wavemakers. I might set up a separate reef-pi for those two, I have a spare r-pi zero. It would be awesome if the PCA9685 board had a higher max frequency.

I think the preset pins for pwm ch 0/1 is pin 18 and 19 and I already use those pins as outputs. So I had to go to config.txt and specify pin 12 and 13 and reboot.
"dtoverlay=pwm-2chan,pin=12,func=4,pin2=13,func2=4"


1602520736433.png
 
OP
OP
Mandelstam

Mandelstam

Well-Known Member
View Badges
Joined
Oct 29, 2017
Messages
688
Reaction score
1,117
Location
Malmö, Sweden
Rating - 0%
0   0   0
Supply voltage and ground to the lights - I am assuming the lights are powered by the same supply? I'd put them close (same board) as the PWM switch if you can, even if it means running the +V supply lead to the board as well. Having wire run in every direction creates inductive loops, which means it starts humming away at certain frequencies.

You can push the frequency up as well.

I changed the frequency but had to go to the hardware pwm on the pi to do that (above post). Seems to be working fine with no humming/noise.
Thanks for the help! :)
 

Looking back to your reefing roots: Did you start with Instant Ocean salt?

  • I started with Instant Ocean salt.

    Votes: 38 74.5%
  • I did not start with Instant Ocean salt, but I have used it at some point.

    Votes: 7 13.7%
  • I did not start with Instant Ocean salt and have not used it.

    Votes: 5 9.8%
  • Other.

    Votes: 1 2.0%
Back
Top