Author Topic: RGB(W) arduino device  (Read 24394 times)

Offline MarcB

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
Re: RGB(W) arduino device
« Reply #30 on: February 28, 2014, 06:42:58 pm »
I'm not very good when it comes to hardware (software developer, not EE) so I'd appreciate if someone could sanity check my post. I can use a soldering iron, I know what a resistor does in theory, but I have no idea how it is used in practice (for example, I had to learn about pull-up resistors from sparkfun.com about 2 hours ago) and I know enough not to short out a capacitor with a screwdriver, but that is pretty much it... I can however follow instructions to the letter :P

I want to use an Arduino to PWM dim an RGBW strip I've got attached to the back of my TV.
I also want to have a "sensor" that flicks a virtual switch whenever the TV turns on or off (that I'll use to turn on/off the RGBW strip and various room lightning).

I will use a (non-dimmable) 12v transformer to power the Arduino and the RGBW strip, pretty much as linked above (mosfets, etc), should be a non-issue I think.
The TV has an USB out, so I figure I can use this to detect the on/off status of the TV by connecting it to the Arduino input pins. I will *NOT* power the Arduino from the TV's USB.

I want to protect the TV's USB controller (at all costs) from any dumb things I do (which will be a lot), I think I have two options:
a) Use an opto-isolator (NEC PS2501 ?) and keep the TV's USB feed electrically isolated from the Arduino. I guess I need to add a resistor after the isolator on both the USB and the Arduino end to keep from causing a short - Is this correct? If yes, what size? After or before isolator?
b) The second alternative I came up with is connect the USB 5v from the TV to one of the Arduinos input pins, should be pulled high when the TV starts. To protect the TV I've tried to find 5v 500ma fuses, but I can't find any polyfuses in that size. I also don't know where to put it (5v, GND, both?). Suggestions?
Also, if I do b), should I use a diode on the USB 5v line to prevent "backcurrent" from when I break the Arduino by applying 12v to the wrong place?

If I do b), do I connect the USB GND to the Arduino GND? Bit confused since they'll essentially have different grounds.. the Arduino is fed from the 12v transformer while the USB is fed from the TV's internal powersupply. Also, do I need a resistor here somewhere?

Any input would be appreciated!

Offline rosskinard

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +3/-0
Re: RGB(W) arduino device
« Reply #31 on: March 19, 2014, 06:46:08 pm »
Here is the finished RGBW sketch if someone wants it...

Just put together a device and uploaded this to it. Works, but when you select 100% on any of the channels it turns off. I'll tinker with the sketch and all to see if I can contribute anything useful.

Wonder how hard it will be to combine the 3 and/or 4 devices into one single Vera device with the correct number of settings inside it.

I already have RGB light strips in the kitchen, so I need to make two 3-channel RGB control modules for them (2 sets of cabinets...no way to link them via wire without ripping out drywall. Kitchen is downstairs so no access method to run wiring up one wall and down another. I may go ahead and make them RGBW controls in case I want to add in white later...maybe inside the cabinets so they can be trigged by a magnetic switch when a door is opened.

Thanks for the work of all involved...this is some really cool stuff.

Offline rosskinard

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +3/-0
Re: RGB(W) arduino device
« Reply #32 on: March 19, 2014, 08:46:21 pm »
OK...figured out the error making it turn off at 100%

Change this line:

Code: [Select]
     analogWrite(message.header.childId, 256*incomingDimmerStatus/100);
to

Code: [Select]
     analogWrite(message.header.childId, 255*incomingDimmerStatus/100);
Lights operate on 0-255, so using 256 to multiply by basically was setting 100% to 0. If you send higher numbers to the pins, they just cycle over the 0-255 range again.

256 = 0
257 = 1
...
510 = 254
511 = 255
512 = 0

and so on...

Offline SirMeili

  • Hero Member
  • *****
  • Posts: 1052
  • Karma: +43/-20
Re: RGB(W) arduino device
« Reply #33 on: March 20, 2014, 12:23:48 pm »
Here is the finished RGBW sketch if someone wants it...

@Korttoma, I've been doing research, but I specifically want to use this in my vera. Is there any ways you could do a simple write up of how you did all the hardware (And what is needed) to accomplish this? I would like to use this behind my Bathroom Mirrors (there is a gap between the mirrors and the wall).
VeraLite (Live); ISY 994i (Live); Vera 3 (Waiting to replace VeraLite); Vera Edge (Waiting for all the bugs to be fixed); Xuan StackBox (Testing and waiting for more plugins and for it to mature)
Countless z-wave and insteon devices :D

Offline rosskinard

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +3/-0
Re: RGB(W) arduino device
« Reply #34 on: March 20, 2014, 01:02:08 pm »
Here is the finished RGBW sketch if someone wants it...

@Korttoma, I've been doing research, but I specifically want to use this in my vera. Is there any ways you could do a simple write up of how you did all the hardware (And what is needed) to accomplish this? I would like to use this behind my Bathroom Mirrors (there is a gap between the mirrors and the wall).

The hardware is pretty basic. In addition to your Arduino/radio combo, you'll need
4x NPN MOSFETS (I use 30N06L) to handle the regulation of the 12V power to the LED strip
4x 120 ohm resistors

I don't have the schematic handy but in a nutshell:
D3 -> resistor -> PIN #1 MOSFET #1
D5 -> resistor -> PIN #1 MOSFET #1
D6 -> resistor -> PIN #1 MOSFET #1
D9 -> resistor -> PIN #1 MOSFET #1

MOSFET #1 PIN #2 -> LED strip RED
MOSFET #2 PIN #2 -> LED strip GREEN
MOSFET #3 PIN #2 -> LED strip BLUE
MOSFET #4 PIN #2 -> LED strip WHITE

All MOSFETs have PIN #3 connected to ground.
RGB Strip V+ goes to the 12V+

IMPORTANT TO NOTE:

With the pin configuration used here, you will move the radio's CE pin (PIN #9) to PIN #4 of the Arduino. We're using PIN #9 for the WHITE pin so the sketch is written for the radio on PIN #4.

Make sure the Arduino GND is linked to the 12V+ supply ground. I use an UNO for this since it already has a DC jack built on it and will run off the 12V supply. It also provides the 3.3V for the radio.

Here's the modified code for the dimmers (one change to the multiplier in the original sketch to correct for 100% turning the LEDs off):
Code: [Select]
// Example sketch showing how to control RGBW LED Strip.

//IMPORTANTE NOTE!!! one of the "radio" pins has been moved from pin 9 to pin 4 because the White is connected to pin 9 !!!!

// This code should generate 4 Dimmer devices in Vera so you can control the RED, GREEN, BLUE and WHITE individualy

#include <Relay.h>
#include <SPI.h>
#include <EEPROM.h> 
#include <RF24.h>

// Set RADIO_ID to something unique in your sensor network (1-254)
// or set to AUTO if you want gw to assign a RADIO_ID for you.
#define RADIO_ID 4

#define RED       3 // pin for red LED
#define GREEN     5 // pin for green
#define BLUE      6 // pin for blue
#define WHITE     9 // pin for white


Relay gw(4,10);

void setup() 

  Serial.begin(BAUD_RATE);  // Used to write debug info

  gw.begin(RADIO_ID);

  // Register all sensors to gw (they will be created as child devices)
  gw.sendSensorPresentation(RED, S_DIMMER);
  gw.sendSensorPresentation(GREEN, S_DIMMER);
  gw.sendSensorPresentation(BLUE, S_DIMMER);
  gw.sendSensorPresentation(WHITE, S_DIMMER);
 

      pinMode(RED, OUTPUT);
      pinMode(GREEN, OUTPUT);
      pinMode(BLUE, OUTPUT);
      pinMode(WHITE, OUTPUT);
      analogWrite(RED, 0);
      analogWrite(GREEN, 0);
      analogWrite(BLUE, 0);
      analogWrite(WHITE, 0);
   
    // Request/wait for relay status
     gw.getStatus(RED, V_DIMMER);
    setDimmerStatus(gw.getMessage()); // Wait here until status message arrive from gw
     gw.getStatus(GREEN, V_DIMMER);
    setDimmerStatus(gw.getMessage());
     gw.getStatus(BLUE, V_DIMMER);
    setDimmerStatus(gw.getMessage());
     gw.getStatus(WHITE, V_DIMMER);
    setDimmerStatus(gw.getMessage());
   
}


/*
*  Example on how to asynchronously check for new messages from gw
*/
void loop()
{
  if (gw.messageAvailable()) {
    message_s message = gw.getMessage();
    setDimmerStatus(message);
  }
}

void setDimmerStatus(message_s message) {
  if (message.header.messageType=M_SET_VARIABLE &&
      message.header.type==V_DIMMER) {
     int incomingDimmerStatus = atoi(message.data);
     // Change Dimmer level
     
     analogWrite(message.header.childId, 255*incomingDimmerStatus/100);
     // Write some debug info
     //Serial.print("Incoming change for dimmer on pin:");
     //Serial.print(message.header.childId);
     //Serial.print(", New status: ");
     //Serial.println(incomingDimmerStatus);
   }
}

Hope this helps...if someone wants to post the schematic before I dig it up...

Remember too...this will create 4 separate dimmers in Vera. I renamed mine under the Advanced tab for each device since the plugin will use generic names. Screenshot attached.

Offline korttoma

  • Hero Member
  • *****
  • Posts: 729
  • Karma: +26/-5
Re: RGB(W) arduino device
« Reply #35 on: March 26, 2014, 06:14:55 am »

Hope this helps...if someone wants to post the schematic before I dig it up...


It seems like you have used a different schematic from what I did. I used the one from Jerome Bernards blog but I guess the principle is the same. The one I use has some 10kohm resistor to ground to ensure all channels are off until the arduino has started. How does your setup work when you turn it on?

NOTE! there seems to be some error in the picture in Jeromes blog but the idea is " 10kΩ resistors, between each control/gate pins and ground, in order to force the signal to LOW until the Arduino kicks in!"

http://www.jerome-bernard.com/blog/2013/01/12/rgb-led-strip-controlled-by-an-arduino/
« Last Edit: March 26, 2014, 06:20:47 am by korttoma »
- Tomas

Offline rosskinard

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +3/-0
Re: RGB(W) arduino device
« Reply #36 on: March 26, 2014, 09:36:45 am »

Hope this helps...if someone wants to post the schematic before I dig it up...


It seems like you have used a different schematic from what I did. I used the one from Jerome Bernards blog but I guess the principle is the same. The one I use has some 10kohm resistor to ground to ensure all channels are off until the arduino has started. How does your setup work when you turn it on?

NOTE! there seems to be some error in the picture in Jeromes blog but the idea is " 10kΩ resistors, between each control/gate pins and ground, in order to force the signal to LOW until the Arduino kicks in!"

http://www.jerome-bernard.com/blog/2013/01/12/rgb-led-strip-controlled-by-an-arduino/

I haven't paid much attention to the startup state...I'll have to look next time I reassemble it. I *think* it starts up in the same state it was previously, which didn't bother me so I didn't actually care.

I used the Adafruit tutorials as the guide:  http://learn.adafruit.com/rgb-led-strips/usage

I was hesitant to use the Jerome Bernard one since the breadboard layout error...amazing how your trust in someone's circuit is shaken if they post instructions with an error and it isn't correct 14 months later. His blog links back to the Adafruit tutorial also, so I just fell back on that by default.

The resistor in the Adafruit schematic is for lower-capacity MOSFETs like I used...

All my breadboards are tied up in other sensor tests and things, and I haven't gotten around to getting the LED board etched yet. I'll reassemble this weekend and if the 10K resistors are helpful I'll add them to the board I put together in Eagle.

Offline petewill

  • Beta Testers
  • Full Member
  • *****
  • Posts: 176
  • Karma: +20/-0
Re: RGB(W) arduino device
« Reply #37 on: March 26, 2014, 09:58:21 am »
Hi All,

I just wanted to let others know that apparently the MOSFETs mentioned in Jerome's blog (IRFZ44N) don't work well with 3.3v Arduinos.  I have also been unable to get them to work with a 5v Pro Mini.  Just wanted to let others know in case they are ordering parts based on the blog.  I also noticed now (too late) that later on in the comments of the blog post Jerome says he switched to a logic level MOSFET (IRLZ44N). 

If anyone has any ideas for how I can make my IRFZ44N MOSFET work I'm open to trying whatever is suggested.  If there's not much I can do I will just have to wait for some IRFZ44N MOSFETs.

Thanks,

Pete
My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

Offline hek

  • Moderator
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: RGB(W) arduino device
« Reply #38 on: March 26, 2014, 10:16:59 am »
Hi All,

I just wanted to let others know that apparently the MOSFETs mentioned in Jerome's blog (IRFZ44N) don't work well with 3.3v Arduinos.  I have also been unable to get them to work with a 5v Pro Mini.  Just wanted to let others know in case they are ordering parts based on the blog.  I also noticed now (too late) that later on in the comments of the blog post Jerome says he switched to a logic level MOSFET (IRLZ44N). 

