Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: Vixen and Arduino Mega + inexperience

  1. #1
    Join Date
    Dec 2021
    Location
    ITALY
    Posts
    17
    Post Thanks / Like

    Default Vixen and Arduino Mega + inexperience

    as required by RichieNorthcott public pc coAttachment 46787m setting and Vixen settingAttachment 46787
    I connected individual LEDs to be exact 9 red LEDs starting from channel 3

    #define CH01 2 #define CH02 3 #define CH03 4 #define CH04 5 #define CH05 6 #define CH06 7 #define CH07 8 #define CH08 9 #define CH09 10 #define CH10 11 #define CH11 12
    #define CH12 13 #define CH13 A0 #define CH14 A1 #define CH15 A2 #define CH16 A3 #define CH17 A4 #define CH18 A5
    // Up to here for Arduino uno.
    #define CH19 A6 #define CH20 A7 #define CH21 A8 #define CH22 A9 #define CH23 A10 #define CH24 A11 #define CH25 A12 #define CH26 A13 #define CH27 A14 #define CH28 A15
    #define CH29 22 #define CH30 23 #define CH31 24 #define CH32 25 #define CH33 26 #define CH34 27 #define CH35 28 #define CH36 29 #define CH37 30 #define CH38 31 #define CH39 32
    #define CH40 33 #define CH41 34 #define CH42 35 #define CH43 36 #define CH44 37 #define CH45 38 #define CH46 39 #define CH47 40 #define CH48 41

    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; // new line

    //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 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(){
    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) {
    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);
    }
    }
    }
    }
    }
    }
    // Random mode code. Random mode starts if no serial input has been received in TIME_OUT millisenconds
    else {
    wdt_reset(); // resets the watchdog
    unsigned long diff = millis() - timer_a;
    if (diff >= TIME_OUT) {
    timer_a = millis ();
    int random_a = 0;
    for (i = 0; i < CHANNEL_COUNT; i++) {
    random_a = random(0, 2);
    if (random_a == 0) {
    digitalWrite(channels[i], LOW);
    }
    else {
    digitalWrite(channels[i], HIGH);
    }
    }
    }
    }
    }


    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);
    }
    }
    }
    I copied the program from the previous post. I connected individual LEDs to be exact 9 red LEDs starting from channel 3
    The sketch includes a 'header' of -!, tonight I will do a test I had not headed it.
    Attached Images Attached Images

  2. #2
    Join Date
    Dec 2021
    Location
    ITALY
    Posts
    17
    Post Thanks / Like

    Default Re: Vixen and Arduino Mega + inexperience

    After unhinged attempts by adding ~! It started working. Thank you for your help and I will try to learn more and more to improve this beautiful passion Thank you Gabry59

  3. #3
    Join Date
    Oct 2014
    Location
    Sauk City, WI USA
    Posts
    2,631
    Post Thanks / Like

    Default Re: Vixen and Arduino Mega + inexperience

    Make sure you attached the LED to the correct pin. CH03 is pin 4 according to your #define

    But your sketch is using CH01, CH02, etc. This array setup is what "channels" you will be using.

    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
    };

    These #define statements logically connect the CHxx to a physical pin.
    #define CH01 2
    #define CH02 3
    #define CH03 4
    CH01 is channel 1 because of the array above and uses pin 2 because of the #define.

    If you started with CH03 (pin 4), you will need to adjust your array definition to match. Take CH01 and CH02 and move them to the back of list. The first element of the "channels" array should be the first LED you attached (CH03 also known as pin 4).

  4. #4
    Join Date
    Jul 2019
    Location
    United Kingdom
    Posts
    270
    Post Thanks / Like

    Default Re: Vixen and Arduino Mega + inexperience

    Sorry I had this wrong, good to hear you have it working. And thanks for the screen grabs, looks like everything is good. Yes this:

    Code:
    if (uno == 126) {
    int dos = Serial.read();
    if (dos == 33) {
    is looking for byte values 126 and 33 consecutively as the header. The header is used to 'frame' the data so the sketch knows where the channel values start (as the data 'loops' continuously). Indeed this is '~!' not '-!' as I wrote. This goes in the 'header' config box in Vixen.
    Last edited by RichieNorthcott; 02-16-2023 at 07:19 AM.

  5. #5
    Join Date
    Dec 2021
    Location
    ITALY
    Posts
    17
    Post Thanks / Like

    Default Re: Vixen and Arduino Mega + inexperience

    Hi, sorry for the delay in replying, the system has seen ~! And I managed to turn on the LED with music. Now for RGB strings I have no problems but problems begin with WS2811 strings. I have been following you for a long time and my dream would be to be able to make a 'mega tree' with at least 16 strings of 50 WS2811 LEDs for a total of at least 2400 pixels. all if it is possible with Arduino Mega. if arduino could not drive these 16 strings I was considering the purchase of a 'Flcon F16 v4' or similar. Thanks for the help Gabry59

  6. #6
    Join Date
    Oct 2014
    Location
    Sauk City, WI USA
    Posts
    2,631
    Post Thanks / Like

    Default Re: Vixen and Arduino Mega + inexperience

    A single Mega does not have enough CPU and serial bandwidth to read input and output 2400 pixels. But your math is confused. 2400 channels but only 800 pixels. You could try it but I don't think you will like the results. At 20 FPS, you would need to use about 512K port speed and you'd have to unload the MEGA receive buffer at a high rate of speed and then find time to push the data to FastLED or whatever you are using. Try it though...and report your success.

    An ESP device could do it using multiple outputs. You can get the ESP with a SDCard option that reduces networking to be negligible impact. Then you have plenty of CPU to read the sdcard and output data. As I don't remember the latest specs, I believe Martin has the ESPixelStick firmware doing 6 or 8 outputs and you would need only 2-3. A ESP32 WROOM with an SDCard with a 4 channel level shifter and you have a nice setup for doing a mega tree.

  7. #7
    Join Date
    Jul 2019
    Location
    United Kingdom
    Posts
    270
    Post Thanks / Like

    Default Re: Vixen and Arduino Mega + inexperience

    Agree serial data/Arduino isn't the way to go for pixels. While the Mega gives you lots of outputs pins and memory (and sounds impressive!), it doesn't have any speed benefits over a regular nano/uno/micro. It's relatively old technology now.

    If you have big plans for a large display you may be best off investing in a commercial controller TBH. You will be wanting to look at one of the other controller types in Vixen (or Xlights) like streaming ACN, not generic serial.

    My own display uses multiple Arduino Nanos with wired ethernet shields, each controls 680 pixels in 4 strings of 170. So my tree (and whole display) is designed around that. The sketch takes a different approach than the FastLED library - it reads the incoming bytes and manipulates into a timed output in line with the WS2811 specification.

    The ESP microcontroller range is another route to go, there's lots of information on here about that.
    Last edited by RichieNorthcott; 02-24-2023 at 06:29 AM.

  8. #8
    Join Date
    Dec 2021
    Location
    ITALY
    Posts
    17
    Post Thanks / Like

    Default Re: Vixen and Arduino Mega + inexperience

    Hi, If I understand correctly the problem lies in the cycle time of the processor that is not enough to perform all operations. G59

  9. #9
    Join Date
    May 2007
    Posts
    6,024
    Post Thanks / Like

    Default Re: Vixen and Arduino Mega + inexperience

    Quote Originally Posted by Gabry59 View Post
    Hi, If I understand correctly the problem lies in the cycle time of the processor that is not enough to perform all operations. G59
    More or less. While I think that the Arduino could handle 2400 pixels (split into four 600-pixel output streams) with carefully crafted assembly-language code, it would be a pointless exercise in masochism.

    The ESP-based solutions that other people have suggested would be a far better solution, particularly because it would be easier to find help on this site when you need it.
    Phil

  10. #10
    Join Date
    Dec 2021
    Location
    ITALY
    Posts
    17
    Post Thanks / Like

    Default Re: Vixen and Arduino Mega + inexperience

    Thank you for the explanations now I buy a pair of ESP32 Wroom and start experimenting. However, a raspberry pi of the latest generation should be able to process many pixels. What do you think?? G59

Page 1 of 3 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
  •