Glediator , ws2812 , mega2560 , cant make it to work

pls can someone watch video i told me where i make mistake

i download glediator , skech for ws2812 from glediator site , new leds and i cant make them to work

thx

where i make mistake

Was that your video?

Have you got the LEDs working using the example ws2812 code?

The circuit looks not very robust just sticking wires into the Arduino, you should solder the wires to pins and insert the pins in the Arduino sockets.

What code have you running in the Arduino?

yes its my video

its work with code direct to arduino , neo pixel

issue is glediator ws2812 code , becose he is made for uno ,not mega 2560 i read thet ppl menage to work by changing ISR

one man wrote

  1. The interrupt vector in the code is for an Arduino Uno ISR (USART_RX_vect) . Changed to ISR (USART0_RX_vect ) for the Mega 2560
  2. Change the char variable 'go' to a boolean. Why this worked, not sure.

I change isr , but I dont understand this "Change the char variable 'go' to a boolean"

does anyone have working glediator code for mega or fix this one

Ok so you are having a problem getting some code to work.
You have to post that code or a link to it so we can see what is wrong.
The mega and the uno have different interrupt hardware so that is why you have to make the change

Read the how to use this forum sticky post to learn how to post code correctly.

first at all , thx for your effort , many will be grateful becose some ppl sucess to menage to work but there is no right code

here is link of code

http://www.solderlab.de/index.php/downloads/file/33-ws2812-glediator-interface-v1

and here is code

//##############################################################################
//##############################################################################
//                                                                             #
// Glediator to WS2812 pixel converter                                         #
// by R. Heller                                                                #
// V 1.0 - 07.01.2014                                                          #            
// wwww.SolderLab.de                                                           #
//                                                                             #
// Receives serial data in Glediator protocol format @ 1 MBit/s                #
// and distributes it to a connectect chain of WS2812 pixels                   #
//                                                                             #
// Adjust the correct DATA PIN and the correct NUMBER OF PIXELS you are using  # 
// in the definitions section below before uploading this sketch to your       #
// Arduino device.                                                             #
//                                                                             #
// Maxiumim number of supported pixeles is 512 !!!                             #
//                                                                             #
// In the Glediator software set output mode to "Glediator_Protocol",          #
// color order to "GRB" and baud rate to "1000000"                             #
//                                                                             #
//##############################################################################
//##############################################################################


//##############################################################################
//                                                                             #
// Definitions --> Make changes ONLY HERE                                      #
//                                                                             #
// To find out the correct port, ddr and pin name when you just know the       #
// Arduino's digital pin number just google for "Arduino pin mapping".         #
// In the present example digital Pin 6 is used which corresponds to "PORTD",  #
// "DDRD" and "6", respectively.                                               #
//                                                                             #
//##############################################################################

#define DATA_PORT          PORTD
#define DATA_DDR           DDRD						
#define DATA_PIN           6							
#define NUMBER_OF_PIXELS   40


//##############################################################################
//                                                                             #
// Variables                                                                   #
//                                                                             #
//##############################################################################

unsigned char display_buffer[NUMBER_OF_PIXELS * 3];
static unsigned char *ptr;
static unsigned int pos = 0;

volatile unsigned char go = 0;


//##############################################################################
//                                                                             #
// Setup                                                                       #
//                                                                             #
//##############################################################################

void setup()
{
  // Set data pin as output
  DATA_DDR |= (1 << DATA_PIN);
  
  // Initialize UART
  UCSR0A |= (1<<U2X0);                                
  UCSR0B |= (1<<RXEN0)  | (1<<TXEN0) | (1<<RXCIE0);   
  UCSR0C |= (1<<UCSZ01) | (1<<UCSZ00)             ; 
  UBRR0H = 0;
  UBRR0L = 1; //Baud Rate 1 MBit (at F_CPU = 16MHz)
  
  ptr=display_buffer;
  
  //Enable global interrupts
  sei();
}


//##############################################################################
//                                                                             #
// Main loop                                                                   #
//                                                                             #
//##############################################################################

void loop()
{  	
  if (go==1) 
  {
    cli();
    ws2812_sendarray(display_buffer, NUMBER_OF_PIXELS * 3); 
    sei();
    go=0;
  }
}


//##############################################################################
//                                                                             #
// UART-Interrupt-Prozedur (called every time one byte is compeltely received) #
//                                                                             #
//##############################################################################

ISR(USART_RX_vect) 
{
  unsigned char b;
  b=UDR0;
  
  if (b == 1)  {pos=0; ptr=display_buffer; return;}    
  if (pos == (NUMBER_OF_PIXELS*3)) {} else {*ptr=b; ptr++; pos++;}  
  if (pos == ((NUMBER_OF_PIXELS*3)-1)) {go=1;}
}


//##############################################################################
//                                                                             #
// WS2812 output routine                                                       #
// Extracted from a ligh weight WS2812 lib by Tim (cpldcpu@gmail.com)          #
// Found on wwww.microcontroller.net                                           #
// Requires F_CPU = 16MHz                                                      #
//                                                                             #
//##############################################################################

void ws2812_sendarray(uint8_t *data,uint16_t datlen)
{
  uint8_t curbyte,ctr,masklo;
  uint8_t maskhi = _BV(DATA_PIN);
  masklo =~ maskhi & DATA_PORT;
  maskhi |= DATA_PORT;

  while (datlen--) 
  {
    curbyte = *data++;

    asm volatile
    (
      "		ldi %0,8	\n\t"		// 0
      "loop%=:out %2, %3	\n\t"		// 1
      "lsl	%1		\n\t"		// 2
      "dec	%0		\n\t"		// 3
      "		rjmp .+0	\n\t"		// 5
      "		brcs .+2	\n\t"		// 6l / 7h
      "		out %2,%4	\n\t"		// 7l / -
      "		rjmp .+0	\n\t"		// 9
      "		nop		\n\t"		// 10
      "		out %2,%4	\n\t"		// 11
      "		breq end%=	\n\t"		// 12      nt. 13 taken
      "		rjmp .+0	\n\t"		// 14
      "		rjmp .+0	\n\t"		// 16
      "		rjmp .+0	\n\t"		// 18
      "		rjmp loop%=	\n\t"		// 20
      "end%=:			\n\t" 
      :	"=&d" (ctr)
      :	"r" (curbyte), "I" (_SFR_IO_ADDR(DATA_PORT)), "r" (maskhi), "r" (masklo)
    );
  }

}


//##############################################################################
//                                                                             #
// End of program                                                              #
//                                                                             #
//##############################################################################

We need also the code as you have modified it unsuccessfully, and a link to this glediator software so we know what it is sending.

I change ISR

ISR (USART_RX_vect) Changed to ISR (USART0_RX_vect )

and this is glediator
http://www.solderlab.de/index.php/downloads/file/19-glediatorv203

So did you not change the UART initialisation?

In what way was that response posting the code you changed?

Again pleas read the rules of this forum.

I am not expert , i just learning , i need help from someone who undurstend code

yes , its work , if someone have same problem I will explain to him

If you got glediator to work with mega 2560, tell me how, because i have the same problem. It works with Uno and Nano.

Post the working code?

can you tell me the solution?

Does anyone managed to make it work wit Mega?

It got the comunication to my mega working but it looks is not triggering the interrupt.

Any working code?

Hello I got it to work fine. Here is working code use pin 22

//##############################################################################
//##############################################################################
//                                                                             #
// Glediator to WS2812 pixel converter                                         #
// by R. Heller                                                                #
// V 1.0 - 07.01.2014                                                          #            
// wwww.SolderLab.de                                                           #
//                                                                             #
// Receives serial data in Glediator protocol format @ 1 MBit/s                #
// and distributes it to a connectect chain of WS2812 pixels                   #
//                                                                             #
// Adjust the correct DATA PIN and the correct NUMBER OF PIXELS you are using  # 
// in the definitions section below before uploading this sketch to your       #
// Arduino device.                                                             #
//                                                                             #
// Maxiumim number of supported pixeles is 512 !!!                             #
//                                                                             #
// In the Glediator software set output mode to "Glediator_Protocol",          #
// color order to "GRB" and baud rate to "1000000"                             #
//                                                                             #
//##############################################################################
//##############################################################################


//##############################################################################
//                                                                             #
// Definitions --> Make changes ONLY HERE                                      #
//                                                                             #
// To find out the correct port, ddr and pin name when you just know the       #
// Arduino's digital pin number just google for "Arduino pin mapping".         #
// In the present example digital Pin 6 is used which corresponds to "PORTD",  #
// "DDRD" and "6", respectively.                                               #
//                                                                             #
//##############################################################################

#define DATA_PORT          PORTA
#define DATA_DDR           DDRA
#define DATA_PIN           0 //This relates to PDA0 (PIN 22 on the Mega 2560)
#define NUMBER_OF_PIXELS   900


//##############################################################################
//                                                                             #
// Variables                                                                   #
//                                                                             #
//##############################################################################

unsigned char display_buffer[NUMBER_OF_PIXELS * 3];
static unsigned char *ptr;
static unsigned int pos = 0;

boolean go = 0;


//##############################################################################
//                                                                             #
// Setup                                                                       #
//                                                                             #
//##############################################################################

void setup()
{
  // Set data pin as output
  DATA_DDR |= (1<<DATA_PIN);

  
  // Initialize UART
  UCSR0A |= (1<<U2X0);                                
  UCSR0B |= (1<<RXEN0)  | (1<<TXEN0) | (1<<RXCIE0);   
  UCSR0C |= (1<<UCSZ01) | (1<<UCSZ00)             ; 
  UBRR0H = 0;
  UBRR0L = 1; //Baud Rate 1 MBit (at F_CPU = 16MHz)
  
  ptr=display_buffer;
  
  //Enable global interrupts
  sei();
}


//##############################################################################
//                                                                             #
// Main loop                                                                   #
//                                                                             #
//##############################################################################

void loop()
{   
  if (go==1) 
  {
    cli();
    ws2812_sendarray(display_buffer, NUMBER_OF_PIXELS * 3); 
    sei();
    go=0;
  }
}


//##############################################################################
//                                                                             #
// UART-Interrupt-Prozedur (called every time one byte is compeltely received) #
//                                                                             #
//##############################################################################

ISR(USART0_RX_vect) 
{
  unsigned char b;
  b=UDR0;
  
  if (b == 1)  {pos=0; ptr=display_buffer; return;}    
  if (pos == (NUMBER_OF_PIXELS*3)) {} else {*ptr=b; ptr++; pos++;}  
  if (pos == ((NUMBER_OF_PIXELS*3)-1)) {go=1;}
}


//##############################################################################
//                                                                             #
// WS2812 output routine                                                       #
// Extracted from a ligh weight WS2812 lib by Tim (cpldcpu@gmail.com)          #
// Found on wwww.microcontroller.net                                           #
// Requires F_CPU = 16MHz                                                      #
//                                                                             #
//##############################################################################

void ws2812_sendarray(uint8_t *data,uint16_t datlen)
{
  uint8_t curbyte,ctr,masklo;
  uint8_t maskhi = _BV(DATA_PIN);
  masklo =~ maskhi & DATA_PORT;
  maskhi |= DATA_PORT;

  while (datlen--) 
  {
    curbyte = *data++;

    asm volatile
    (
      " ldi %0,8 \n\t" // 0
      "loop%=:out %2, %3 \n\t" // 1
      "lsl %1 \n\t" // 2
      "dec %0 \n\t" // 3
      " rjmp .+0 \n\t" // 5
      " brcs .+2 \n\t" // 6l / 7h
      " out %2,%4 \n\t" // 7l / -
      " rjmp .+0 \n\t" // 9
      " nop \n\t" // 10
      " out %2,%4 \n\t" // 11
      " breq end%= \n\t" // 12      nt. 13 taken
      " rjmp .+0 \n\t" // 14
      " rjmp .+0 \n\t" // 16
      " rjmp .+0 \n\t" // 18
      " rjmp loop%= \n\t" // 20
      "end%=: \n\t" 
      : "=&d" (ctr)
      : "r" (curbyte), "I" (_SFR_IO_ADDR(DATA_PORT)), "r" (maskhi), "r" (masklo)
    );
  }

}


//##############################################################################
//                                                                             #
// End of program                                                              #
//                                                                             #
//##############################################################################

Correction its PA0 (port22) - Sorry
:o

Here is what I did:

The sketch DATA_PIN actually refers to the AVR pin not the arduino pin. PortE-H can NOT be used, so I chose PORTA. In this instance PA0 (PORT A 0) which correlates to pin 22 on the arduino 2560.

#define DATA_PORT PORTA
#define DATA_DDR DDRA

I also had to change ISR (USART_RX_vect) to ISR (USART0_RX_vect )

and volatile unsigned char go = 0; to boolean go = 0;

I successfully tested this code with 900 led's on the 2560.

That's it, enjoy!

Regards!

It doesn't work for me :confused:

I have connected the data to pin 22 on the arduino (PA0) and still not working, I can receive the data to the arduino but the leds still not working. Any idea?

I tried with the arduino one and it works perfect. So frustrating this arduino mega, did you had to cut the auto-reset line?

I have the mega R3, is the same that you have?

Cheers

Yes I used a Mega R3. I did not have to do anything. Just plugged the data line from led strip to data pin 22.

I have since given up on the mega, as its to slow. I bought a teensy LC, the teensy LC has a single 5v data pin for the purpose of driving LED strips. At $11 its lightning fast with my 900 LED's. And with the speed of the teensy the code gets very simple for Glediator. Here is my Teensy LC code. If you decide to use the Teensy LC, just change number of LED's and your done.

#include "FastLED.h"
#define NUM_LEDS 900

CRGB leds[NUM_LEDS];
void setup() {
        Serial.begin(1000000); 
     LEDS.addLeds<WS2812B,17>(leds, NUM_LEDS);
}
int serialGlediator() {
  while (!Serial.available()) {}
  return Serial.read();
}
void loop() {
   while (serialGlediator() != 1) {} 

   for (int i=0; i < NUM_LEDS; i++) {
     leds[i].r = serialGlediator();
     leds[i].g = serialGlediator();
     leds[i].b = serialGlediator();
   }
     FastSPI_LED.show();
}

This code work whit ws2812b?? and if I want to check the code I got this error code :
exit status 1
'DDRA' was not declared in this scope

is the mega 2560 slow to handle 600 leds?

The Mega is to slow for even 16 Led's I tried hemmi25 Code withe the Due and it works
The Mega can not handle even 128200 Baud. In my case it freezes and commiting than a reset

Using a Mega2560 board and running Glediator using Java and wiring data pin 22 on the Mega to a 16X16 WS2812 board I get nothing. Have tried all suggestions here. What the problem seems to be is that the COM port can't be changed in Glediator. It is greyed out and not active. Any ideas how to activate the COM ports on my 32Bit Windows PC? Please help me out...