Pages: [1] 2   Go Down
Author Topic: need to move 1 unsigned long serially really quick  (Read 1124 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need to move 1 unsigned long integer over the serial port from one arduino to another , over and over, without stopping, as fast as I can. Basically I will encode the bits of the integer in one arduino and then send that unsigned long integer to another arduino to decode them. I will do this over the serial port at 9600 baud. This is to control christmas lights next year so it has to happen really fast to keep the lights up with the music. I am currently doing this with a string of 6 integers, comma delimited and ending the string with a ;   It works but I have to put a 300 ms delay on the transmitter or the decoding fails on the other end. And the data rate is to slow. I have read all of the libriaries and find the definitions for the serial stuff very confusing. I can get the serial print statement to work nicely at all speeds even with the delay between print statements eliminated. But getting the receiver to decode it without the delay of at least 300 ms between transmissions falls flat on its face. I came up with the idea of just using the single 32 bit unsigned integer instead of the 6, 16 bit integers withe the comma delimiter because I thought that should be more simple to speed up. But I am unsure how to proceed.
Logged

Offline Offline
Edison Member
*
Karma: 33
Posts: 1432
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you sending ASCII or binary?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49040
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I will do this over the serial port at 9600 baud. This is to control christmas lights next year so it has to happen really fast to keep the lights up with the music.
Really fast and 9600 baud rate do not belong together.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17292
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

300 millisec delay required! I suspect you are doing something wrong in the receiver sketch such as using delay commands or other blocking commands that is causing your serial receiver buffer to lose characters. Post your code if you really want help.

Lefty
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 619
Posts: 33961
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
from one arduino to another , over and over, without stopping, as fast as I can.
Is there any point in this as there is no time to do anything with the number if you do.

Quote
This is to control christmas lights next year so it has to happen really fast to keep the lights up with the music.
Ah I see your idea of fast is not the same as mine. Music changes quite slowly compared to the speed that a controller will work at.

Quote
It works but I have to put a 300 ms delay on the transmitter or the decoding fails on the other end.
That suggests you are writing the code incorrectly.

Quote
And the data rate is to slow
Well 9600Baud is quite slow, try changing it to 115200 baud that is a lot faster.

Quote
But getting the receiver to decode it without the delay of at least 300 ms between transmissions falls flat on its face.
Again you are writing the code incorrectly. You are probably using the delay function somewhere.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 216
Posts: 13664
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Really fast and 9600 baud rate do not belong together.
For snails they do smiley-wink

Quote
try changing it to 115200 baud that is a lot faster.
between 2 Arduino's you can even use higher like 230400 or 345600 baud over hardware serial.

Can you post your code?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12631
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need to move 1 unsigned long integer over the serial port from one arduino to another , over and over, without stopping, as fast as I can.

That sounds like the solution to some problem, and not a very smart solution at that. You're trying to turn lots of LEDs on and off individually? How many - and what sort of latency do you want to achieve? Where are the LED commands coming from?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17292
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I will do this over the serial port at 9600 baud. This is to control christmas lights next year so it has to happen really fast to keep the lights up with the music.
Really fast and 9600 baud rate do not belong together.

You insensitive clod, my first communications link was at 300 baud using an acoustically coupled modem. 9600 baud will always seem fast to me. smiley-grin

Lefty
« Last Edit: January 07, 2013, 02:24:35 pm by retrolefty » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 216
Posts: 13664
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


@ 9600 baud continuous mode one can send about 2000 longs (binary = 4 bytes) of 32 bits enough to switch on/off 64000 leds Or 64 leds 1000 times.
in text mode one need max 11 bytes to send one long(+ separator) so that makes 32000 leds.

phrased more seriously:
How many LEDS's are there?
How often do the need to be refreshed?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49040
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You insensitive clod
Yep, that's me.  smiley-cool
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 216
Posts: 13664
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I always thought PaulS was an anagram of "A plus" because of the many quality contributions smiley-wink

The "you ...clod" has many many anagrams - http://www.wordsmith.org/anagram/advanced.html -

(and yes robtillaart == Ill Abort Rat)
OK time to move to bar sport ...
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

9600 baud is a necessity. I will be sending from one Arduino as the transmitter to multiple Arduinos as recievers. And this will be done using 900 Mhz RS232 wireless serial radios. They top out at 9600 baud. Without the delay in the transmitter program and using the serial monitor on the software to see what the transmitter is putting out with the present 6 integer, comma delimited stream, the speed ismore than quick enough. But the receiver cannot read it and stuff it back into 6 sets of integers.  Right now for testing I am just connecting the Tx out of the transmitting Arduino to the Rx of the reicever on my workbench. I will put the radios in later but they are not part of the equation now. I will be using the 32 bits of the single long integer in various ways. 5 groups of 4 bits will be scaled from a binary 0-15 to a integer of 0 - 255 to drive 5 PWM outputs. 7 bits will directly control 7  outputs of the Arduino directly. Either on or off.  One of the bits will be a system on - off bit. When off all of the outputs and the PWM values will be set to 0 . The rest of the 32 bits are spares for now.


 
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49040
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
And this will be done using 900 Mhz RS232 wireless serial radios. They top out at 9600 baud.
You've got 11 months to get better radios.

Quote
But the receiver cannot read it and stuff it back into 6 sets of integers.
At 9600 baud, it has an eternity to parse and convert the data.

We need to see some code to see why you are having problems.
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use the hardware spi or uart, plus interrupts: configure the modules to trigger an isr when the data register is empty (or the transmission is done). In the isr, load up the next byte, until all four bytes / string have been done.

The speed will be blindingly fast, and it is a send-and-forget type.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12631
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use the hardware spi or uart, plus interrupts: configure the modules to trigger an isr when the data register is empty (or the transmission is done). In the isr, load up the next byte, until all four bytes / string have been done.


In other words, call Serial.write()?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: [1] 2   Go Up
Jump to: