PDA

View Full Version : Vixen Generic Serial Output controls the Arduino!



Gorak
10-15-2010, 02:05 AM
Vixen Lights is awesome and I wanted to have it control my new little Arduino Duemilanove. I decided to use the generic serial output already in vixen lights as my plugin. I’m using 5 channels on my Arduino (5,6,9,10 & 11) that have PWM so I can fade the LEDs. The generic serial output appears to simply output one byte at a time like so: 06 00 00 00 00 00 0d. I setup my vixen lights sequence to use 7 channels. The first 5 would be for my LEDs, channel 6 is the beat track and channel 7 was a spare. I used a baud rate of 9600. The code simply takes the 7 bytes, stuffs them into an array and then sends them to the hungry LEDs. Check out the code:


/*
The purpose of this code is to allow the Arduino to use the
generic serial output of vixen lights to control 5 channels of LEDs.
Author: Matthew Strange
Created: 14 October 2010

*/

// Output
int Chan1 = 5; // red LED, connected to digital pin 5
int Chan2 = 6; // green LED, connected to digital pin 6
int Chan3 = 9; // red LED, connected to digital pin 9
int Chan4 = 10; // green LED, connected to digital pin 10
int Chan5 = 11; // red LED, connected to digital pin 11

int i = 0; // Loop counter
int incomingByte[7]; // array to store the 7 values from the serial port

//setup the pins/ inputs & outputs
void setup()
{
Serial.begin(9600); // set up Serial at 9600 bps

pinMode(Chan1, OUTPUT); // sets the pins as output
pinMode(Chan2, OUTPUT);
pinMode(Chan3, OUTPUT);
pinMode(Chan4, OUTPUT);
pinMode(Chan5, OUTPUT);
}

void loop()
{ // 7 channels are coming in to the Arduino
if (Serial.available() >= 7) {
// read the oldest byte in the serial buffer:
for (int i=0; i<8; i++) {
// read each byte
incomingByte[i] = Serial.read();
}

analogWrite(Chan1, incomingByte[0]); // Write current values to LED pins
analogWrite(Chan2, incomingByte[1]); // Write current values to LED pins
analogWrite(Chan3, incomingByte[2]); // Write current values to LED pins
analogWrite(Chan4, incomingByte[3]); // Write current values to LED pins
analogWrite(Chan5, incomingByte[4]); // Write current values to LED pins
}
}

Simple and easy. This will only work with a 7 channel output. I can see complications if you wanted to grow this more. Which I do! Next steps will be to daisy chain some Arduinos, and add some SSRs. I’m completely new so I hope this helps another noobie. Any comments or suggestions are appreciated.

dmcole
10-15-2010, 02:42 AM
This will only work with a 7 channel output.

Matthew:

Congratulations on your project.

I have a Arduino Duemilanove sitting on the bench right here with Vixen controlling 16 channels of PWM LEDs and eight more channels of on/off LEDs (the 16 channels are sink controlled and the eight channels are source controlled). It uses DMX rather than the simple plug-in, so requires a few extra chips, like:

*An RS485 converter;

*A TLC5940/5941 to do the PWM on the sink channels.

*A UDN2981 for the source channels.

I wrote about two or three lines of code and cut-and-paste all the rest.

It's all part of the (so-far) incomplete Sawyer Star project (search it here).

I'll get around to documenting this someday, but probably not until after tear-down.

\dmc

Gorak
10-15-2010, 11:31 AM
That is awesome! I'm still learning and like I said I want to see if I can daisy chain a few of these together. I have 4 MAX488s so I'll try RS485 to communicate. Eventually I want to get to where you're at and use an external shield to control more channels. Can't wait! I'll check out the Sawyer Star Project. Thanks!

bnradams
10-15-2010, 01:35 PM
Great Idea!!! I love Arduino's and have played with using them for all kinds of 'play' things. I can see the potential of using the arduino to control some servo motors for a 'moving' display and having Vixen control the 'when' to move. This can be a great addition to my Halloween Display!!!!

Gorak
10-15-2010, 08:37 PM
I never thought about using servo motors until you mentioned it. But you're right that gives you the opportunity for some extra creative displays (other than lights) simply using another channel in Vixen!

bnradams
10-16-2010, 08:07 AM
Should be an easy script to write on the arduino side. The arduino outputs the degrees from 0 to 180, Vixen outputs 0 to 255. Scale the 0~255 into 0~180 and write to servo motor. I will be playing with this tonight, Ill post my script if all goes well.

chesterspot
10-18-2010, 11:13 PM
@Gorak

I loaded your sketch but when I try to run a sequence I get:

Generic Serial
(Router-Startup)
Access to the port 'COM3' is denied

I opened the arduino software and used the serial monitor and sent 00 to turn on the led. I then closed all of the software and restarted vixen. Have ya'll encountered this problem? It might be that Windows told me that COM3 was already in use. The problem is that I have 1-7 in use, some how, and vixen only goes up to COM4. I'll try it on another machine but just wanted to see if I'm doing something wrong.

BTW I have the new Arduino Mega 2560 with 54 DI/O. That should hold me for two years I think. I really want to get this to work as the Arduino is a cool little toy. Also, I just got it in the mail and have played with it a total of 2hrs. In fact I really should go to bed so I can get up for work! :)

Gorak
10-19-2010, 02:30 AM
Did you get your servos working bnradams?


Chesterspot it looks like something is connected to your com port already. All you have to do is make sure you select the correct com port in vixen and match the baud rates with vixen and the code (9600 is what I used). Make sure you don't run the arduino software and vixen at the same time and look at the code. You have the better board than I do so your pin numbers at the beginning might be different. Make sure you use pins with PWM to allow fading. But all I have to do for me is make sure the settings are correct, close all software, start vixen, then plug in the arduino and load my sequence that controls 5 puny channels and hit play lol.

chesterspot
10-19-2010, 07:04 AM
WOOO! It Worked!

I had to start vixen and then plug in the arduino. Kind of a pain if the power goes out or something while I've got the light show up and running. I figured I could just remotely start Vixen. Oh well I'm excited! Time to start sequencing.

chesterspot
10-19-2010, 07:49 AM
I modified your code for 5 PWM and 20 On/off. I'm not sure if my SSR's that are coming will be able to do PWM so we'll see. Man this is easy! Thanks for the original code.


/*
The purpose of this code is to allow the Arduino to use the
generic serial output of vixen lights to control 5 channels of LEDs.
Author: Matthew Strange
Created: 14 October 2010
Modifier: Ben Towner
Modified: 19-OCT-2010
Changes: Addition of 20 Digital On/Off Channels - Setup for Arduino Mega 2560

*/

// PWM Output - ChanX=PWM Pin
int Chan1 = 2;
int Chan2 = 3;
int Chan3 = 4;
int Chan4 = 5;
int Chan5 = 6;

// Digital Output - ChanX=Digital Pin
int Chan6 = 22;
int Chan7 = 23;
int Chan8 = 24;
int Chan9 = 25;
int Chan10 = 26;
int Chan11 = 27;
int Chan12 = 28;
int Chan13 = 29;
int Chan14 = 30;
int Chan15 = 31;
int Chan16 = 32;
int Chan17 = 33;
int Chan18 = 34;
int Chan19 = 35;
int Chan20 = 36;
int Chan21 = 37;
int Chan22 = 38;
int Chan23 = 39;
int Chan24 = 40;
int Chan25 = 41;


int i = 0; // Loop counter
int incomingByte[25]; // array to store the 25 values from the serial port

//setup the pins/ inputs & outputs
void setup()
{
Serial.begin(9600); // set up Serial at 9600 bps

pinMode(Chan1, OUTPUT); // sets the pins as output
pinMode(Chan2, OUTPUT);
pinMode(Chan3, OUTPUT);
pinMode(Chan4, OUTPUT);
pinMode(Chan5, OUTPUT);
pinMode(Chan6, OUTPUT);
pinMode(Chan7, OUTPUT);
pinMode(Chan8, OUTPUT);
pinMode(Chan9, OUTPUT);
pinMode(Chan10, OUTPUT);
pinMode(Chan11, OUTPUT);
pinMode(Chan12, OUTPUT);
pinMode(Chan13, OUTPUT);
pinMode(Chan14, OUTPUT);
pinMode(Chan15, OUTPUT);
pinMode(Chan16, OUTPUT);
pinMode(Chan17, OUTPUT);
pinMode(Chan18, OUTPUT);
pinMode(Chan19, OUTPUT);
pinMode(Chan20, OUTPUT);
pinMode(Chan21, OUTPUT);
pinMode(Chan22, OUTPUT);
pinMode(Chan23, OUTPUT);
pinMode(Chan24, OUTPUT);
pinMode(Chan25, OUTPUT);
}

void loop()
{ // 25 channels are coming in to the Arduino
if (Serial.available() >= 25) {
// read the oldest byte in the serial buffer:
for (int i=0; i<26; i++) {
// read each byte
incomingByte[i] = Serial.read();
}

analogWrite(Chan1, incomingByte[0]); // Write current PWM values to LED pins
analogWrite(Chan2, incomingByte[1]);
analogWrite(Chan3, incomingByte[2]);
analogWrite(Chan4, incomingByte[3]);
analogWrite(Chan5, incomingByte[4]);
digitalWrite(Chan6, incomingByte[5]); // Write on/off values to LED pins
digitalWrite(Chan7, incomingByte[6]);
digitalWrite(Chan8, incomingByte[7]);
digitalWrite(Chan9, incomingByte[8]);
digitalWrite(Chan10, incomingByte[9]);
digitalWrite(Chan11, incomingByte[10]);
digitalWrite(Chan12, incomingByte[11]);
digitalWrite(Chan13, incomingByte[12]);
digitalWrite(Chan14, incomingByte[13]);
digitalWrite(Chan15, incomingByte[14]);
digitalWrite(Chan16, incomingByte[15]);
digitalWrite(Chan17, incomingByte[16]);
digitalWrite(Chan18, incomingByte[17]);
digitalWrite(Chan19, incomingByte[18]);
digitalWrite(Chan20, incomingByte[19]);
digitalWrite(Chan21, incomingByte[20]);
digitalWrite(Chan22, incomingByte[21]);
digitalWrite(Chan23, incomingByte[22]);
digitalWrite(Chan24, incomingByte[23]);
digitalWrite(Chan25, incomingByte[24]);
}
}

bnradams
10-19-2010, 08:45 AM
Yes, I did a quick and dirty script on the Arduino to pass the first hex byte to a single servo PWM output. Only got flaky if Vixen event period was to low, the servo would chatter at anything longer than 100ms. Once I have some cleaned up code Ill post it. Ill probably use the Aduino this year but for next year I think I will make a dedicated 4 channel servo board that will operate off of a standard Renard stream. Should be fairly easy considering the LED PWM out put is the same signal format that a servo needs for positioning. I think I could modify a SSR board and instead of triacs just have an opto amp to buffer the signal and add a 5~6 VDC power supply. Thanks for the insperation!

Gorak
10-26-2010, 01:08 AM
I've been having some fun with this Arduino! I have it hooked up to 2 TLC 5940NTs for a total of 32 channels. Problem is I only have 10 LEDs. Radio Shack wanted $2 for 2 LEDs so I've ordered 100 from mouser for $6. I have the code working and I've added a header since I was getting weird errors with the original code. I'll post it all in a few days when I get the LEDs and can see how far I can push this thing. I have 4 total TLCs which should mean 64 channels of love but we'll see. Might need external power. Time to buy that multimeter...

Gorak
10-29-2010, 03:07 AM
I'm back! And with better toys! I bought 4 TLC 5940NTs so that allows me to have 64 channels using the generic serial output. First I downloaded the the tlc5940 library (http://code.google.com/p/tlc5940arduino/). It comes with a few examples and some nice pics on how to setup your breadboard. I tried out the BasicUse example and the Fades to make sure it was working correctly.

To read the vixen generic serial output I setup the plugin output to send channels 1-64. I also used a header of '~!' (sans quotes). In the tlc_config file where you specify how many TLCs you are using I added a VIXEN variable to specify how many channels I'm using.


#define NUM_TLCS 4
#define VIXEN 64

The sketch is simple:

void setup()
/*
The purpose of this code is to allow the Arduino to use the
generic serial output of vixen lights and the TLC library
at http://code.google.com/p/tlc5940arduino/
to control many channels of LEDs.
Author: Matthew Strange
Created: 29 October 2010
*/

#include "Tlc5940.h"
{
/* Call Tlc.init() to setup the tlc.
You can optionally pass an initial PWM value (0 - 4095) for all channels.*/
Tlc.init();
Serial.begin(19200);
}

/* Set the channel number using the vixen variable in the tlc_config.h file */

void loop()
{
Tlc.clear();
if (Serial.available() > VIXEN+2) {
int uno = Serial.read();
if (uno == 126){
int dos = Serial.read();
if (dos == 33){
for (int i=0; i<VIXEN+1; i++) {
int bb = Serial.read();
if (bb > 0){
bb = (((bb+1) * 16) - 1);
}
Tlc.set(i, bb);
bb = 0;
}
Tlc.update();
}
}
}
}

Uno and Dos check to make sure the header '~!' was sent so we know where to start the sequence. I should probably just change it to read 2 then 3. I added the line 'bb = (((bb+1) * 16) - 1);' to convert Vixen's 256 steps (0-255) to the TLC's 4096 (0-4095). I think I could shift the bits with bitwise or bit something but I was not successful . . . . yet. It runs really well with 32 channels but in the 15 minutes I've had to play with it, 64 channels seemed a bit much for it to handle with a fast song like wizards in winter and all lights on flashing super fast. I'll adjust it some more this weekend when I have a chance to play more. Now all that is left is to grab a multimeter and take some readings, maybe add an external power supply and hook it up to some SSRs. Hopefully this post will help someone.

budude
10-29-2010, 03:29 AM
Aren't those TLC chips the best!? I got a tube of them but haven't done anything with them quite yet (was going to hang them off my Propeller chips - oh well - next year!). You have a nice project there - it could be packaged up pretty small if need be.

frenchruston
11-02-2010, 11:49 PM
I was glad to see your post. I purchased my Arduino Duemilanove last year. Plus i purchased Prop-SX board this year plus several IO Relay boards. So I was excited to finally use what you have accomplished as a starting point for my work.

Any advice about extending the network over SPI or I2C? I was considering DMX but think i will wait next to implement the DMX..
- Already running into the comm port not going past port 4. So i have some reading to do :)

budude
11-03-2010, 12:39 AM
Any advice about extending the network over SPI or I2C? I was considering DMX but think i will wait next to implement the DMX..
- Already running into the comm port not going past port 4. So i have some reading to do :)

You may want to check out Entropy's thread HERE (http://doityourselfchristmas.com/forums/showthread.php?t=10157) for some ideas.

Gorak
11-03-2010, 02:03 AM
I was glad to see your post. I purchased my Arduino Duemilanove last year. Plus i purchased Prop-SX board this year plus several IO Relay boards. So I was excited to finally use what you have accomplished as a starting point for my work.

Any advice about extending the network over SPI or I2C? I was considering DMX but think i will wait next to implement the DMX..
- Already running into the comm port not going past port 4. So i have some reading to do :)

Thanks for the comment. It was hard to find any information about vixen working with an Arduino so that is why I posted. Wanted to help others who were like me looking for a starting point. The cool thing with the Arduino is that you can program it to do more than lights, it has a lot of potential. I'm not saying all but the few controllers I've looked at on here can only/mostly do lights.

I ordered 4 chips to do full duplex RS-485 but I'm not going to start that until next year. I want to hook what I have to the SSRez and see what real results I can accomplish. I still need to do a little math, I'm getting 1.8v output and I think the optocoupler can only take a max of 1.5v. I'll have to check.

n1ist
11-03-2010, 06:49 AM
Just treat the optocoupler like any other LED. I believe we try to run them around 5mA, and there's a series resistor already on the SSR, but depending on how you are driving it, you may need to change the value.
/mike

Mactayl
11-03-2010, 07:12 AM
I ordered 4 of them and I am going to play with them for awhile, they seem like they have potential ;)

frenchruston
11-03-2010, 08:40 PM
I have am horrible at going and blowing when I get an ideas, so I took a year to plan and found some good deals.

www.lightnwire.com - Low Cost DC Powered Light wire super bright 5 mm for $1.50.
www.futurlec.com - IO Boards| 1watt LED. I just placed my second order, but always email them about quantity before you order. I hope to test my DC Opto-Isolated output board this week i got dirt cheap. Takes a while to get here but the company is great.

About the Arduino, are you seeing issues with the clocking.

frenchruston
11-04-2010, 12:12 AM
Ok, i read where someone earlier said hey where not a programmer. I am about to show my ignorance ;) I SUCK AT ELECTRONICS BUT A PRETTY DARN GOOD PROGRAMMER..

I understand the PWM to dim, but what if :confused: I BOUGHT A BOARD AND IT APPEARS TO BE DIGITAL ON|OFF.:confused:

How do I tell what data vixen outputs.
Below is the link to the board I am trying to get to work. The problem is the lights are not working according the sequence. I used on/off in the seq, I have matched the channels with the code but the lights remain on and react to vixen in a random order.

http://www.tellab.it/open2b/var/catalog/product/files/55.pdf

Thanks

A Marchini
11-06-2010, 12:13 AM
I understand the PWM to dim, but what if :confused: I BOUGHT A BOARD AND IT APPEARS TO BE DIGITAL ON|OFF.:confused:


http://www.tellab.it/open2b/var/catalog/product/files/55.pdf


What are you using to control this board? I think I missed something. Why are you using this board? Are you controlling high voltage LEDs or something?

Are you using an arduino?

Tony M.

frenchruston
11-08-2010, 07:11 AM
I do have some 1 & 3 Watt LED Plus LightnWire I hope to run off that board.
Good News - I have the board working with my Arduino via Generic serial driver. The board turned out to be always on which is no big deal, i can use it to control the sign and Accent Lighting.

frenchruston
11-08-2010, 07:37 AM
Now I need to make a decision and was hoping for some suggestions.
Time is limited and I would love to dim some LED String Lights:
Any recommendations on pre-assembled SSR relay boards to use?

Plus I need to add more controllers to my Serial and/or DMX Network:
When I purchased the Prop-SX card it was recommend I use a 50 Mhz Crystal for timing on a DMX Network. Can I use my extra 50 hz Crystal to do the same with Arduinio? I know I can always leave the Arduino as Serial & put the Prop-SX as DMX if I choose but would like to take the project as far as possible this year. Since the Arduino is easier to work with, I though of purchasing a Arduino Mega for more outputs but worry about the clocking. Any suggestions or warnings from the more experienced?

Why DMX?
I have several RS232/RS485 Serial Servers and would like to use them to locate my controllers throughout display over a 1 acre yard.

n1ist
11-08-2010, 01:15 PM
The processor on the Arduino is limited to 20MHz. The bootloader code, howerver, must be rebuilt and reloaded with a programmer if you change the clock rate.

/mike

Photo-Worx
11-22-2010, 08:25 PM
GORAK,
I copied the code from post #13 and pasted it into a sketch and made the tlc_config file, but when I try and verify the program I get the following error:

expected unqualified-id before '{' token

In file included from a_a_vixen_controller.cpp:16:
C:\arduino-0021\libraries\Tlc5940/Tlc5940.h:51: error: expected initializer before 'extern'
a_a_vixen_controller:13: error: expected unqualified-id before '{' token
a_a_vixen_controller.cpp: In function 'void loop()':
a_a_vixen_controller:25: error: 'VIXEN' was not declared in this scope

Any idea what would cause this? I would really love to use this for Vixen as the Arduino Pro's are out and they are only $20.00.

Thanx in advance.

Gorak
11-23-2010, 12:18 PM
Hi Photo!

The project is fun! The TLCs are working great with DC but I'm having trouble getting them to work with a triac. Just don't have much free time to play with it as I would like. Might have to switch to a different chip. Anyway, I'm not an arduino expert by any means but it appears you have 2 errors. One looks like you didn't define the VIXEN variable like it says to do in post #13. Look at the post, it says to add in your tlc_config.h file that line: '#define VIXEN 64'. I have 4 TLCs so I have 64 channels. If you have 1 TLC that is 16 channels. You said you made the file, and if you included it in the sketch correctly the VIXEN variable should work.

The other error looks like a bracket '{' or '}' error or maybe the 'Tlc.init();' is not working. Did you get the BasicUse or Fades examples to work with your TLC chip first before trying my code?

Photo-Worx
11-23-2010, 05:08 PM
Gorak,

Thanx for the reply. If I can get this working, it could make for a great Cheaper controller project.

I found one problem. The line ' #include "Tlc5940.h" ' was inside the void setup instead of before it. (you might want to change that in your example).

I still can't get it to compile as it says that VIXEN isn't defined. Here are my code file and my tlc_config file as they show up:

Main Program:


/* TLC5940 Vixen controller
*/
#include "Tlc5940.h"

void setup()
/*
The purpose of this code is to allow the Arduino to use the
generic serial output of vixen lights and the TLC library
at http://code.google.com/p/tlc5940arduino/
to control many channels of LEDs.
Author: Matthew Strange
Created: 29 October 2010
*/
{
/* Call Tlc.init() to setup the tlc.
You can optionally pass an initial PWM value (0 - 4095) for all channels.*/
Tlc.init();
Serial.begin(19200);
}

/* Set the channel number using the vixen variable in the tlc_config.h file */

void loop()
{
Tlc.clear();
if (Serial.available() > VIXEN+2) {
int uno = Serial.read();
if (uno == 126){
int dos = Serial.read();
if (dos == 33){
for (int i=0; i<VIXEN+1; i++) {
int bb = Serial.read();
if (bb > 0){
bb = (((bb+1) * 16) - 1);
}
Tlc.set(i, bb);
bb = 0;
}
Tlc.update();
}
}
}
}

tcl_config.h:


#define NUM_TLCS 1
#define VIXEN 16

Was I supposed to create a tcl_config.h in the same directory as the program file or change something in the file that came with the drivers in the TLC5940 Library?

Photo-Worx
11-23-2010, 10:06 PM
Figured it out. I had to put the VIXEN def in the libraries tcl_config.h file.
I have it running with 1 chip, 16 channels.

My only problem now is it doesn't always start at the beginning of the vixen sequence and it doesn't turn the led's off at the end even if i indicate an off state on all lines.

Any ideas?

chesterspot
11-25-2010, 09:29 AM
I've found something odd once I got my show up. It seems that Vixen 2.5 is dropping the COM port before the sequence is complete. The way I found this out is that it works all of the time using the sequence alone but when I put it in a program it drops the connection before the end of the song and the next starts. So unless I figure out the problem blinky flash is not happening this year.

budude
11-25-2010, 11:25 AM
You might play around with the Prefererences->Sequence Execution->Reset controller at end of sequence (at least in 2.1). It defaults to on but you might try turning that off to see if it helps.

chesterspot
11-26-2010, 09:16 PM
Thanks. I set turned off the controller reset and I also set the program to use the plugin's from each sequence. When I set the controller to the arduino profile it would crash so each sequence is set to that profile alone and seems to be working. It's run for 30min so far without a hiccup.

chesterspot
11-29-2010, 09:08 AM
Here's an update on where I stand with the Arduino. After doing all of my sequencing on my main computer there were some errors with the profile I'm using for the Arduino. When I tired to use the scheduler it crashed. So I created a new profile and program and it worked for about 30 min. I moved the baud rate to 34800 and that has really improved performance. The Arduino still crashes once a night but can now be run continuously for a few hours. I've narrowed down the problem to either the serial buffer is filling up and not dumping and/or the voltage regulator on the board is giving out. I have external power hooked up at 9v/600ma but am going to use the ATX PSU that I am using to power the SSRs. It'll be like 7v/10A so hopefully I can rule out the power problem.

I'm new to the Arduino scene but really like the platform. I think it's somewhat limited as a Christmas light controller and will probably try the Renard SS boards next year. With that said does anyone know how to do a software reset or memory clearing on the Arduino? If I could have it reset itself every couple of hours I think it would at least help.

chesterspot
12-02-2010, 09:39 PM
Well unless I get this thing running better this will be my last post. I've found that I have some major overheating issues. I have yet to try the 7v from my ATXPSU but I'm really fed up. If it's 65 deg in my house then the arduino will run for hours. It was 77 one day and it would hardly get through 2 songs. Heck it even started on it's own today but seeing as it's about 73 in here (weather not my choice) it's frozen twice. I think i'm just gonna write a sketch for the arduino to do some little flickers or something. What a disappointment. All this time working on it. Oh well there's always next year.

Words of advice: Don't use the arduino unless you want to do motion or only a few channels.

A Marchini
12-02-2010, 09:52 PM
I have yet to try the 7v from my ATXPSU but I'm really fed up.

I have to ask this... where are you getting 7 volts on an ATX power supply?
I am not understanding why your device is overheating?

Tony M.

budude
12-02-2010, 09:55 PM
Well unless I get this thing running better this will be my last post. I've found that I have some major overheating issues. I have yet to try the 7v from my ATXPSU but I'm really fed up. If it's 65 deg in my house then the arduino will run for hours. It was 77 one day and it would hardly get through 2 songs. Heck it even started on it's own today but seeing as it's about 73 in here (weather not my choice) it's frozen twice. I think i'm just gonna write a sketch for the arduino to do some little flickers or something. What a disappointment. All this time working on it. Oh well there's always next year.

Words of advice: Don't use the arduino unless you want to do motion or only a few channels.

What is the maximum overall current that the Arduino can support (from a device perspective - not per I/O pin)? The spec sheet says 40mA/output but I didn't see the overall I/O maximum. Typically this is much less than the single output x number of I/O's. Maybe check out the datasheet a bit deeper and determine how much you are actually drawing/sourcing to be sure.

chesterspot
12-02-2010, 10:55 PM
You get 7 volts by using the +5 and +12 lines. Taking the difference gives you 7v.

Yea I think that voltage regulator is getting warm and is right at the limit of how much it'll output. It sucks. I haven't been able to find an overall amperage rating anywhere. All of my boards are controlled by 2n2222 transistors from the arduino but i'm sure that I'm at the limit of the board. Once you get some voltage drop the board resets and that's where Vixen is dying. I'll either just build a sketch to do some blinky or lower the amount of channels I'm using. :(

pmscientist
12-04-2010, 12:18 PM
I don't know about the ATmega chip itself, but the regulator the current and previous Arduino versions use is a MC33269D, which has an 800mA capacity. Not that you'd be using 3.3v, but the Arduino supplies that with a 50mA max. Not sure why they spec the 3.3v max and not the 5v max. Perhaps it has to do with heat dissipation variations depending on supply voltage, as the regulator does not have a heat sink.

If you're powering via USB, max current should be ~500mA per the USB spec.

If you're using another Arduino board, you should check the specs on the regulator. I know the promini board uses a MIC5205 regulator, which maxes out at 150mA.

chesterspot
12-04-2010, 09:00 PM
Ill have to look at the chip. I pulled out the external power and am just using USB. I thought it would work better and it didn't last night. But tonight it's been running since 1730 all by itself. It'll probably die in an hour or so... im pessimistic. I'm thinking about trying to use an external regulator and feeding +5v to the board. Honestly at this point im not going to try much more. I just think that I'm at the edge of what it's capable of. I think as it gets cooler it will run better. I've thought about attaching a small piece of metal to act as a heatsink.

Entropy
12-05-2010, 06:53 PM
Ill have to look at the chip. I pulled out the external power and am just using USB. I thought it would work better and it didn't last night. But tonight it's been running since 1730 all by itself. It'll probably die in an hour or so... im pessimistic. I'm thinking about trying to use an external regulator and feeding +5v to the board. Honestly at this point im not going to try much more. I just think that I'm at the edge of what it's capable of. I think as it gets cooler it will run better. I've thought about attaching a small piece of metal to act as a heatsink.

I mentioned this in another thread that I think you were participating in, but in my case - I cannablized a cell phone car charger that was rated for 5v at 1-2A (not sure exactly what) and used it as an external regulator.

All of the problems you describe sound like an overheating regulator because you're asking it to deliver WAY too much current.

Arduino-compatible hardware can do quite a bit if you use the right support circuitry. I know I can easily dim 8 LEDs smoothly using software PWM. If you want to drive external relays you should use a ULN2803 to provide external switching transistors.

chesterspot
12-06-2010, 02:23 PM
I'm using 25 2N2222's to take 5V to gnd for the SSRoz and other SSR's I'm using. 5v from arduino pins to base through 4.7k resistors, I think. I think my problem may be simpler. 04-DEC it ran all night. Last night it failed once and I realized that I had closed the cover on the box the PSU is in for the SSR's. After I opened it and it cooled it ran all night. I think I am getting voltage fluctuation there and need to add a load resistor to see if that smooths things out and/or try another one of the many PSU's I have sitting around. I spend between 15 and 90 min a night working on this........"hobby" even though I keep saying I'm giving up. LOL!

chesterspot
12-07-2010, 11:17 AM
I decided to try running the Arduino through my powered USB hub after it died in an hour. As you all have stated there's just not enough power provided by a USB port. So I started looking for a way to easily inject 5v without using the ATX PSU that I thought might be faulty and without having to go to the store and get regulator. The hub has a 6v 2.1A wall wart. After hooking up the hub I had no problems. The hub got warm, as expected, but should provide all the power the Arduino needs. I'll let you know how tonight goes. And if this doesn't work I think that I'll just only run the show when I'm home. Not really sure why I didn't think of it before but as they say hindsight is 20/20.

bjohns17
12-12-2010, 09:54 PM
void loop()
{ // 7 channels are coming in to the Arduino
if (Serial.available() >= 7) {
// read the oldest byte in the serial buffer:
for (int i=0; i<8; i++) {
// read each byte
incomingByte[i] = Serial.read();
}

analogWrite(Chan1, incomingByte[0]); // Write current values to LED pins
analogWrite(Chan2, incomingByte[1]); // Write current values to LED pins
analogWrite(Chan3, incomingByte[2]); // Write current values to LED pins
analogWrite(Chan4, incomingByte[3]); // Write current values to LED pins
analogWrite(Chan5, incomingByte[4]); // Write current values to LED pins
}
}[/CODE]


I am just trying to understand this code, I am confused why the for loop goes from 0-7 (i=0; i<8) when you only have 7 channels. Maybe I'm missing something. Should it just loop 7 times (0-6)?
Anyway I'm trying this out tonight. I am using the vixen software to create a sequence for a water fountain application. I have 9 solenoid valves(25ms response time) that I'm pulsing on and off and I'm wanting to use the arduino as the data handler for my driver circuits. Thanks for the code!!

phinch
03-30-2011, 04:56 PM
Hi sorry to dig up an old post, but I wrote an arduino sketch that will use pwm on the 6 available pwm channels, and on/off control for the 12 other outputs.
I have Vixen running at 57.6k and it seems to work great.

I plan on building a shield will be SSRez compatable someday....

I'm new to this forum and I love everything about it. You people have created an amazing resource.



/*
The purpose of this code is to allow the Arduino to use the
generic serial output of vixen lights to control 18 channels of LEDs.
6 pwm and 12 on/off


Code Modified by: Phinch
Original Code: Matthew Strange
Modified: 30 March 2011


Channel | output type | Pin
------------+-------------+-----
Channel 1 | PWM | 3
Channel 2 | PWM | 5
Channel 3 | PWM | 6
Channel 4 | PWM | 9
Channel 5 | PWM | 10
Channel 6 | PWM | 11
Channel 7 | Digital | 2
Channel 8 | Digital | 4
Channel 9 | Digital | 7
Channel 10 | Digital | 8
Channel 11 | Digital | 12
Channel 12 | Digital | 13
Channel 13 | Analog | A0
Channel 14 | Analog | A1
Channel 15 | Analog | A2
Channel 16 | Analog | A3
Channel 17 | Analog | A4
Channel 18 | Analog | A5



*/

// Output
int pwmchans[6] = {3,5,6,9,10,11};
int onoffchans[12] = {2,4,7,8,12,13,A0,A1,A2,A3,A4,A5};

//setup the pins/ inputs & outputs
void setup()
{
Serial.begin(57600); // set up Serial at 9600 bps
for(int i = 0; i<6; i++)
{
pinMode(pwmchans[i], OUTPUT); // sets the pins as output
pinMode(onoffchans[i], OUTPUT);
pinMode(onoffchans[i+6], OUTPUT);
}
}

void loop()
{
if (Serial.available() >= 18) {
for (int i=0; i<18; i++) {
// read each byte and send it to the output function
int incomingByte = Serial.read();
decodeOut(i, incomingByte);
}
}
}

void decodeOut(int chan, int value)
{ // outputs pwm to proper channels and digital others
for(int i=0;i<6;i++)
{
if (chan == i)
{
analogWrite(pwmchans[i], value); // pwm
}
if (chan == i+6)
{
digitalWrite(onoffchans[i], value); // first 6 onoff channels
}
if (chan == i+12)
{
digitalWrite(onoffchans[i+6], value); // last 6 onoff channel
}
}
}

chesterspot
03-30-2011, 09:54 PM
Just note that PWM wont work properly without some zero cross code. I ran into reliability issues with my Arduino Mega. 25ch is just a bit too much for the voltage regulator/atmega. It took me weeks to get the show to run continuously and I got it to run most nights on it's own. Not trying to discourage you, I hope you get yours working better than I did. I am moving to a Renard XC and some SS's this year. I want dimming and purpose built hardware. If you have any questions about my arduino setup let me know and I'll be glad to help.

Gorak
03-31-2011, 01:09 AM
I had fun with my arduino as well. Like Chester said it didn't seem "strong" or "beefy" enough (technical terms) to handle as many channels as I wanted while pushing SSRs. With LEDs it works fine but adding the zero cross for the number of outputs I wanted was a strech for my arduino duemilanove to handle. I also had to stop my testing/development a month before last Nov. because of work so I don't want to discourage either.

Looking for something stronger to test I ordered the Cyclone IV FPGA from terasic.com It has 152 I/Os and should hopefully push the number of SSRs with more reliablilty. I'm not an electrical engineer but the community here is a very helpful resource. Looking forward to seeing what this board can do.

phinch
03-31-2011, 01:24 PM
so with the zero crossing, you need to detect when the phase hits zero and start your pwm from there? interesting...so it only sounds like its only required for ac dimable circuits.
i wonder if I put opto isolators on the arduino side to drive the long cables to the ssrs if that would reduce the load on the arduino's power supply. or i could probably use uln2003's or some other driver chip.

Gorak
03-31-2011, 04:20 PM
It is needed to make sure the triac fires at the right moment. The triac will turn on when a voltage is detected and turn off at the zero cross (or near them). So you need to detect the zero cross to match the frequency (120 zero crossings for 60Hz power). Take a look at this project and read replies #3 & #4 for a better explanation on the math. Actually, read the whole thing and you should be able to create a dimmable circuit and apply that knowledge to the vixen outputs:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230333861

chesterspot
03-31-2011, 04:32 PM
so with the zero crossing, you need to detect when the phase hits zero and start your pwm from there? interesting...so it only sounds like its only required for ac dimable circuits.
i wonder if I put opto isolators on the arduino side to drive the long cables to the ssrs if that would reduce the load on the arduino's power supply. or i could probably use uln2003's or some other driver chip.

I ran the outputs through 1k resistors to 2n2222 transistors then out to the SSR's. I should have tried to go with a little higher value on the resistor to help a little with power. It works for on/off but AC dimming is magical! If you are using a DCSSR then it'll work just fine.

phinch
04-10-2011, 10:57 PM
were you tying the collector of the 2n2222 to the 5v out of the arduino? if you tied it to a beefier power supply, it wouldn't draw so much current from the arduino, and should be able to handle things just fine.

chesterspot
04-11-2011, 05:19 PM
were you tying the collector of the 2n2222 to the 5v out of the arduino? if you tied it to a beefier power supply, it wouldn't draw so much current from the arduino, and should be able to handle things just fine.

2n2222 are NPN transistors. The Collector was hooked to the low signals for the SSR's. Emitter tied to ground. 5v was supplied via the +5v rail on an ATX PSU.

Goneferal
05-18-2011, 05:20 PM
I am totally new to this stuff and have an arduino uno that I want to use to control my Halloween LED 12v spot lights. I would like to have different channels fade different lights on and off. Is there anyone willing to walk me through the process? I am a quick learner and am eager to get started. Thx in advance for any help.

chesterspot
05-19-2011, 08:57 AM
The first post code should get you started. As long as you are using DC/Transistors you can do dimming.

CheapOLights
06-20-2011, 12:04 PM
To go back to the board reset issues:

I think that you are all right about drawing too much power off of the boards PSU. It makes since to decouple the output from the board's PSU so that it does not overload the processor. I use an old PC power supply and an 8ch op amp to decouple the output. All of the ground lines are tied together and the only thing the micro sources is current (~6ma) for the op amp. It hasn't failed once and the whole board runs cool.

paulfig
07-07-2011, 02:59 PM
I am using the vixen software to create a sequence for a water fountain application. I have 9 solenoid valves(25ms response time) that I'm pulsing on and off and I'm wanting to use the arduino as the data handler for my driver circuits. Thanks for the code!!

I am also interested in using the Arduino to control a water fountain with solenoids to create a Christmas (2011) "water feature." Were you ever able to adapt the arduino to do this?

Gorak
07-08-2011, 12:35 AM
I'm also curious about bjohns17 fountain project! Share a link/images, would love to see!

Goneferal
07-19-2011, 12:16 AM
Here is my 12 channel update to the original post. I'm using Vixen and for some reason although it's only 12 Channels, I have to start Vixen with 14 Channels. I still can't get the softPWM to work to make all PWM. Any thoughts?

/*
The purpose of this code is to allow the Arduino to use the
generic serial output of vixen lights to control 12 channels of LEDs.
Original Author: Matthew Strange Changed by Jeanne Pepalis
Originally Created: 14 October 2010, Revised 7/18/11

*/

// Output
int Chan1 = 2; // LED, connected to digital pin 2
int Chan2 = 3; // LED, connected to digital pin 3
int Chan3 = 4; // LED, connected to digital pin 4
int Chan4 = 5; // LED, connected to digital pin 5
int Chan5 = 6; // LED, connected to digital pin 6
int Chan6 = 7; // LED, connected to digital pin 7
int Chan7 = 8; // LED, connected to digital pin 8
int Chan8 = 9; // LED, connected to digital pin 9
int Chan9 = 10; // LED, connected to digital pin 10
int Chan10 = 11; // LED, connected to digital pin 11
int Chan11 = 12; //LED, connected to digital pin 12
int Chan12 = 13; // LED, connected to digital pin 13


int i = 0; // Loop counter
int incomingByte[12]; // array to store the 12 values from the serial port

//setup the pins/ inputs & outputs
void setup()
{
Serial.begin(9600); // set up Serial at 9600 bps

pinMode(Chan1, OUTPUT); // sets the pins as output
pinMode(Chan2, OUTPUT);
pinMode(Chan3, OUTPUT);
pinMode(Chan4, OUTPUT);
pinMode(Chan5, OUTPUT);
pinMode(Chan6, OUTPUT);
pinMode(Chan7, OUTPUT);
pinMode(Chan8, OUTPUT);
pinMode(Chan9, OUTPUT);
pinMode(Chan10, OUTPUT);
pinMode(Chan11, OUTPUT);
pinMode(Chan12, OUTPUT);
}

void loop()
{ // 14 channels are coming in to the Arduino
if (Serial.available() >= 14) {
// read the oldest byte in the serial buffer:
for (int i=0; i<14; i++) {
// read each byte
incomingByte[i] = Serial.read();
}

analogWrite(Chan1, incomingByte[0]); // Write current values to LED pins
analogWrite(Chan2, incomingByte[1]); // Write current values to LED pins
analogWrite(Chan3, incomingByte[2]); // Write current values to LED pins
analogWrite(Chan4, incomingByte[3]); // Write current values to LED pins
analogWrite(Chan5, incomingByte[4]); // Write current values to LED pins
analogWrite(Chan6, incomingByte[5]); // Write current values to LED pins
analogWrite(Chan7, incomingByte[6]); // Write current values to LED pins
analogWrite(Chan8, incomingByte[7]); // Write current values to LED pins
analogWrite(Chan9, incomingByte[8]); // Write current values to LED pins
analogWrite(Chan10, incomingByte[9]); // Write current values to LED pins
analogWrite(Chan11, incomingByte[10]); // Write current values to LED pins
analogWrite(Chan12, incomingByte[11]); // Write current values to LED pins
}}

dmcole
07-19-2011, 02:13 PM
I still can't get the softPWM to work to make all PWM.

Are you using Brett Hagman's SoftPWM library (http://code.google.com/p/rogue-code/wiki/SoftPWMLibraryDocumentation)?

The code you've posted doesn't have any library listed, so I don't know how you're trying to implement PWM on all the pins. Therefore, it's hard to help you debug.

I have been using the SoftPWM library for the last couple of weeks and have it working on eight pins (all I need), but I don't see any reason why it shouldn't work on 12 ...

Here would be my cut at redoing this code (to be slightly more efficient and to implement the library):



/*
The purpose of this code is to allow the Arduino to use the
generic serial output of vixen lights to control 12 channels of LEDs.
Original Author: Matthew Strange Changed by Jeanne Pepalis
Originally Created: 14 October 2010, Revised 7/18/11
Modified by Dave Cole for use with SoftPWM library, 7/19/11
*/

#include <SoftPWM.h>

int incomingByte[12]; // array to store the 12 values from the serial port

//setup SoftPWM
void setup()
{
//Initialize SoftPWM
SoftPWMBegin();

// Create and sets row pins
for (int i = 2; i <= 13; i++)
{
SoftPWMSet([i], 0);
}
}


void loop()
{
// 14 channels are coming in to the Arduino
if (Serial.available() >= 14)
{
// read the oldest byte in the serial buffer:
for (int i = 0; i < 14; i++)
{
// read each byte
incomingByte[i] = Serial.read();
}
SoftPWMSet(2, incomingByte[0]); // Write current values to LED pins
SoftPWMSet(3, incomingByte[1]); // Write current values to LED pins
SoftPWMSet(4, incomingByte[2]); // Write current values to LED pins
SoftPWMSet(5, incomingByte[3]); // Write current values to LED pins
SoftPWMSet(6, incomingByte[4]); // Write current values to LED pins
SoftPWMSet(7, incomingByte[5]); // Write current values to LED pins
SoftPWMSet(8, incomingByte[6]); // Write current values to LED pins
SoftPWMSet(9, incomingByte[7]); // Write current values to LED pins
SoftPWMSet(10, incomingByte[8]); // Write current values to LED pins
SoftPWMSet(11, incomingByte[9]); // Write current values to LED pins
SoftPWMSet(12, incomingByte[10]); // Write current values to LED pins
SoftPWMSet(13, incomingByte[11]); // Write current values to LED pins
}
}



I haven't even run this through the IDE, so I'm not sure that it will even compile.

HTH.

\dmc

Goneferal
07-19-2011, 05:39 PM
DMcole: Thanks! I'll try some of that out either tonight or tomorrow night. Thanks for the input. Between Haunt Forum and DIYChristmas, I'm in good company.

Materdaddy
07-19-2011, 08:31 PM
Are you using Brett Hagman's SoftPWM library (http://code.google.com/p/rogue-code/wiki/SoftPWMLibraryDocumentation)?

The code you've posted doesn't have any library listed, so I don't know how you're trying to implement PWM on all the pins. Therefore, it's hard to help you debug.

I have been using the SoftPWM library for the last couple of weeks and have it working on eight pins (all I need), but I don't see any reason why it shouldn't work on 12 ...

Here would be my cut at redoing this code (to be slightly more efficient and to implement the library):



/*
The purpose of this code is to allow the Arduino to use the
generic serial output of vixen lights to control 12 channels of LEDs.
Original Author: Matthew Strange Changed by Jeanne Pepalis
Originally Created: 14 October 2010, Revised 7/18/11
Modified by Dave Cole for use with SoftPWM library, 7/19/11
*/

#include <SoftPWM.h>

int incomingByte[12]; // array to store the 12 values from the serial port

//setup SoftPWM
void setup()
{
//Initialize SoftPWM
SoftPWMBegin();

// Create and sets row pins
for (int i = 2; i <= 13; i++)
{
SoftPWMSet([i], 0);
}
}


void loop()
{
// 14 channels are coming in to the Arduino
if (Serial.available() >= 14)
{
// read the oldest byte in the serial buffer:
for (int i = 0; i < 14; i++)
{
// read each byte
incomingByte[i] = Serial.read();
}
SoftPWMSet(2, incomingByte[0]); // Write current values to LED pins
SoftPWMSet(3, incomingByte[1]); // Write current values to LED pins
SoftPWMSet(4, incomingByte[2]); // Write current values to LED pins
SoftPWMSet(5, incomingByte[3]); // Write current values to LED pins
SoftPWMSet(6, incomingByte[4]); // Write current values to LED pins
SoftPWMSet(7, incomingByte[5]); // Write current values to LED pins
SoftPWMSet(8, incomingByte[6]); // Write current values to LED pins
SoftPWMSet(9, incomingByte[7]); // Write current values to LED pins
SoftPWMSet(10, incomingByte[8]); // Write current values to LED pins
SoftPWMSet(11, incomingByte[9]); // Write current values to LED pins
SoftPWMSet(12, incomingByte[10]); // Write current values to LED pins
SoftPWMSet(13, incomingByte[11]); // Write current values to LED pins
}
}



I haven't even run this through the IDE, so I'm not sure that it will even compile.

HTH.

\dmc

Looks like you're going to step on some memory (buffer overflow). You read 14 bytes into the incomingByte array that is only 12 bytes.

dmcole
07-19-2011, 08:59 PM
Looks like you're going to step on some memory (buffer overflow). You read 14 bytes into the incomingByte array that is only 12 bytes.

Good point. I didn't look at that code at all, because the OP had said his problem was with PWM.


I'm using Vixen and for some reason although it's only 12 Channels, I have to start Vixen with 14 Channels.

I wonder if the difference comes from that statement.

Clearly, there are only 12 pins being driven, so either the array is declared incorrectly (should be 14) or the if statement is incorrect (should be 12) -- I guess the latter.

I have only one Arduino and it's set up for another project, so I can't run this code to see if it will work.

\dmc

P. Short
07-19-2011, 09:49 PM
Setting these implementation issues aside, it seems to me that any application using the generic serial output plugin is going to be a bit touchy. The basic problem is that the receiver has no way of knowing when a 'packet' begins and ends. If you power up the controller when Vixen is stopped, and you have both the serial plugin and the remote controller set up for the same number bytes in a frame, then everything will be OK. But if you power up the controller while Vixen is sending data, from time to time the controller will take the byte in the middle of a frame as the start of a frame, and the wrong lights will turn on (or the wrong servo, etc). This won't happen every time, but often enough to be a problem. There is just no sure-fire, 100% reliable way for the controller to know which is the starting byte.

There are other plugins which can provide this information, such as the Firegod plugin, any of the DMX plugins, the Renard plugin, etc. These are all some complicated, I know, for a neophyte to use with Arduino, but there is always going to be a struggle with random flaky behavior for anything using the generic serial output plugin.

Just my $0.02...

dmcole
07-20-2011, 01:47 PM
Setting these implementation issues aside, it seems to me that any application using the generic serial output plugin is going to be a bit touchy.

Phil:

I think the OP was in the mind of the old saw about dancing dogs: "The marvel is not that it dances well, but that it dances at all.” My sense was that this was more of an intellectual exercise that an attempt to create a working system.

I could be wrong, though. And have been wrong on numerous occasions.

\dmc

P. Short
07-21-2011, 12:03 AM
I've been following a closely related thread on another forum by the same poster, and the effort appears to more than just an exercise.

phinch
07-21-2011, 09:30 AM
You can configure the generic serial tosend a start bit on the packet and have the arduino coderesetthe array pointer upon recieving the start bit.

P. Short
07-21-2011, 12:03 PM
What do you mean by 'start bit'?

If you meant 'start byte', there is no guarantee the value of the 'start byte' won't also occur in the data portion of the packet, potentially causing the Arduino program to mis-interpret it. You could change the single 'start byte' to two bytes, and make a synchronization error less likely to occur, but the possibility is still there.

dmcole
07-21-2011, 09:11 PM
I've been following a closely related thread on another forum by the same poster, and the effort appears to more than just an exercise.

Like I said, I could be wrong (and clearly am in this case).

\dmc

Gorak
07-22-2011, 11:22 AM
MasterDaddy - You are correct! I was using 2 bytes extra for something else on my arduino (beat tracks) which is why there are 2 extra bytes not being used by an output. I even made a fool of myself this week at HauntForum forgetting that and telling a person they had their for-loop wrong lol (I still feel bad about that - but I apologized and explained).

P. Short - In my mind I wanted to make a system with arduino and the original post was a beginning to that. I eventually go the system up to 64 channels DC which was fun. With MOSFETs it could be AC. I was new (still am) and posted the code to help other newbies and get advice. The only problem I had (other than being busy with work) was not having enough channels for what I wanted. And maybe daisy-chaining a few arduino Megas would solve that problem. I also notice during fast songs the flashing/dimming was delayed more than I would have liked. I'll be the first to admit it could be my amateur code or something I could have corrected but in the beginning I was definitely happy to just have it all working. Now I demand sacrifice! lol

If I powered the arduino on first and then the vixen software I never had an issue losing bytes or having an unexpected shift. But yes the possibility is certainly there without a byte to align the stream which is something else I didn't have the time to play with. Hopefully I will have time to hook it up again this weekend. Its in a box (recently moved - more stress lol). Hopefully then I can help on the pwmsoft code a bit. I've also been playing with the DE0-Nano by terasic. Its miles ahead of the arduino with 150+ outputs so I'm hoping to use this instead. I have too much fun learning to program these devices

P. Short
07-22-2011, 11:42 AM
MasterDaddy - You are correct! I was using 2 bytes extra for something else on my arduino (beat tracks) which is why there are 2 extra bytes not being used by an output. I even made a fool of myself this week at HauntForum forgetting that and telling a person they had their for-loop wrong lol (I still feel bad about that - but I apologized and explained).

P. Short - In my mind I wanted to make a system with arduino and the original post was a beginning to that. I eventually go the system up to 64 channels DC which was fun. With MOSFETs it could be AC. I was new (still am) and posted the code to help other newbies and get advice. The only problem I had (other than being busy with work) was not having enough channels for what I wanted. And maybe daisy-chaining a few arduino Megas would solve that problem. I also notice during fast songs the flashing/dimming was delayed more than I would have liked. I'll be the first to admit it could be my amateur code or something I could have corrected but in the beginning I was definitely happy to just have it all working. Now I demand sacrifice! lol

If I powered the arduino on first and then the vixen software I never had an issue losing bytes or having an unexpected shift. But yes the possibility is certainly there without a byte to align the stream which is something else I didn't have the time to play with. Hopefully I will have time to hook it up again this weekend. Its in a box (recently moved - more stress lol). Hopefully then I can help on the pwmsoft code a bit. I've also been playing with the DE0-Nano by terasic. Its miles ahead of the arduino with 150+ outputs so I'm hoping to use this instead. I have too much fun learning to program these devices

As a beginning, it's fine. The reason for my earlier post was to point out that it is just the beginning, not the end.

For some of the things that I'm playing with I've written a plugin that has a similar purpose. The biggest difference is that my plugin always sends a '0' byte at the beginning of a packet, and changes any '0' byte in the data stream to a '1'. This provides for a robust way of detecting the beginning of a packet while restricting the output data to the range 1-255 (instead of the usual 0-255). That restriction didn't matter for what I was doing at the time.

n8huntsman
07-22-2011, 07:22 PM
I was thinking something similar. A zero byte would be used frequently but a 255 would be used less. If you limited your display to 80% intensity, it would never be used, correct?

gonzo
07-25-2011, 05:32 AM
Hi guys, I've been working to integrate Vixen to Arduino for the past few week (using 2.1.1.0 and Arduino ATmega 1280)

I have the common configuration working easily - multiple channels, software PWM = lots of blinky lights, but I know this is where this integration is going wrong. One lost bit or byte and the whole display would be corrupted.

So I though I'd use the tools given.


- Limit serial channel brightness values to 196 steps, reserving 197 - 255 for control codes (or header / footer for now) (step up the values on the Arduino end)

- Thus I limited the Max Illumination to 196 (aka 3/4 brightness) - ugly but I can live with that.

- I then defined the header to use a single byte (255) and footer to use a single byte (254)

- Sketched up some code in the Arduino to look for these control codes before allowing the 'channel buffer' to be filled, and then expecting the 'footer' code when the buffer was full (and if it wasn't Huston we have a problem)

- Sounded right, I then proceeded to spend several hours debugging on the Arduino -- grrrr

- Gave up on the Arduino and began to monitor the com port (sysinternals portmon) - and this was when I discovered that somewhere in the generic serial plug-in it has been decided that the header and footer can only use 'printable ascii' codes (tracked down to Encoding.ASCII.GetBytes piece of code) - if the codes are even accepted, they come out at the other end as '?' or code 063

- Thus currently we cant 'reserve' any high or low ascii codes to use in the header / footer (aka cant use 0 – 32, or 127 – 255)


Anyone know how we can amend the source to cater for this?

Be good to be able to translate the 256 steps of illumination to 196 in the plug-in, and use the remaining bytes as channel markers.

Or maybe this is already accomplished in another serial based output plugin - I just need to translate the protocol into Arduino Code.

On an interesting note - the generic serial will not send data when the state of the channels doesn’t change between 'events'


Been following ctmals videos about how to build a plugin + searching through the MSDN website , just need to change Encoding.ASCII to Encoding.UTF8 and we should be away laughing :)

P. Short
07-25-2011, 02:49 PM
Why do you want to reserve that many values for control codes? I think that one code should suffice for most uses. I prefer to use 0 for this purpose, because it is quite easy to spot on an oscilloscope and is the most similar to the break used in DMX. However, the exact value isn't extremely important.

As for the problem with the header/trailer, why don't you just reserve one channel for control purposes? For example, assign channel 0 for the start of frame indicator, and fill it 100% of the time with whatever value you are using for control purposes. If you are using 16 channels for the data portion of the packet, just assign 17 channels to the plugin that you are using, and just make sure that you always have the correct value in the extra channel used for marking the start of frame.

MacabreRob
09-16-2011, 01:41 PM
Any more news on this topic? Enquiring minds want to know...

Gorak
10-09-2011, 02:47 AM
MacabreRob I thought about you today so I'm updating my fun project.

P. Short I wish I had your brain. And thanks to dmcole for helping me this time last year.

LED or DC dimming on the arduino is very simple and I've been wanting to do AC dimming with my arduino hooked up to vixen. After moving this last year and not touching it I finally took it out of the box and had some fun. I set up my solid state relay (4 channels) on the breadboard and zero-cross detection. Everything is working fine and I have had a little success. Doing some slow easy fades isn't a problem.

I think I'm hitting a performance barrier in the arduino. If I use 2 channels, everything is fine. Adding more and the flickering starts. Its bad. I'm a novice so figuring this out has been giving me a headache. LoL I've rewritten the code I think a zillion times, tried different ways, different loops. One thing that does cut down on the overhead is using direct port manipulation instead of digital.write and is just as simple. I'm posting 2 variations of the code below. They work with < 2 channels. I'm using the generic serial output with 5 channels in vixen.

I'm just posting as an update, its not final yet. Maybe its not a performance issue at all but all my "experiments" are pointing in that direction. Either way, to be sure I ordered the Maple Native Beta for Leaflabs (http://leaflabs.com/) tonight which will put any performance questions to rest. Maybe someone will see something I am completely missing or not thinking of and it will be a simple fix. I have done other variations of these (code posts) but with the same results. The more channels I add, the more intense the flickering gets.


// Matthew Strange
// Vixen AC light dimming test 1
// 08-October-2011

int i;
int incomingByte[5];
int dim = 0;
int ledPin = 8;
int z=1;
byte b = B00000000;

void setup() {
Serial.begin(9600);
attachInterrupt(0, light, RISING);
pinMode(ledPin, OUTPUT);
TIMSK1=0x01; // enabled global and timer overflow interrupt;
TCCR1A = 0x00; // normal operation page 148 (mode0);
TCNT1=0x0000; // 16bit counter register
TCCR1B = 0x05; // start timer/ set clock
DDRB = B00111111; // digital pins -,-,13,12,11,10,9,8
};

void light(){
TCNT1=0x0000;
}

void loop () {
if (Serial.available() >= 5) {
// read the oldest byte in the serial buffer:
for (i=0; i<5; i++) {
// read each byte
incomingByte[i] = Serial.read();
incomingByte[i] = (255 - incomingByte[i]);
}
}

if((TCNT1*2)>=(incomingByte[0])){
b |= (1 << 0);
PORTB = b;
delayMicroseconds(5);
b &= ~(1 << 0);
PORTB = b;
}

if((TCNT1*2)>=(incomingByte[1])){
b |= (1 << 1);
PORTB = b;
delayMicroseconds(5);
b &= ~(1 << 1);
PORTB = b;
}
/*
if((TCNT1*2)>=(incomingByte[2])){
b |= (1 << 2);
PORTB = b;
delayMicroseconds(5);
b &= ~(1 << 2);
PORTB = b;
}

if((TCNT1*2)>=(incomingByte[3])){
b |= (1 << 3);
PORTB = b;
delayMicroseconds(5);
b &= ~(1 << 3);
PORTB = b;
}
*/
};



// Matthew Strange
// Vixen AC light dimming test 2
// 08-October-2011

int i;
int incomingByte[5];
int dim = 0;
int ledPin = 8;
int z;
byte b = B00000000;

void setup() {
Serial.begin(9600);
attachInterrupt(0, light, RISING);
pinMode(ledPin, OUTPUT);
TIMSK1=0x01; // enabled global and timer overflow interrupt;
TCCR1A = 0x00; // normal operation page 148 (mode0);
TCNT1=0x0000; // 16bit counter register
TCCR1B = 0x05; // start timer/ set clock
DDRB = B00111111; // digital pins -,-,13,12,11,10,9,8
};

void light(){
TCNT1=0x0000;
PORTB = B00000000;
}

void loop () {
if (Serial.available() >= 5) {
for (i=0; i<5; i++) {
// read each byte
incomingByte[i] = Serial.read();
//incomingByte[i] = (255 - incomingByte[i]);
incomingByte[i] = (255 - incomingByte[i]);
}
}


//while(1){
for (z=0; z<5; z++) {
if((TCNT1*2)>=(incomingByte[z])){
b |= (1 << z);
PORTB = b;
delayMicroseconds(5);
b &= ~(1 << z);
PORTB = b;
}
}
//break;
//}

};


Maybe you'll see something. Feel free to copy/paste/destroy - just give credit if you do.

dmcole
10-09-2011, 05:06 PM
Gorak:

Glad this project is providing you with entertainment.

My (still limited) experience with the A is that loops and whiles introduce a lot of latency into the project. I haven't reviewed your code well enough to know if this is a good idea for you, but have you considered hard-coding those? In other words, instead of (the following nonsense):



for (z=0; z<5; z++)
{
PORTB = z;
}

construct, you do something like


PORTB = 0;
PORTB = 1;
PORTB = 2;
PORTB = 3;
PORTB = 4;

I found that the latter code executes faster than the former code (by like a factor of 10 or 20 ... or maybe two or three ... numbers ain't my specialty).

Anyway, I was able to remove flickering from a project by writing the code that way.

HTH.

\dmc

Gorak
10-09-2011, 07:10 PM
Thanks for the quick reply. I tried hard coding the input as you suggested but it still flickers. You're right, the loops will surely slow it down.


I took this code (From test #1)

if (Serial.available() >= 5) {
// read the oldest byte in the serial buffer:
for (i=0; i<5; i++) {
// read each byte
incomingByte[i] = Serial.read();
incomingByte[i] = (255 - incomingByte[i]);
}
}

and made it this:

if (Serial.available() >= 5) {
serial1=Serial.read();
serial2=Serial.read();
serial3=Serial.read();
serial4=Serial.read();
serial5=Serial.read();
}You also have to make a few changes/declarations but the result was the same.

MacabreRob
10-10-2011, 12:07 AM
How does the arduino actually detect the zero cross? Do you have to have the AC connected to the controller via an input pin, and if so, how do you keep everything from getting fried?

Gorak
10-10-2011, 12:02 PM
I'm using a H11AA1 Optocoupler. I have it linked to the interrupt so every pulse (zero crossing) from the H11AA1 will begin the function. The H11AA1 is also an opto-isolator so the DC and AC sides remain separated.

MacabreRob
10-10-2011, 12:26 PM
I was reading somewhere on the Arduino.cc website about someone encountering flickering doing the dimming. I think he increased the baud rate and that reduced it, but I don't recall exactly...

MacabreRob
10-10-2011, 02:01 PM
Picked up my new 8-Channel relay board I got from Hong Kong. Cost almost as much to ship the darned thing as it was to order. Between this and the 6-channels from the Mr. Christmas box, I now have 14 channels available for my Halloween light show. I saw this morning that the 4-channel relay board I ordered from eBay arrived in a post-office point at 3am this morning, so I might have it by Wedsday, putting my up to a total of 18 channels.

11696

I can either control 12 channels via my parallel port of the computer, with the other 6 controlled by my Arduino Uno microcontroller, or vice versa. Max the arduino can control is 14, and max the parallel port can control is 12. My Mr. Christmas box will receive 6 channels of data, but I have 8 data lines going to it (I run 4 data lines per network jack, so I had 2 left over). I might be able to rig up 2 more channels so that the Mr. Christmas will take in 8 channels total, but that might be pushing things.

Now, of course, all those Vixen sequences I did for 12 channels will have to be re-done for 14, 18 or even 20 channels!

Question: Looking at the terminal blocks, where the AC feeds in, I'm not exactly sure which wire goes where... I have the black, white and ground (bare) wires... Any help? Also, these relay blocks, I'm assuming they are not solid state, but mechanical relays (could be wrong, newbie alert). Are there any issues with non-solid state relays?

budude
10-10-2011, 02:09 PM
The relays typically are used to make/break the hot (black) wire so you connect the black from your AC line to one connector and the hot to your gadget on the other side of the relay (the two outside connections on the block). The neutral (white) would connect directly to your gadget. Ground depends on what you're connecting to - usually it's not required/used but need to know what you're connecting the AC to.

Gorak
10-10-2011, 03:08 PM
I was reading somewhere on the Arduino.cc website about someone encountering flickering doing the dimming. I think he increased the baud rate and that reduced it, but I don't recall exactly...

That was another test I have tried. Used every baud rate available and there is still flickering. Keeps the suggestions coming, I need them! :|

Materdaddy
10-10-2011, 04:03 PM
Picked up my new 8-Channel relay board I got from Hong Kong. Cost almost as much to ship the darned thing as it was to order. Between this and the 6-channels from the Mr. Christmas box, I now have 14 channels available for my Halloween light show. I saw this morning that the 4-channel relay board I ordered from eBay arrived in a post-office point at 3am this morning, so I might have it by Wedsday, putting my up to a total of 18 channels.

11696

I can either control 12 channels via my parallel port of the computer, with the other 6 controlled by my Arduino Uno microcontroller, or vice versa. Max the arduino can control is 14, and max the parallel port can control is 12. My Mr. Christmas box will receive 6 channels of data, but I have 8 data lines going to it (I run 4 data lines per network jack, so I had 2 left over). I might be able to rig up 2 more channels so that the Mr. Christmas will take in 8 channels total, but that might be pushing things.

Now, of course, all those Vixen sequences I did for 12 channels will have to be re-done for 14, 18 or even 20 channels!

Question: Looking at the terminal blocks, where the AC feeds in, I'm not exactly sure which wire goes where... I have the black, white and ground (bare) wires... Any help? Also, these relay blocks, I'm assuming they are not solid state, but mechanical relays (could be wrong, newbie alert). Are there any issues with non-solid state relays?

Depending on your application, you could probably write some code to use a shift register to get additional "pins" from the arduino.

MacabreRob
10-10-2011, 08:14 PM
Well, specifically, the blocks are marked like:


---o \ o---


what do you think I should wire to the dots and what to the diagonal lines?

budude
10-10-2011, 08:24 PM
From the picture, it appears that there are three connectors for each terminal block per channel and that the middle connector is not used. It appears only the two outer connectors are used - this should be easy to confirm with an ohmmeter. If so, just connect your hot to one side from the source and the other is the hot to the device.

MacabreRob
10-11-2011, 12:11 PM
I just want to make sure I don't fry anything! Being paranoid, I guess...

Gorak
10-19-2011, 02:27 AM
I just want to make sure I don't fry anything! Being paranoid, I guess...

Did you get it working? Kinda want to see more pics!
I've got 4 channels with AC dimming now. We'll see how many after tomorrow night.....

MacabreRob
10-19-2011, 08:40 AM
Okay, I did figure out the wiring issue. These are mechanical relays, so they have a "nice" click whenever they open or closed, but I can deal with that. The confusion was over how to wire up the AC wires to the three posts next to the relays. The leftmost, I believe is the Normally Open (NO), middle is the switch, and the rightmost is the Normally Closed (NC). On my first attempt, I accidentally wired the hot from the plug to the NO post and had the middle wire going to the outlet. When I tested with the arduino, the effect was that the lights were on until Vixen sent the signal, then the lights went off! Doh! I move the hot to the NC plug and all is well.

I have a plastic box from GoodWill ($2) that I'm using to house the 2 boards and the 6 outlets (ie 12 channels). When it is closed, it should contain all the clicking sounds. Maybe I can add some bubblewrap to muffle it as well.

http://halloween.tittivillus.com/2011/2011_10_15_004_forum.jpg

Only thing left is to wire up the boards to an RJ45 jack, put the Arduino in its own container and wire the 2 together with Cat5.

Gorak
10-20-2011, 12:04 AM
MacabreRob thats awesome! Keep the pics coming I'm addicted to progress.

I've had a great week! I'm excited I have my board AC dimming 50 channels so far with Vixen now! I'm a little excited. Still playing/refining it though. Its a shame the Arduino DUE won't be out for this Holiday season, it would make this project a breeze... sigh next year.

Gorak
10-25-2011, 02:23 AM
Just sent out some gerber files for a custom shield. First time so I hope I didn't mess up. Next will be a custom SSR to connect to the shield. The board as 100+ pins/channels but I'm only going to use 52 (headers already installed).

chesterspot
10-25-2011, 10:06 AM
MacabreRob thats awesome! Keep the pics coming I'm addicted to progress.

I've had a great week! I'm excited I have my board AC dimming 50 channels so far with Vixen now! I'm a little excited. Still playing/refining it though. Its a shame the Arduino DUE won't be out for this Holiday season, it would make this project a breeze... sigh next year.

What was the culprit for the flickering? Do you mind posting the code?

Gorak
10-25-2011, 04:42 PM
I'm going to. I want to tweak it more and test it with using a 2-dimension array with some loops. Essentially its the same code I posted in this thread (post #74 - test 1 code) but with 60 if statements at the end instead of the 4 you see. The cause appears to be the clock speed. My Arduino is at 16MHz and the Maple is at 72MHz. The Arduino definitely struggled with the dimming. I only wish I had full wave LED strings instead of what I bought at Lowes.

TerryKing
10-26-2011, 03:06 AM
Max the arduino can control is 14, and max the parallel port can control is 12.

The Arduino MEGA has 48! Digital Outputs and 16 of them can do PWM for dimming. People are doing awesome things with LED patterns on big speakers, Halloween interactive displays etc..
DISCLAIMER: Mentioning stuff from my own shop... but you can buy Arduino lots of places like Sparkfun, Adafruit etc...

See the Mega and other Arduino choices here: http://arduino-direct.com/sunshop/index.php?l=product_list&c=1

Wiring can be difficult with so many connections. Some help here: http://arduino-info.wikispaces.com/Cables

The easiest way to connect a LOT of things to an Arduino is here: http://arduino-info.wikispaces.com/SensorShield
and the version for the Mega is here (Click on the larger image to see the connections details): http://arduino-direct.com/sunshop/index.php?l=product_detail&p=195

And if you're starting out on controlling power with Arduino or other microcomputers see: http://arduino-info.wikispaces.com/ArduinoPower

People are doing great things with Arduino here and I need to read more of the code posted!

Materdaddy
10-26-2011, 03:51 AM
The Arduino MEGA has 48! Digital Outputs and 16 of them can do PWM for dimming. People are doing awesome things with LED patterns on big speakers, Halloween interactive displays etc..
DISCLAIMER: Mentioning stuff from my own shop... but you can buy Arduino lots of places like Sparkfun, Adafruit etc...

See the Mega and other Arduino choices here: http://arduino-direct.com/sunshop/index.php?l=product_list&c=1

Wiring can be difficult with so many connections. Some help here: http://arduino-info.wikispaces.com/Cables

The easiest way to connect a LOT of things to an Arduino is here: http://arduino-info.wikispaces.com/SensorShield
and the version for the Mega is here (Click on the larger image to see the connections details): http://arduino-direct.com/sunshop/index.php?l=product_detail&p=195

And if you're starting out on controlling power with Arduino or other microcomputers see: http://arduino-info.wikispaces.com/ArduinoPower

People are doing great things with Arduino here and I need to read more of the code posted!

Wow, when did I say that? :P

Somehow you butchered the quote text! (Click the link after my name, that takes you to the post where I originally quoted MacabreRob, but it wasn't me with the max control statement.) :)

Gorak
10-26-2011, 04:48 PM
I'm going nutty waiting for the Arduino Due. It looks like it will have at least 80+ channels and the power (MHz) to AC dim all of them. Can't wait to make a shield for it when they release the board to the public!

Otherwise the Arduino is awesome for DC/LED projects. Keep getting ideas but I simply don't have the time for them which sucks. Enjoy seeing what everyone can do with it.

Gorak
10-26-2011, 09:37 PM
I posted my Maple Native Beta code HERE (http://doityourselfchristmas.com/forums/showthread.php?17582-Maple-Native-Beta-Vixen-Code-50-channels-AC-Dimming).

Since its not Arduino I made a separate thread for it.

TerryKing
10-27-2011, 01:43 AM
Oh. Sorry, MatterDaddy! I will selectively quote THIS from your sig :happy:


The perfect is the enemy of the good. -Voltaire

Materdaddy
10-27-2011, 02:29 AM
Oh. Sorry, MatterDaddy! I will selectively quote THIS from your sig :happy:

Ha! Phil Short said something inspired by this quote which I loved, so I made that my signature. It fits me to a tee. I often lose track of a goal because I think I need things perfect.

Anyways, I've been following this thread closely because I recently wrote some code for my Arduino that takes Renard Serial (not generic serial) as input, and controls a string (the whole string, not pixel level) of GECEs. I might post something soon, but I want to work out some math on my color conversions. I get 8 bits in, and only have 4 out, plus I'm attempting taking RGBW in, and only controlling RGB plus intensity. So far, simple things were working for RGB at 50ms updates..

Gorak
10-27-2011, 11:44 AM
I often lose track of a goal because I think I need things perfect.

That sounds exactly like me unfortunately. Maybe its the Steve Jobs in us lol. I hate when things could be better or if I feel like I settled. I felt that way posting the Maple code last night a little bit. I know it works perfect but I feel like the code could be be optimized better with some loops and arrays. Even though its long and repetitive I know it works and that is the important end goal, plus it allows me to move on to another phase of this light project.

Very interested to see your code for the renard plugin. That is something in the back of my mind I've always wanted to tackle. Good Luck!

theshadowwalker91
11-05-2011, 10:06 AM
hello. i am trying to get my arduino working with vixen while using tlc5940. i am using an arduino mega. after i upload the code to my board most of the leds light up right away. and as soon as it starts to receive serial data all the leds light up and dont change. any help would be greatly appreceated


IGNORE THIS I WIRED MY CHIP WRONG