The Planted Tank Forum banner
1 - 20 of 111 Posts

·
Registered
Joined
·
13 Posts
Discussion Starter · #1 · (Edited)
Hi everyone,

i am big into Arduino hacking these days, and I wanted, like so many others, to write my own aquarium controller.

Lighting is obviously a big part of it, and I was looking to control the Fluval 2.0 LED ramp.

What first got me into this idea is the fact that the LED fixture can be controlled by a (crappy) touch-sensitive button, OR by a wifi gizmo that plugs between the wall wart and the fixture.

The Led 2.0 is a 2-channel light. It has white and blue. When you press the touch sensitive button on the fixture, it goes from WHITE, BLUE, OFF. Touch-holding the button will slowly dim, then slowly brigthen the LEDs.

Apparently, when you plug the wifi controller, the light needs to be in its OFF state for the controller to work.

The connector from from the wall wart to the fixture is some sort of 4-pin DIN connector. With a multimeter, I have easily identified +24V and 0V.

The two other pins are more complicated to figure out. Because the Wifi gizmo plugs directly into the wiring that has those 4 pins, I figured they could be PWM signal.


Without an oscilloscope, I used an Arduino to peek at the voltage signal coming from the 5V lines. Turns out the 5v turns on-and-off at not-so-steady rate that can range anywhere from 60 to 150 Hz, averaging at a pretty constant 87 hz over consecutive 10 second intervals of measurement.

Voltage on-off cycles typicall range from 6-8 milliseconds at 5v followed by 6-8 milliseconds at 0v, about 46% duty cycle. But a typical PWM should be at around 1000 Hz.

I don't have an oscilloscope here, but I don't think it's PWM. The wave is just too darned inconsistent and nowhere near the frequency of a typical PWM.

Maybe some sort of square or sine wave, though the voltage drops go from 5V to 0V quite quickly.

Going back to the WIFI gizmo that sits between the wall wart and the fixture, I'm guessing it's a self-sustained microcontroller that talks to the iPhone application, downloads the settings, and then drives the lights from the 5v signals of the connector.

So what I want is basically to reproduce the control of the WIFI gizmo has over the light, but I want to control the light depending on conditions other than just a schedule.

And besides, reverse-engineering stuff is just so much fun.

Anyone has suggestions on where to go from here?


For reference: you can look at the 4-pin plug and the wifi gizmo thing here:

https://www.youtube.com/watch?v=0UFszuRE30M
 

Attachments

·
Registered
Joined
·
13 Posts
Discussion Starter · #3 ·
Have you considered the possibility that the Arduino input may not be fast enough to capture a pwm signal? In other words, only capturing some of the pulses? That may explain the inconsistent measurements.
Yes. So I did a test. I hooked up a wire from PWM pin 3 and fed it directly into analog pin 0 (A0) which reads 5V voltage levels as 0 to 1023.

When I do this, I get a rock solid reading from the arduino.

But using the same code on the 5V signal of the Fluval, I get a lot of variability in the signal.

I used the code at the link below to do my test. It's an interrupt-driven approach to querying the signal, not polling, so should not miss pulses.

Three Ways To Read A PWM Signal With Arduino


I also did tests with the arduino pulseIn() function -- all yield similar results.


At some point I might bite the bullet and buy the wifi controller, spy on the output, try to replicate what it's doing.

But that would be a waste of 150$ and I'm like, ugh.
 

·
Registered
Joined
·
21,012 Posts
Doesn't pulse width power control work by chopping the tail end off of each sine wave, so you get a sine wave start, followed by an abrupt drop to zero? That would show up as a weird wave shape, with the length of the off time being what determines how much the power is reduced.
 

·
Registered
Joined
·
1,413 Posts
Yes. So I did a test. I hooked up a wire from PWM pin 3 and fed it directly into analog pin 0 (A0) which reads 5V voltage levels as 0 to 1023.

When I do this, I get a rock solid reading from the arduino.

But using the same code on the 5V signal of the Fluval, I get a lot of variability in the signal.

I used the code at the link below to do my test. It's an interrupt-driven approach to querying the signal, not polling, so should not miss pulses.

Three Ways To Read A PWM Signal With Arduino


I also did tests with the arduino pulseIn() function -- all yield similar results.


At some point I might bite the bullet and buy the wifi controller, spy on the output, try to replicate what it's doing.

But that would be a waste of 150$ and I'm like, ugh.
I don't remember all the details, but arginine pwm operates around 1000hz and other pwm operates up to 60000hz (again the details are fuzzy in my memory) but look into controlling pwm PC fans with an arduino fit more details
 

·
Registered
Joined
·
13 Posts
Discussion Starter · #6 ·
So I'm in front of an oscilloscope right now, and I feel like a bit of an idiot.

Keep in mind I'm a total noob here and until about 3 hours ago I knew nothing about oscilloscopes other than there was one at work. After a couple of youtube videos about how to use them, I was good to go.

So, the first thing is that I just realized that I was making measurements of the supposedly 5V pins without them being grounded, and what I saw must have been... I have no clue. But when I just look at that signal (not connected to ground) it definitely looks like an AC wave and goes way beyond 5V. It has a frequency of 60 hz (1st picture). Sorry again for the noobiness.


Now, the next pictures show the signal of the two pins with the probe properly grounded.

On the pin on the right, I read an AC wave of 320 mV differential (+/- 180 mV peaks), and on the pin on the left, I read an AC wave of 640 mV (+/- 320 mV peaks). Both signals at 60 hz,

It appears there's hardly any voltage there at all.

Certainly, the signal does NOT look like a square wave like you might expect from a PWM signal.

And it's all the more surprising that what IS there looks like an AC signal.


I'm going to get the Wifi thing tomorrow and I'll see if I can get the Wifi adapter to spew anything of significance out of those pins.
 

Attachments

·
Registered
Joined
·
13 Posts
Discussing this with coworkers today, we basically concluded that the AC signal described in previous posts was probably the scope reading AC noise/leaks coming from the wall wart and that there was likely no signal coming off of those pins, and that those pins might not even be connected to anything in the wall wart (or, maybe, to ground), who knows.

So, previous posts = garbage.

Anyway, I went and got the wifi controller instead.

And aha! Now we're talking!

After setting up the device, loading up the application and making sure I could adjust the lighting levels, I disconnected the lamp and hooked up the scope to the 0V and the two mystery pins.

I adjusted the brightness via the application, and looked at how the signal changed on the scope. And now, it the waveform certainly looks like a PWM signal at 500 hz and at 3.3 VDC. The only weird thing about it is that it seems to be negative voltage, going from -3.3v (LOW state) to 0V (HIGH state). I'm not sure why at this point, but the scope doesn't lie, and I tried reversing the scope's ground/measurement tips to see if I'd get a different polarity, and the signals went all wonky on me.

I added pictures of what I saw.

On the first image, you can see the regularity at which the scope sees the many cycles of what appears to be a PWM (I set the light at 50%) going from -3.3v to 0V. The image tells of a frequency of 250 hz, but I think that's because of how "zoomed out" I was on the time scale. When zoomed in a little bit on the individual cycles, the scope clearly shows a solid and steady 500 hz.


The other images below show the scope's results based on the settings of the wifi module/app.

10% brightness, 50% brightness, 90% brightness.


You can see a very constant rising of the wave, then jumps to top voltage for the % of the duty cycle programmed by the app.


So, now that I know what to look for and what to replicate, my next steps are to try to come up with code and circuitry based on an arduino that reads similar wave forms on the scope at the same frequency. Then, hook up the arduino to the lamp and see what happens.

Wee!

Just tested a couple of things with an Arduino.