If anyone has any ideas for how I can make my IRFZ44N MOSFET work I'm open to trying whatever is suggested.  If there's not much I can do I will just have to wait for some IRFZ44N MOSFETs.

Thanks,

Pete

I haven't had time to build my own LED dimmer yet.
Are you saying I should recommend IRLZ44N instead in the buying guide on mysensors.org?

Anyone who has build led dimmer here that can confirm this?

Offline RichardTSchaefer

  • Community Beta
  • Master Member
  • ******
  • Posts: 10091
  • Karma: +764/-143
Re: RGB(W) arduino device
« Reply #39 on: March 26, 2014, 10:52:48 am »
According to the specs the  IRLZ44N would like at least 4.4 volts G-S to start conducting efficiently
The IRLZ44N would work well at 2.5 volts.


The 10K resistors to pull the gate down to ground instead of letting them float when the arduino is not powered or is starting up.
And it's important to have a common ground between the Arduino power and the LED power to drive the MOSFET properly.

Offline korttoma

  • Hero Member
  • *****
  • Posts: 729
  • Karma: +26/-5
Re: RGB(W) arduino device
« Reply #40 on: March 26, 2014, 01:45:01 pm »
I use the IRLZ44N on a 5v pro mini and I have not noticed any issues. I feed the 5v pro mini on the raw pin with the same 12v as I feed the LED strip.

blacey also made a quite nice schematic over in the following thread but he also left out the 10kohm to ground on the PWM pins. (in my opinion the resistors are optional)

http://forum.micasaverde.com/index.php/topic,23342.msg161427.html#msg161427
- Tomas

Offline petewill

  • Beta Testers
  • Full Member
  • *****
  • Posts: 176
  • Karma: +20/-0
Re: RGB(W) arduino device
« Reply #41 on: March 26, 2014, 03:36:28 pm »
Thanks for the feedback. 

@HEK, you may want to suggest the IRLZ44N in case people use a 3.3v pro min?

@Richard, do you know how many amps are required for the IRFZ44N?  I tried to understand the data sheet but until I do some more learning, I'm lost.  I am able to get the gate to work if I put a 5v wire directly on the gate (not using the Pro Mini) but so far I haven't been able to get the pro mini to work.  Maybe because the direct wire connection is allowing more amps?  (I'm new so I could be way off). 

@korttoma, maybe you aren't having any issues because you're using the Logic Level MOSFET?  Based on my preliminary reading those are meant to work with micro controllers.  I am too scared to power my pro mini with 12v I already burnt one up when I did that on an earlier project.  I am testing with a dual power (5v and 12v) power brick that I grabbed from a piece of equipment that was being recycled at work.

Thanks for the replies!
My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

Offline petewill

  • Beta Testers
  • Full Member
  • *****
  • Posts: 176
  • Karma: +20/-0
Re: RGB(W) arduino device
« Reply #42 on: March 26, 2014, 07:59:24 pm »
FYI I found this info about the IRFZ44N on the Arduino forum:
Quote
That means it is fully turned on with a gate source voltage (VGS) of 10V.
Any less you are in the liner region and therefore dissipating heat as there is some extra voltage being dropped across the FET.

You should pull up the gate with a transistor to the 12V rail. Or get another FET.
http://forum.arduino.cc/index.php/topic,12885.0.html

Basically the gist of the forum is that the IRFZ44N shouldn't be used with a micro controller unless it is used with a transistor.  Off to order the correct MOSFETs...
My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

Offline blacey

  • Sr. Member
  • ****
  • Posts: 251
  • Karma: +29/-1
Re: RGB(W) arduino device
« Reply #43 on: March 27, 2014, 12:37:11 am »
Basically the gist of the forum is that the IRFZ44N shouldn't be used with a micro controller unless it is used with a transistor.  Off to order the correct MOSFETs...

You want low RDS MOSFETs - I ordered some but haven't had a chance to get back to the Multichannel Dimmable LED due to competing demands...
Three Vera-3 (Home, Seasonal 1 & 2) - Firmware: 1.5.622,   Zwave: 3.20 L:1
One Vera-Edge (Dependent) - Firmware: 1.7.1707, Zwave: 4.5 L:1

Offline petewill

  • Beta Testers
  • Full Member
  • *****
  • Posts: 176
  • Karma: +20/-0
Re: RGB(W) arduino device
« Reply #44 on: March 27, 2014, 07:04:43 am »
@Blacy, thanks.  I ordered the IRLZ44N MOSFETs.  Hopefully those will work ok.
My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA