LINX

cancel
Showing results for 
Search instead for 
Did you mean: 

Arduino Mega 2560 and custom commands, array size limitation?

Hi 

 

I am using LabVIEW and Linx's custom commands to send an array of 8-bit integers (LED RGB values of up to 300 individually adressable LEDs) to an Arduino Mega 2560. I can send an array 57 elements size, but any more than this causes a timeout error 5001. Is this a memory limitation?

 

Is there a way of sending more data to the Arduino?

 

Thanks

0 Kudos
Message 1 of 8
(511 Views)

The current command format for Linx messages is limited to 255 bytes. Depending how you transmit your LED values, this could very well be your limit. There is some header overhead of 10 bytes or so and with 4 bytes per LED it would appear that you have indeed reached the limit.

 

If you have digital IO in Linx, there are two forms of digital transfers, one is unpacked and uses 2 bytes per digital port (1 byte for the channel number and 1 byte for the channel value) and the packed format uses 1 1/8 byte per digital port (1 byte for the channel number and 1 bit packed into bytes per channel value.

 

Or how do you write the values?

Rolf Kalbermatter
Averna BV
0 Kudos
Message 2 of 8
(433 Views)

If you are using neopixels then you could have a custom command to write an array to your Arduino buffer at a specified offset and a command to flush the buffer to the neopixels.

0 Kudos
Message 3 of 8
(425 Views)

Thanks for the reply.

 

The custom command takes a 1D array of 8-bit integers as input. So I populate the array as R1, G1, B1, R2, G2, B2.. etc. So one LED occupies 3 bytes (I believe). The values read by the Arduino which then uses the fastLED library to write the colour data to the digital out of the board to the LED strip in a sequential manner.

0 Kudos
Message 4 of 8
(418 Views)

I'm using Ws2812B which I believe are the same as neopixels. So are you saying I could split the array up and send different chunks of the array after flushing the buffer? I was hoping to use the fastLED library to write to the LEDs to try and simplify things and I'm not sure if it is possible to write values to break up the writing process(?)

0 Kudos
Message 5 of 8
(417 Views)

You would have to use something like this as message:

 

Your custom command, offset, <some register values>

 

 

Depending if your Neopixels library supports update with offset or not! If it does just calculate the according offset from the offset in the message if it is not the same, your message offset might be in registers, the neopixels offset in bytes or vice versa or whatever.

 

If it doesn't:

 

allocate a 300 register buffer in your Arduino code

 

On offset = 0 you clear the buffer and write the first X register values,

On offset = 1 .. n you add the data with the according register offset into your memory block

when the last block is send that completes your 300 register buffer, send the whole to your neopixels or whatever library.

Rolf Kalbermatter
Averna BV
0 Kudos
Message 6 of 8
(407 Views)

Thanks for the info, I'll have to do some research into this!

0 Kudos
Message 7 of 8
(405 Views)

Hi,

LINX has a set of VI's for the WS2812. The library is implemented in the firmware for the chipKIT board.

Could you use the routines as a basis for your Arduino library?

 

The routines are in

LINX\LabVIEW\vi.lib\MakerHub\LINX\Firmware\Source\core\device\utility\LinxChipkit.cpp
LINX\LabVIEW\vi.lib\MakerHub\LINX\Firmware\Source\core\libs\WS2812


The LINX files for the the Arduino have the WS2812 function declarations where you could add support for the FastLED library.

 

e.g.

LINX\LabVIEW\vi.lib\MakerHub\LINX\Firmware\Source\libraries\LinxArduinoLeonardo\utility\LinxDevice.cpp

int LinxDevice::Ws2812Open(unsigned short numLeds, unsigned char dataChan)
int LinxDevice::Ws2812WriteOnePixel(unsigned short pixelIndex, unsigned char red, unsigned char green, unsigned char blue, unsigned char refresh)
int LinxDevice::Ws2812WriteNPixels(unsigned short startPixel, unsigned short numPixels, unsigned char* data, unsigned char refresh)
int LinxDevice::Ws2812Refresh()
int LinxDevice::Ws2812Close()

 

0 Kudos
Message 8 of 8
(381 Views)