Page 1 of 5 123 ... LastLast
Results 1 to 10 of 41

Thread: Multiple Arduinos

  1. #1
    Join Date
    Oct 2013
    Location
    Hornsea, United Kingdom
    Posts
    74
    Post Thanks / Like

    Angry Multiple Arduinos

    Hi all, i have had two Uno's and a Mega connected to vixen 3, when i run a sequence they run great but when starting another sequence only one continues working? any ideas please?

    windows 7
    vixen 3
    x2 uno
    x1 mega

    Code for Mega:-
    // 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 Chan13 = 14; // LED, connected to digital pin 14
    int Chan14 = 15; // LED, connected to digital pin 15
    int Chan15 = 16; // LED, connected to digital pin 16
    int Chan16 = 17; // LED, connected to digital pin 17
    int Chan17 = 18; // LED, connected to digital pin 18
    int Chan18 = 19; // LED, connected to digital pin 19
    int Chan19 = 20; // LED, connected to digital pin 20
    int Chan20 = 21; // LED, connected to digital pin 21
    int Chan21 = 22; // LED, connected to digital pin 22
    int Chan22 = 23; // LED, connected to digital pin 23
    int Chan23 = 24; // LED, connected to digital pin 24
    int Chan24 = 25; // LED, connected to digital pin 25
    int Chan25 = 26; // LED, connected to digital pin 26
    int Chan26 = 27; // LED, connected to digital pin 27
    int Chan27 = 28; // LED, connected to digital pin 28
    int Chan28 = 29; // LED, connected to digital pin 29
    int Chan29 = 30; // LED, connected to digital pin 30
    int Chan30 = 31; // LED, connected to digital pin 31
    int Chan31 = 32; // LED, connected to digital pin 32
    int Chan32 = 33; // LED, connected to digital pin 33
    int Chan33 = 34; // LED, connected to digital pin 34
    int Chan34 = 35; // LED, connected to digital pin 35
    int Chan35 = 36; // LED, connected to digital pin 36
    int Chan36 = 37; // LED, connected to digital pin 37
    int Chan37 = 38; // LED, connected to digital pin 38
    int Chan38 = 39; // LED, connected to digital pin 39
    int Chan39 = 40; // LED, connected to digital pin 40
    int Chan40 = 41; // LED, connected to digital pin 41
    int Chan41 = 42; // LED, connected to digital pin 42
    int Chan42 = 43; // LED, connected to digital pin 43
    int Chan43 = 44; // LED, connected to digital pin 44
    int Chan44 = 45; // LED, connected to digital pin 45
    int Chan45 = 46; // LED, connected to digital pin 46
    int Chan46 = 47; // LED, connected to digital pin 47
    int Chan47 = 48; // LED, connected to digital pin 48
    int Chan48 = 49; // LED, connected to digital pin 49
    int Chan49 = 50; // LED, connected to digital pin 50
    int Chan50 = 51; // LED, connected to digital pin 51
    int Chan51 = 52; // LED, connected to digital pin 52
    int Chan52 = 53; // LED, connected to digital pin 53


    int i = 0; // Loop counter
    int incomingByte[52]; // array to store the 52 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); // sets the pins as 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);
    pinMode(Chan26, OUTPUT);
    pinMode(Chan27, OUTPUT);
    pinMode(Chan28, OUTPUT);
    pinMode(Chan29, OUTPUT);
    pinMode(Chan30, OUTPUT);
    pinMode(Chan31, OUTPUT);
    pinMode(Chan32, OUTPUT);
    pinMode(Chan33, OUTPUT);
    pinMode(Chan34, OUTPUT);
    pinMode(Chan35, OUTPUT);
    pinMode(Chan36, OUTPUT);
    pinMode(Chan37, OUTPUT);
    pinMode(Chan38, OUTPUT);
    pinMode(Chan39, OUTPUT);
    pinMode(Chan40, OUTPUT);
    pinMode(Chan41, OUTPUT);
    pinMode(Chan42, OUTPUT);
    pinMode(Chan43, OUTPUT);
    pinMode(Chan44, OUTPUT);
    pinMode(Chan45, OUTPUT);
    pinMode(Chan46, OUTPUT);
    pinMode(Chan47, OUTPUT);
    pinMode(Chan48, OUTPUT);
    pinMode(Chan49, OUTPUT);
    pinMode(Chan50, OUTPUT);
    pinMode(Chan51, OUTPUT);
    pinMode(Chan52, OUTPUT);


    }

    void loop()
    { // 53 channels are coming in to the Arduino
    if (Serial.available() >= 52) {
    // read the oldest byte in the serial buffer:
    for (int i=0; i<53; 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
    analogWrite(Chan13, incomingByte[12]); // Write current values to LED pins
    analogWrite(Chan14, incomingByte[13]); // Write current values to LED pins
    analogWrite(Chan15, incomingByte[14]); // Write current values to LED pins
    analogWrite(Chan16, incomingByte[15]); // Write current values to LED pins
    analogWrite(Chan17, incomingByte[16]); // Write current values to LED pins
    analogWrite(Chan18, incomingByte[17]); // Write current values to LED pins
    analogWrite(Chan19, incomingByte[18]); // Write current values to LED pins
    analogWrite(Chan20, incomingByte[19]); // Write current values to LED pins
    analogWrite(Chan21, incomingByte[20]); // Write current values to LED pins
    analogWrite(Chan22, incomingByte[21]); // Write current values to LED pins
    analogWrite(Chan23, incomingByte[22]); // Write current values to LED pins
    analogWrite(Chan24, incomingByte[23]); // Write current values to LED pins
    analogWrite(Chan25, incomingByte[24]); // Write current values to LED pins
    analogWrite(Chan26, incomingByte[25]); // Write current values to LED pins
    analogWrite(Chan27, incomingByte[26]); // Write current values to LED pins
    analogWrite(Chan28, incomingByte[27]); // Write current values to LED pins
    analogWrite(Chan29, incomingByte[28]); // Write current values to LED pins
    analogWrite(Chan30, incomingByte[29]); // Write current values to LED pins
    analogWrite(Chan31, incomingByte[30]); // Write current values to LED pins
    analogWrite(Chan32, incomingByte[31]); // Write current values to LED pins
    analogWrite(Chan33, incomingByte[32]); // Write current values to LED pins
    analogWrite(Chan34, incomingByte[33]); // Write current values to LED pins
    analogWrite(Chan35, incomingByte[34]); // Write current values to LED pins
    analogWrite(Chan36, incomingByte[35]); // Write current values to LED pins
    analogWrite(Chan37, incomingByte[36]); // Write current values to LED pins
    analogWrite(Chan38, incomingByte[37]); // Write current values to LED pins
    analogWrite(Chan39, incomingByte[38]); // Write current values to LED pins
    analogWrite(Chan40, incomingByte[39]); // Write current values to LED pins
    analogWrite(Chan41, incomingByte[40]); // Write current values to LED pins
    analogWrite(Chan42, incomingByte[41]); // Write current values to LED pins
    analogWrite(Chan43, incomingByte[42]); // Write current values to LED pins
    analogWrite(Chan44, incomingByte[43]); // Write current values to LED pins
    analogWrite(Chan45, incomingByte[44]); // Write current values to LED pins
    analogWrite(Chan46, incomingByte[45]); // Write current values to LED pins
    analogWrite(Chan47, incomingByte[46]); // Write current values to LED pins
    analogWrite(Chan48, incomingByte[47]); // Write current values to LED pins
    analogWrite(Chan49, incomingByte[48]); // Write current values to LED pins
    analogWrite(Chan50, incomingByte[49]); // Write current values to LED pins
    analogWrite(Chan51, incomingByte[50]); // Write current values to LED pins
    analogWrite(Chan52, incomingByte[51]); // Write current values to LED pins

    }
    }

    Code for Uno's:-
    // 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 22
    int Chan13 = A0; // LED, connected to digital pin 23
    int Chan14 = A1; // LED, connected to digital pin 24
    int Chan15 = A2; // LED, connected to digital pin 25
    int Chan16 = A3; // LED, connected to digital pin 26
    int Chan17 = A4; // LED, connected to digital pin 27
    int Chan18 = A5; // LED, connected to digital pin 28


    int i = 0; // Loop counter
    int incomingByte[18]; // array to store the 28 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); // sets the pins as 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);

    }

    void loop()
    { // 28 channels are coming in to the Arduino
    if (Serial.available() >= 18) {
    // read the oldest byte in the serial buffer:
    for (int i=0; i<19; 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
    analogWrite(Chan13, incomingByte[12]); // Write current values to LED pins
    analogWrite(Chan14, incomingByte[13]); // Write current values to LED pins
    analogWrite(Chan15, incomingByte[14]); // Write current values to LED pins
    analogWrite(Chan16, incomingByte[15]); // Write current values to LED pins
    analogWrite(Chan17, incomingByte[16]); // Write current values to LED pins
    analogWrite(Chan18, incomingByte[17]); // Write current values to LED pins

    }
    }

    Any help please.
    P.s im no programmer so in simple term's please,
    Thankyou
    Dave.

  2. #2
    Join Date
    Nov 2009
    Location
    Morrisburg, On, Canada
    Posts
    2,540
    Post Thanks / Like

    Default Re: Multiple Arduinos

    Quote Originally Posted by halfpinter69 View Post
    Hi all, i have had two Uno's and a Mega connected to vixen 3, when i run a sequence they run great but when starting another sequence only one continues working? any ideas please?...
    Let's see;
    You have 3 USB ports on your computer, one for each Arduino.
    Each USB has their own COM port number, baudrate, etc.

    In Vixen you have 3 Generic Serial controllers setup where each COM port matches 1 Arduino's COM port.

    When you say "starting another sequence" What does that mean? Does this sequence have data for all 3 COM ports?

  3. #3
    Join Date
    Oct 2013
    Location
    Hornsea, United Kingdom
    Posts
    74
    Post Thanks / Like

    Default Re: Multiple Arduinos

    Hi lightup, yeah all have there own com port, baud rate which matches p.c. i have 8 songs (sequences) which use all three arduino's all mapped and patched ok. like i say when playing sequence with just one arduino (doesnt matter which one) they work ok, just when i plug all three in and play one sequence after another that i start losing them. im thinking it could be a coding problem or would a Header work?
    Thanks Dave

  4. #4
    Join Date
    Nov 2009
    Location
    Morrisburg, On, Canada
    Posts
    2,540
    Post Thanks / Like

    Default Re: Multiple Arduinos

    Quote Originally Posted by halfpinter69 View Post
    ... im thinking it could be a coding problem or would a Header work?
    Thanks Dave
    Nothing obvious hitting me.
    What isn't clear is if Vixen is sending data to each Arduino on the next sequence, as you indicate only 1 continues to work.
    You could use the RX light on each Arduino to indicate that each Arduino is receiving data. If so, that suggests that Vixen is pumping out a data stream. I would think the Arduino should be able to keep up with their respective data stream.
    But, then again, I would try to use a header in each Arduino sketch and program each Vixen Generic Serial to send the header. This provide synchronization for each Arduino.
    Then see what happens.

  5. #5
    Join Date
    Sep 2013
    Location
    Newhaven, East sussex, uk
    Posts
    433
    Post Thanks / Like

    Default Re: Multiple Arduinos

    Hi dave.

    I'm wondering whether a unique header for each arduino is needed.

    On my mega I send no header or footer and it works fine.
    But on my uno I use a sans qoute for both header and footer. ~! Without this I get no syncronised data stream.
    Hope this helps.
    80+ plus channels

    2 x 32 channel custom build tlc5940 dimmable DC controllers.
    1 ren 48 LSD v3c
    All rgb strips and 1 custom made face.

  6. #6
    Join Date
    Oct 2013
    Location
    Hornsea, United Kingdom
    Posts
    74
    Post Thanks / Like

    Default Re: Multiple Arduinos

    Thanks lightup for your support, when i plug all three arduinos in and play first sequence, tx lights are on all arduinos until next sequence plays then only mega on first COMM port COMM 3 works.

    Hi matt, hows things down windy sussex? thanks for your support and yeah i think i will have to have a go and add Headers to each sketch, wish me luck lol, crap at programming..

  7. #7
    Join Date
    Sep 2013
    Location
    Newhaven, East sussex, uk
    Posts
    433
    Post Thanks / Like

    Default Re: Multiple Arduinos

    In a word. WINDY. 4 extra anchors to stop my tree flying like a parachute.
    Good luck with the headers. Hope that solves the issue for you.
    80+ plus channels

    2 x 32 channel custom build tlc5940 dimmable DC controllers.
    1 ren 48 LSD v3c
    All rgb strips and 1 custom made face.

  8. #8
    Join Date
    Nov 2009
    Location
    Morrisburg, On, Canada
    Posts
    2,540
    Post Thanks / Like

    Default Re: Multiple Arduinos

    Quote Originally Posted by halfpinter69 View Post
    Thanks lightup for your support, when i plug all three arduinos in and play first sequence, tx lights are on all arduinos until next sequence plays then only mega on first COMM port COMM 3 works.

    Hi matt, hows things down windy sussex? thanks for your support and yeah i think i will have to have a go and add Headers to each sketch, wish me luck lol, crap at programming..
    Don't know why Vixen doesn't appear to send data to the other COM ports even if your sequence asks to do so. Each Arduino is still listening.
    I haven't tried your method so have no further experience with multiple Arduinos on Vixen.

  9. #9
    Join Date
    Dec 2012
    Posts
    152
    Post Thanks / Like

    Default Re: Multiple Arduinos

    Both your codes are overflowing your buffer....
    Example:
    int incomingByte[52]; // array to store the 52 values from the serial port
    for (int i=0; i<53; i++) {
    incomingByte[i] = Serial.read();

    The for loop indexes from i=0 to i = 52
    Your incomingByte array is 52 long, C arrays are indexed from 0, so valid values for incomingByte[i] are 0..51, but your for loop is
    indexing one more.

    What you get then is a buffer overflow as you're writing a memory address that belong to something else and most often you get erratic Arduino behavior.
    Fix that first, and then if that doesn't solve your issue, you could have multiple causes.

    Also there's some inconsistency between how your checking for available serial and filling that byte table. If you miss a byte as some point, things will get out of sync.

  10. #10
    Join Date
    Nov 2014
    Location
    Austin, TX
    Posts
    164
    Post Thanks / Like

    Default Re: Multiple Arduinos

    Good catch, and on top the omnipresent analogWrite ;)

Page 1 of 5 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •