View Full Version : Simple Arduino controller

11-30-2010, 01:00 AM
Thought I'd share a a quick writeup on the controller I built this year. I know it's way more simple than most people here would be interested in, but it's all I could swing...for this year :D

I thought it might be a nice starter project people could share w/interested friends testing the waters for possibly larger endeavors down the road. Arduino is such an easy platform to get started with. Example code is included.

Someone also posted code here to support 7 channels via Vixen, which I linked to from the writeup, though didn't implement myself.


12-04-2010, 09:52 PM
There's a thread for generic serial from vixen. You should read up on it. I'm running a Mega 2560 with 25 channels. It runs... kinda. Sometimes it'll run all night, others it wont. I think the voltage regulator is supplying all it can so while the arduino is great its limited as well. If I do some motion control next year I will definitely be using it.


12-05-2010, 06:02 PM
Yea, I read that ... after I had this years controller together. The Mega is definitely the way to go. Using a TLC 5940NT or similar serial PWM driver you can get 48 channels out of it, and another 16 if you use the software serial.

In regards to power, the Mega really should have a regulator with more capacity, but it doesn't for now. The only issue I've had was due to the transformer voltage dipping to the point of brown out when the relays powered up. A capacitor solved that issue, but it sounds like you might have a different kind of trouble than that.

Since I believe you mentioned in another thread that you're currently powering via USB, your thought of adding a separate power supply is almost certainly right on the mark.

Here's a quick diagram of how I've got it wired up currently. A split supply would look a bit different, but you get the idea.

|----> coil <----|
| |
+ |------|--------|------------(-)1A diode(+)-----|
| | | |
9-12V 1000uf Arduino---4.7k---base |
| | | |
- |------|--------|---------collector | emitter---|

The relays and high current (C/E) side of the transistors are powered directly from the power supply (9V 1A wall transformer in this case). This relieves the Arduino regulator of all high current loads.

One other thing that might be considered is a transistor with a lower potential current on the base than a 2N2222. I believe that transistor can pull up to 200mA through the base, which makes it possible to overdraw the regulator pretty quickly.

12-05-2010, 07:31 PM
pmscientist - for controlling multiple relays in the manner you describe (external switching transistor), look into the ULN2803 - It's an array of Darlington pairs with built-in base resistors so can be driven directly by a microcontroller at logic levels.

In the event that you need more 5v power than the onboard regulator can provide without burninating, depending on which Arduino variant you have, you may be able to bypass the regulator.

On the Adafruit DC Boarduino (my standard dev board), it has a jumper that allows selection of USB power vs. regulator power. If you outright remove this jumper, neither power option is selected. At this point you can use an external regulator as follows:

Wire the Vin pin of the Arduino to the regulator input. (It's a little confusing, but usually Vin is an output that has whatever voltage is on the DC jack.)
Wire one of the ground pins to the regulator ground
Wire the +5v pin of the Arduino to the regulator output

In my case, I'm getting my 5v from a cannabalized cell phone charger for a car (the mini-USB connector got rusted when I accidentally let it sit in a salty puddle on one of my car's rubber floormats) - Since it's a switching regulator it can deliver quite a bit of current and stay cool.

12-05-2010, 08:12 PM
In case you were interested: if you've put an RS485 on the RX output (google: DMXShield), then you've turned your Arduino into a DMX512 line driver. (it has some faults like "no packet buffering/timing/" etc.. but it works!)
Load the OpenDMX drivers up, and now Vixen talks native DMX to your devices.
I am running all 10 my Pixels in this way.. (my renards are still serial this year).
If you put DMX PICs in your renards, you eliminate native Renard/"Serial".

Going the other way:
1. Arduino DMX Controller: find "fade all DMX channels" code off the playground - and I got the arduino to push a constant "fade" across all 170 RGB DMX channels (each 512 universe is grouped into Reg Green Blue = 170 channels).. I used this to test my pixels - I only had 10 so didn't care about the channel numbering.. just faded everything..
If your handy with programming... you could probably do sequemcing this way and make a standalone controller.

(ie. with DMX REN's, the arduino could control the whole show - not very flexible - but good for a "simple" display - and if you have spare 5V - very "standalone").

2. Arduino DMX Reciever: I loaded some DMXListener code and put an RGB 5050 SMD on the PWM's of the arduino - and set it to listen to 3 channels (RGB)... now Vixen can control teh RGB via DMX.
My plan was to expand the arduino with a daisy-chain of TLC5490's/5050RGBs and then control all (my roof) from DMX (vixen/lsp/madrix etc).
The hope is to get this all to work E1.31...

Just a thought.

12-05-2010, 09:33 PM
I just posted this over in Development, but:

If you're looking to receive DMX on Arduino hardware, I've got Henne's code (targeted at a slightly different AVR) ported over the the MegaXX8s.

There's an example that takes DMX input and drives a single NCP PCA9635 PWM chip at:

(Using straight avr-gcc, not the Arduino IDE for development)

You should be able to convert it to drive 5940s with not too much trouble, or you can use the PCA9635, which has typically been a lot easier to source and is cheaper than DIP TLC5940s even after you've bought a Sparkfun TSSOP breakout last time I checked prices.

12-06-2010, 12:38 AM
Erf, my diagram had a couple extra connections between the capacitor, power supply and Arduino. Edited those out.

That's some excellent DMX information. If you're messing around with Arduino/AVR anyways, it makes a cost effective platform for a DMX dongle. Could come in handy with the Lynx Smart String RGB strings among other things.

Might have to look at the 9635s. It's nice to be able to just use Serial.print with the 5940s, but doing so does increase code size more than I really like, and I2C isn't much more work under the Arduino environment.

A couple ideas for the DMXshield. The Arduino Mega/ATMega 1280 or 2560 might be able to provide some buffering. Consistent timing could likely be provided via a RTC module and use of interrupts. The downside is that both add complexity, and really aren't needed for small numbers of channels.

As far as controlling relays goes, the thought for this project was to use as many common and inexpensive parts as possible, and keep it fairly simple so someone could get their feet wet before jumping to a more complex system. I could have gone w/darlingtons in a DIP package or TIP120s, etc., but you don't get more common and inexpensive than a basic transistor. The higher current capacity of a darlington pair also seemed like overkill. It's not like you're looking for this to ignite rocket motors...http://www.pmscientist.net/arduino/launch_control :D

Good suggestion on an alternate power scenario. I wasn't totally clear on the relay power needs, which really drove the chosen design. The relays need 9-12V@200mA or so each, so running their power through the Arduino's 5V regulator wasn't an option. The Arduino was left to power itself and provide current to the transistor bases, which even the pro mini regulator's 150mA is more than adequate for. Separate 5V and 9-12V power sources w/the grounds tied together is certainly a good solution as well, especially if you don't have a 9-12V wall transformer w/1A capacity. In the spirit of keeping it simple, I decided on the use of a single power supply.