RGB LED lamp help

Stuck with a problem in your code? Seek help here.

RGB LED lamp help

Postby anybodysguess » September 11th, 2014, 7:53 am

Hi, I tried to get help with a project on the Arduino forums, but no one was very helpful, maybe Hack A Day will pull through and be more helpful!
I am sort of just getting into Arduino and the whole programming scene, in the past I did everything analog with discrete components. I love how easy it is to program the arduino to do stuff!

My problem, and its most annoying because the RGB lamp was supposed to be a very short project because I was making a permanent light fixture, I didn't want it to be a project just to play around with like my arduino car.

I have a arduino nano knock off, connected to a RGBW CREE LED through power transistors. I also have a IR receiver connected, although I don't know what brand it is, came off of an old RC heli, but it works just fine.

My problem is after doing research to find WHY my code wasn't working I found that the IR library takes over an internal timer and that messes with PWM. That is only supposed to interrupt the PWM capabilities of two pins, and there are 6 PWM pins, that should leave 4 available, enough to run the RGBW LED, but it seems no arrangement of connections work properly when the IR functionality is enabled. I have the RGB pins fade using a random fading code, and at some point within 5-45 seconds the color will freeze, and the arduino is unresponsive until a reset. This does not happen without the IR enabled, If I just upload the fading code it works perfectly.

I am about ready to put a push button on the front and cycle through off, random fade, and white light with that. I really wanted to use the remote though so I could have white, random, and also pick a color by adjusting all three RGB values up and down, and also adjustable brightness.

I will post code if needed, but I have several versions, all produce the same results, I tried to make one where it turns on off the IR receiver while running the fade loop, then once each loop cycle listens, then turns it back off, but that doesn't work either.
anybodysguess
 
Posts: 12
Joined: September 2nd, 2011, 8:19 am

Re: RGB LED lamp help

Postby st2000 » September 11th, 2014, 8:23 pm

My problem is after doing research to find WHY my code wasn't working I found that the IR library takes over an internal timer and that messes with PWM.


If true, then that is your problem. The Arduino Nano uses an ATmega328. If there is only 1 timer available - even if that is a limitation of the Arduino software - then you need to arbitrate the use of that timer between the two features in your project. The PWM of the fading LEDs and the IR ASK receiver. But it is likely the only way you can do this is to rewrite the LED and IR driver code. Arduno calls them libraries - well, they are not pre-compiled re-locatable code like the libraries in Windows or Linux. The way I understand it, they are C++ source code files that gets compiled along with your code.

I suspect you need to create a single "Arduino Library" that uses the single timer to service the LED and IR software methods (functions). Not a simple task. The people who write "Arduino Libraries" are the people who are abstracting the hardware from you. They are the people making it easy to write Arduino code.

Of course the quickest work around is to use 2 Arduinos. True, it would be like driving a plane to the grocery store. But if you are short on time it would probably work fastes.
st2000
 
Posts: 1454
Joined: February 3rd, 2011, 6:10 pm

Re: RGB LED lamp help

Postby anybodysguess » September 15th, 2014, 8:13 am

I figured the reply would be to use two, I thought of that, I just can't accept the cost of using two for the one lamp. I may try to find a RGB fading chip, that does the fading for me. Or one of those RGB led's that take one signal to control the whole led.
Thanks
anybodysguess
 
Posts: 12
Joined: September 2nd, 2011, 8:19 am

Re: RGB LED lamp help

Postby st2000 » September 15th, 2014, 8:39 am

Option 1:
As you point out, it is almost always cheaper to solve the problem in software. If you are avoiding having to read the Atmel processor specifications - there is the possibility that you can simply deduce the appropriate software for the new combined C++ driver by inspecting the source of the 2 C++ libraries in question. What are the 2 libraries you are using to control the RGB directly as well as the IR/ASK receiver?

Option 2:
Simplify the IR/ASK requirements to a simple toggle feature and write your own code/driver. Do not sample the port fast! Instead, sample it slowly in your normal Arduino looping method/function. When you see activity turn on the lamp and enter a state where activity needs to be absent for at least a second. Afterwards when you see activity again, turn off the lamp and wait again for the absence of the ASK signal. Down side? You can not use this in the vicinity where you use the remote for any other purpose. Up side? It is universal. The lamp will respond to any IR/ASK signal that is modulated at (probably) 48KHz.

BTW, I would stop using the Arduino Nano w/the USB hardware built in. You are paying extra for that each time you buy the Nano. Instead I would buy one USB to serial Arduino adapter and buy the cheaper Arduino Pro Mini. If you wanted to save even more - you could go to the trouble of pulling the Atmel from an Arduino Uno and use the USB to serial circuit on that board to program the Arduino Pro Mini boards. But I think that is more bother than just buying the actual USB to serial Arduino adapter.
st2000
 
Posts: 1454
Joined: February 3rd, 2011, 6:10 pm

Re: RGB LED lamp help

Postby Sumer » February 25th, 2015, 6:04 am

Hi,

This is exceptionally decent and wonderful post.
I am very happy joined this forum.
I like it exceptionally much....!!!!
Thanks alot...



________
You can easily check out our high quality Testking cloud certification which prepares pmp certification well for the You can also get success in real with the qualitywww.rasmussen.edu
Sumer
 
Posts: 1
Joined: February 25th, 2015, 6:02 am


Return to Help Me! Software

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

cron