1) The good news is that the default PWM frequency is.... 500 Hz.
2) I can also convert a 5V PWM signal to 3.3v using a simple level shifter like 74AHC125.
3) I can use an ICL7660 to negate this voltage (which I don't have right now)

Looks more and more like a piece of cake, but I'm bothered by the fact that the scope is reading a negative voltage for those pins.

But I'm beginning to form an idea as to why that might be, but anyone cares to offer hypothesis?
 

Attachments

·
Registered
Joined
·
13 Posts
Discussion Starter · #10 ·
Sorry folks, It's been a very busy week, and this coming week I'm traveling. Sorry for the delay.

I've actually opened the wifi box, and I've found that:

- From the wall-wart going into the Wifi controller, only +24V and 0V are connected. The two other wires are actually cut (!!)

- The 0V and 24V powers a small motherboard that transmits the 0V and 24V at the other end, plus two channels of PWM per light. There are actually markings on the motherboard labeled PWM1 (light 1 - white), PWM2 (light1 - blue), PWM3 (light 2 - white), PWM4 (light 2 - blue).

- On the board I see 3.3v voltage regulators, confirming the 3.3v pwm output, but I can't figure out, from looking at the board and the components, how they negate the voltage.


The main obstacle at this point is generating the negative PWM which seems simple but happens to not be, because I'm too new with electronics.


Anyway, I have help at work, so I'll post instructions (wiring and code) on how to make this work once I've figured out the negative voltage thing.


@benw: Arduinos are made for kids learning electronics. They are quite capable little beasts. You should check it out. If you have any programming experience at all it will help, but if not you can probably learn bit by bit by osmosis with all the samples that are available.




Patience, patience...
 

·
Registered
Joined
·
13 Posts
Discussion Starter · #13 ·
I am still away and responding on my phone but basically:

Take a wire from the arduino pinout to the +leg of a capacitor.

Connect -leg of the capacitor to a diode going to ground and

Connect same -leg of the capacitor to voltage out.

You end up with pwm going from 0 to +5v from the pin, converted to -5v to 0v to Vout.

It's half of the standard circuit to convert positive pwm voltage to a sustained negative voltage.

http://www.eevblog.com/forum/blog/eevblog-483-microcontroller-voltage-inverter-tutorial/

Now I just have to get back home from my week of travel and go ahead and do it.
 

·
Registered
Joined
·
5 Posts
Great info, thanks! I'm new to micro controllers, but have a decade or so of coding (mainly java & .Net). Haven't done anything with physical electronics in a long time. Interested to learning though.

A buddy of mine gave me his seeeduino along with his working code, luckily it has a 3.3v setting, though unfortunately no real time clock, will have to get the shield.

I have a guy at work to consult with, he seems dubious of the -3.3v. Are you sure that's correct? I agree with you that the pictures look like it is, but it just seems so strange. Any idea why it would be?

edit: didn't see the video post before, I get it now.
orig: If you were to flip the voltage on it wouldn't mirrored across 0v instead of translated down? I'm just speculating, don't know how that's supposed to work.
 

·
Registered
Joined
·
23 Posts
I'm extremely interested in your work here! I have this light and an Apex controller. It would be SOOO cool to be able to get rid of the buggy WiFi module and control the lights directly from the Apex!

If there's anything you need in any way to assist you, please let us know.
 

·
Registered
Joined
·
13 Posts
Discussion Starter · #17 · (Edited)
So, today I am back home, and I went to the electronics shop and got a couple of diodes. But silly me, I forgot to get a proper capacitor. I only have way-too-large capacitors in my toolbox, and those discharge too slowly to see any kind of proper pwm going at 500-to-1000 Hz.

Also, I don't have the oscilloscope at home, just a plain old multimeter.

BUT!

I did try the circuit anyway with what I did have around to prove the concept. I made a small voltage divider to go transform the 5V out to 3.3V, then on the arduino I coded ON-OFF (5V-0V) signals every 5 seconds (to let time to my multimeter to adjust). Sure enough, the multimeter reads about 0V to about -3.2V every 5 seconds. Fun.


to be honest, I'm more intrigued by pictures of the inside than how you are modding it...
I have pictures, just not handy. I'll send them just a little later. But I intend to remove the innards of the WIFI controller and replace all of it with my own mini arduino.

In the end, it will probably be an esp8266 (aka Adafruit Huzzah) and not an arduino. The whole thing will have cost about 12$ in parts (9$ for the Huzzah and around 3$ for resistors, diode, capacitor).

https://www.adafruit.com/products/2471


benw said:
I have a guy at work to consult with, he seems dubious of the -3.3v. Are you sure that's correct?
Well, three of us double-checked it. Yes it seems to be impulses of negative voltage.

benw said:
Any idea why it would be?
My best guess so far would be that, from the light fixture to the LEDs (near the switch on the fixture, later down the chain from the wifi controller), there's a constant 3.3V voltage applied to the LEDs, and that makes the LEDs light up fully. Then, the wifi controller, in order to make them dim, would thus need to subtract impulses of 3.3v in order for the voltage to go from a constant +3.3v down to 0 momentarily.


I'm extremely interested in your work here! I have this light and an Apex controller. It would be SOOO cool to be able to get rid of the buggy WiFi module and control the lights directly from the Apex!

Thanks! It'll be a few more days until I have proof of concept. I'll post a video once I have something going.

Sorry for the slow progress. Just been traveling, then the kids, then work, then... not a lot of time to myself.
 

·
Registered
Joined
·
13 Posts
Discussion Starter · #18 ·
Progress, progress... a little.

So, I brought the scope from work tonight, so I could play with stuff at home.

In a nutshell, I've managed to put my circuit together so that the PWM goes from 0V down to -3.3V.

But there was a bit of a curveball in there, in that the diodes I use have voltage loss of up to 0.6V, meaning my 3.3V voltage was not perfectly inverted. Instead of going from 0 down to -3.3V, it went from 0.6V down to -2.4V.

Which was a problem. Going out spec with an extra 0.7V meant that I might damage the microcontroller in the LED fixture (I don't know what they're using, so didn't want to play with fire) and -2.4V might not be enough to actuate the PWM cycle.


So I modified my voltage divider by using different resistances (I must admit, I mostly fudged it) and used another diode to clamp out the 0.6V at 0V. With these tweaks I managed to get cycles going from +0.08V down to -3.24V, which is a much more acceptable tolerance although it causes my waveform to not be perfectly square. Which I am pretty sure is OK.


Next step: I'm bringing the arduino and the circuit to work tomorrow, I'll try to hook it up to see if I get blinky.

I'll post pictures then.



====


EDIT: For those who are into electronics, I am using 1N4148 diodes at the moment. I wanted to get Schottky diodes, but my electronics store was out of stock, and I'm not sure where else to get them except online, and it feels kind of studid to pay 14$ shipping for a 0.38$ part.
 

·
Registered
Joined
·
13 Posts
Discussion Starter · #19 ·
As promised, an update.

It'll be a short update: it's not working. Yet.

Turns out that the whole -3.3v thing I talked about earlier behaves differently when the light is plugged in, and I take measurements of the scope on the board. Then, I read a PWM signal of 0-10V.

I'm a bit befuzzled at the moment. I'll have to ask guys at work tomorrow.

There's stuff I obviously don't understand.
 
1 - 20 of 111 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top