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?
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?
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.
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.
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(?)
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.
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
The LINX files for the the Arduino have the WS2812 function declarations where you could add support for the FastLED library.
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)
I resolved this by using a buffer on the arduino and repeated calls of the custom command VI to populate the buffer and then turn the lights on.
Hello, can you plese share your VI ,how did you solve it ? i need to control led strip 2812 300LEDs GRB i'm stuck at sending values from Labview to Arduino neopixel library through Serial port .