We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpElectronics,  Serial Library › faster way than serial to talk to arduino
Page Index Toggle Pages: 1
faster way than serial to talk to arduino (Read 3083 times)
faster way than serial to talk to arduino
Jul 24th, 2009, 5:09pm
 
I have a processing app that is communicating with an array of rgb lights that are controlled by an arduino.

Sending serial messages to change individual leds is fast enough to do realtime manipulation but once I get to the point that I am sending realtime updates for the entire led matrix (it is only 5x5 = 25 leds, and 1 byte for each color) the serial communication becomes a huge bottleneck for realtime display.

I can try a higher baudrate but I would like to keep it low so that I can do this wirelessly with an xbee (error rate increases with baud rate).

Should I try doing this over ethernet instead?
Re: faster way than serial to talk to arduino
Reply #1 - Aug 4th, 2009, 6:54am
 
I wouldn't worry about speed.  Just up that baud rate. You have a lot of head room!

If you're thinking of going wireless, then the bottleneck will become the XBee radios, not the serial port.  The radios technically support up speeds up to 250kbs, but I think you can only set the baud rate up to 115200 for serial transmission.  I've used them at 38400 quite a bit without any problems.  

Also keep in mind that the UART's error rate doesn't necessarily increase with baudrate -- its a factor of the baud rate and your clock source (check the ATMega168's datasheet)  Certain combinations of clocks and baud rates will yield higher error rates than others.

d.

Re: faster way than serial to talk to arduino
Reply #2 - Aug 17th, 2009, 9:43pm
 
I maxed the baud rate but it is still way too slow.

For each pixel I am sending 3 x 8 bit color values. So for a 35rgb led I would have to send 35x3 = 105 bytes.

Someone suggested I should reduce the bit depth to 16 values per color (4bit).
If I did that then I could reduce it to 3 bytes for every 2 rgb leds for a total of 52 bytes per frame.

However by my calculations even at 105 bytes (840bits) @115200 baud rate I should be able to push out 137 frames per second.
This means to me there is some other bottle neck slowing this down.

Is there some issue with Serial library I should now about? Like disabling some other aspect of Processing in order to optimize serial output?
Re: faster way than serial to talk to arduino
Reply #3 - Aug 23rd, 2009, 10:10pm
 
did you try to increase the frames per second?, i think that you could have any baud rate you want but the processing will send at the draw() velocity(the fps rate).
Re: faster way than serial to talk to arduino
Reply #4 - Sep 9th, 2009, 9:54am
 
Try using an indexed color system. You create a table of color values on the receiving end hardware to interpret incoming bytes as color(255,255,255)

For example:
Transmitting the byte 0xFA over wireless serial can be re-interpreted as rgb(129,234,200) on the receiving hardware. 1 Byte will give you 256 possible colors.

1 byte per LED
5x5 = 25 Bytes per frame

You can cut that in half for even more fun.

1 byte for every 2 LEDs
5x5 = 13 Bytes per frame

0xFF = 11111111  (first LED gets 1111)
                          (second LED gets 1111)

receiving hardware interprets the first half of 0xFF(1111) as 16 and maps it to an 16 value color table of rgb(255,255,255)

I tried using Serial to transfer data from PC to arduino and found it painfully slow.  I would use an I2C or SPI protocol because I think they are much faster than serial, but I do not know how you would get those protocols wireless enabled.
Page Index Toggle Pages: 1