Back for another tr...
 
Notifications
Clear all

Back for another try..

99 Posts
11 Users
0 Reactions
25.8 K Views
(@lightup)
Posts: 2541
Famed Member
 

OK, I took a look at it. It isn't simply swapping Random routines as you have other variables and void loop() changes to accommodate.
I did get it to compile but I'm missing something as my test stays in random mode. Probably broke the Vixen reading stuff in my 1st attempt.
Will need a closer look...


 
Posted : 01/12/2015 12:55 pm
(@lightup)
Posts: 2541
Famed Member
 

My closer look.
Is this what you were looking for?
Not sure I got your switch idea correct.


// cHANGED TO CHANNEL 22 - 53 FOR OUTPUT PINS AND ADPTED TO 32 CHANNELS OUT
 // This code was written by Victor Perez for doityourselfchristmas.com based on the code from Zparticle, Si_champion and Neil Tapp.
 // To adapt the code to your case, just change this top section, with the #define lines. 
 // Vixen needs to be setup to use a header of: ~! there is no footer in this sketch
 // -Sets all the channels to off in startup.
 // -Wait for up to 2 seconds (can be changed for longer) and if there is no valid input, it goes into random mode, blinking some lights on and off every second.
 // -If it detects valid input (with ~! header), it writes to the relays, as long as Vixen is working.
 // -If Vixen goes off for more than 2 seconds, back to random mode.
 
 // Modified RANDOM feature from original -  LightUp Dec 1, 2015.

 // Includes the watchdog timer library
 #include <avr/wdt.h>

 // This sets how many channels will vixen be sending. Can be set to any number from 1 to 48 for Arduino Mega, and 1 to 18 for Arduino Uno.
 #define CHANNEL_COUNT 32
 
  // Define the pin that will trigger "random mode".
 #define RANDOM_MODE_PIN A0
 #define RANDOM_MODE_SPEED 1000

 // speed for the com port for talking with vixen. From 9600 to 115200. Use the same speed as set in Vixen.
 #define VIXEN_COM_SPEED 57600
 // Timeout waiting for serial input before going to random mode (in milliseconds).
 #define TIME_OUT 1000

 // If the relays turn On and Off opposite to Vixen sequence, change "#define MODE NOT_INVERTED" for "#define MODE INVERTED"
 #define NOT_INVERTED 0
 #define INVERTED 1
 #define MODE NOT_INVERTED
 //#define MODE INVERTED

 // which pins control which channels
 // You can change these assignment to use different pins, but be very careful to not repeat the same pin number for 2 channels. 
 // DO NOT use pings 0 and 1, as those are for the serial port to talk to the computer.
 #define CH01 22
 #define CH02 23
 #define CH03 24
 #define CH04 25
 #define CH05 26
 #define CH06 27
 #define CH07 28
 #define CH08 29
 #define CH09 30
 #define CH10 31
 #define CH11 32
 #define CH12 33
 #define CH13 34
 #define CH14 35
 #define CH15 36
 #define CH16 37
 #define CH17 38
 #define CH18 39
 // Up to here for Arduino uno.
 #define CH19 40
 #define CH20 41
 #define CH21 42
 #define CH22 43
 #define CH23 44
 #define CH24 45
 #define CH25 46
 #define CH26 47
 #define CH27 48
 #define CH28 49
 #define CH29 50
 #define CH30 51
 #define CH31 52
 #define CH32 53
 // #define CH33 A1
 // #define CH34 A2
 // #define CH35 A3
 // #define CH36 A4
 // #define CH37 A5
 // #define CH38 A6
 // #define CH39 A7
 // #define CH40 A8
 // #define CH41 A9
 // #define CH42 A10
 // #define CH43 A11
 // #define CH44 A12
 // #define CH45 A13
 // #define CH46 A14
 // #define CH47 A15
 // #define CH48 13

 int channels[] = {CH01,CH02,CH03,CH04,CH05 ,CH06,CH07,CH08,CH09,CH10,CH11,CH12,CH13,CH14,CH15 ,CH16,CH17,CH18,CH19,CH20,CH21,CH22,CH23,CH24,CH25 ,CH26,CH27,CH28,CH29,CH30,CH31,CH32};
 //,CH33,CH34,CH35,
 // CH36,CH37,CH38,CH39,CH40,CH41,CH42,CH43,CH44,CH45, CH46,CH47,CH48};

 int incomingByte[CHANNEL_COUNT];

 int i = 0; // Loop counter
 //volatile unsigned long timer_a = 0;
 
 boolean startingVixen = true;

 //setup the pins/ inputs & outputs
 void setup(){

 // enable the watchdog timer with a time of 1 second. If the board freezes, it will reset itself after 1 second.
 wdt_enable(WDTO_1S);

 // specifically for the UNO
 // sei(); 

 // initalize PWM Channels / Pins
 for (i=0; i < CHANNEL_COUNT; i++){
 pinMode(channels[i], OUTPUT);
 }
 
// Set up the pin for random mode as input.
 pinMode(RANDOM_MODE_PIN, INPUT);

 // set all the realys to off to start with
 if (MODE == NOT_INVERTED) {
 for (i=0; i < CHANNEL_COUNT; i++){
 digitalWrite(channels[i], LOW);
 }
 }
 else {
 for (i=0; i < CHANNEL_COUNT; i++){
 digitalWrite(channels[i], HIGH);
 }
 }

 testSequence();

 // set up Serial according to the speed defined above.
 Serial.begin(VIXEN_COM_SPEED);
 }

 void loop()
 {
 wdt_reset(); // resets the watchdog
 if(digitalRead(RANDOM_MODE_PIN) == HIGH)
 {
 startingVixen = true;
  // Pin is LOW, turn lights on/off randomly.
  doRandomLights();
 }
 else
 { // Pin is HIGH, read data from Vixen.
 if(startingVixen == true)
 {
 readFromVixen();
 } 
 }
 }
 
 //Read Vixen data
 void readFromVixen()
 {
 if (Serial.available() >= (CHANNEL_COUNT+2)) {
 wdt_reset(); // resets the watchdog
 //timer_a = millis (); // new line
 int uno = Serial.read();
 if (uno == 126){
    int dos = Serial.read();
    if (dos == 33){
      //Detected header, now read channel data.
      for (i=0; i < CHANNEL_COUNT; i++) {
         // read each byte
         incomingByte[i] = Serial.read();
      }
 if (MODE == NOT_INVERTED) {
 for (i=0; i < CHANNEL_COUNT; i++){
 int value = incomingByte[i];
 if (value <= 127) {
 digitalWrite(channels[i], LOW);
 }
 else {
 digitalWrite(channels[i], HIGH);
 }
 }
 }
 else {
 for (i=0; i < CHANNEL_COUNT; i++){
 int value = incomingByte[i];
 if (value < 127) {
 digitalWrite(channels[i], HIGH);
 }
 else {
 digitalWrite(channels[i], LOW);
 }
 }
 }
 }
 }
 } 
 }// end of read from vixen
 
 // Do random light sequence.
 void doRandomLights()
 {// Read value to pin A1 and generates a random sequence from it.
 randomSeed(analogRead(A1));

 for(int i = 0; i < CHANNEL_COUNT; i++)
 {
 int randNumber = random(0, 255);
 randNumber = map(randNumber, 0, 255, 255, 0);
 if(randNumber <= 127)
 {
 analogWrite(channels[i], 255);
 }
 else
 {
 analogWrite(channels[i], 0);
 }
 } 
 delay(random(1000, RANDOM_MODE_SPEED));
 }

 void testSequence(){
 if (MODE == NOT_INVERTED) {
 for (i=0; i < CHANNEL_COUNT; i++){
 wdt_reset(); // resets the watchdog
 digitalWrite(channels[i], HIGH);
 delay (500);
 digitalWrite(channels[i], LOW);
 }
 }
 else {
 for (i=0; i < CHANNEL_COUNT; i++){
 wdt_reset(); // resets the watchdog
 digitalWrite(channels[i], LOW);
 delay (500);
 digitalWrite(channels[i], HIGH);
 }
 }
 }

 
Posted : 01/12/2015 5:28 pm
(@bryanvandyke)
Posts: 44
Eminent Member
Topic starter
 

Thanks to light up,Dj, victor Perez and all others to help me along with this project. The timing is a little off but some tweaks and I'll have it all good.

Sent from my iPad using Tapatalk


 
Posted : 05/12/2015 8:49 pm
(@bryanvandyke)
Posts: 44
Eminent Member
Topic starter
 

Here is a short video in thanks

Sent from my iPad using Tapatalk


 
Posted : 05/12/2015 8:51 pm
(@lightup)
Posts: 2541
Famed Member
 

Good to hear something is working for you.


 
Posted : 05/12/2015 8:58 pm
(@dj-franqstar)
Posts: 527
Honorable Member
 

Nice...ive got a new setup now so hopefully this setup will work out better

Sent from my SM-G920V using Tapatalk


 
Posted : 05/12/2015 9:34 pm
(@skunberg)
Posts: 4092
Famed Member
 

Looks great! Congratulations, you've come a long way. You have learned more than most starting out here. But that's why it's DIYC! Thank you for sharing your results.


2009 - 48 channel MegaTree 4800 lights
plus 3200 lights static display.
2010 - 6 Snowflakes on heavy equipment stored in front yard 🙁
2011 - 72 channel Megatree 7520 lights,
120 channel total about 10k lights total

 
Posted : 05/12/2015 9:40 pm
(@bryanvandyke)
Posts: 44
Eminent Member
Topic starter
 

I am documenting the wiring of my 32 Sr. Relays and how I got them up and running with the mega board. I have to admit that I have not tried the revised code yet and will do soon. I however have the bug and will be looking for some renards soon and want to have them up and going before next season. My son says I have gone a little griswald . How funny I want to increase at least 100 channels by next season with the ssr's increased to 48 channels. At least I got a lot of property to eventually cover.
I used cat5 cables to run from the mega board in my office to 2 satellite boxes that house a 16 board ssr and applicable plug ins for the 16 channels. Worked well after I realized that when I made my boxes I used gfi plugs inside for the power supplies to the ssr board. This when plugged into another gfi plug creates an issue with the two gfi plugs an will cause the loaded gfi to trip. Once figured this out and removed the box gfi and used the gfi on the house everything went well and no breakers tripped.
All in all it was a success and all your help made it so. As well as looking relentlessly through forums for similar issues that had eventually came to an applicable answer.
So renards? Let me know if there are any premises available from someone upgrading? Or,I'll see about purchasing my boards from the supplier on here and start my new map and outlook for next year. Gonna be exciting
Thanks again,
Bryan

Sent from my iPad using Tapatalk


 
Posted : 30/12/2015 1:13 am
(@mufflerfist)
Posts: 11
Active Member
 
Triggerjay wrote:I will be selling most of my renard stuff after this years display. I have 11 24ch renard controllers.

I would love to buy 2 of you 24ch renard Triggerjay


 
Posted : 01/01/2016 11:08 am
Page 7 / 7
Share: