Arduino Real-time Streaming Reliability Issue


hi,

i'm trying send 3 different signals on serial port on arduino duemillanove. goal able send 3 adc signals computer can plot them simultaneously , want able have them plotting in real-time.

i have written arduino code send 3 signals on serial port , communicate via serial input buffer having reliability issues (read after code).
code: [select]
[code]

//set of numbers communicate thru serial
int x1[5] = {1,2,3,4,5};
int x2[5] = {6,7,8,9,10};
int data = 0;
int = 0;

string inside = "inside";

// = 73
// e = 69
// r = 82
// c = 67

void setup()
{
 serial.begin(9600);
 pinmode(13,high); //to turn led on
}

void loop()
{
 
 //debugging block...
 //delay(1500);
 //serial.print(serial.read());
 //serial.flush();
 //serial.print('\n');
 
 
 //if 'i' sent serial input buffer than...
 if(serial.read() == 73)
 {
   
    serial.println(inside);
    serial.println('\n');
               
   go(); //call go function send numbers on serial continuously....
 }
 
 //if 'r' sent serial input buffer than...
 if(serial.read() == 82)
 {
   
   serial.print(data); // print 'data', variable holds count number of data points sent...
   serial.flush();     // clear buffer we've send on count...
   
 }
 
 serial.flush(); //clear buffer miscillaneous junk none of previous conditions have been met...
 
}

//this function sends sets of data via serial....
void go()
{
 digitalwrite(13,high); // turn on led indicate data being sent via serial...
 
 //unless 'e' sent serial input buffer, don't stop sending data on serial line...
 while( serial.read() != 69)
 {
   serial.flush(); // you've checked e hasn't been pressed, clear buffer heck of (neatness sort of thing)...
   
   //print first function
   //print delimeter ',' (it's coma)...
   serial.print(x1[i]);  
   serial.print(',');    
   serial.print(x2[i]);
   serial.print(',');
   serial.print(x1[i]);
   serial.print(',');
   
   serial.print('\n'); // print 3 in line arduino debugging....
   
   data++; //keep count of numbers sent on serial channel...
   i++;    // send next number in x arrays...
   if(i ==5){i = 0;} //make sure don't step out of x array...
 }
 
 serial.flush(); //clean buffer heck of it....
 digitalwrite(13,low); //shut off led light, no longer sending data...
}


[/code]

the code works follows:

1. when "i" sent on serial monitor arduino sends string "inside" , follows continously sending lines of 3 numbers (the array x1, x2)

2. arduino stop sending these numbers when press "e"

3. if send "r" after sending "e" print count of data sets sent during transmission phase. if press "r" start without pressing "i" arduino send 0 nothing has been transmitted via serial loop...


my problem when using arduino serial monitor have send "r" or "i" multiple times in order arduino enter "if" statements in void loop()... isn't reliable, if plan on using program, matlab, interfacing me....

does know why might have send string via serial 2 or more times in order arduino read ?? there wrong serial monitor application?

i appreciate help

you have:
code: [select]
 //if 'i' sent serial input buffer than...
 if(serial.read() == 73)

code: [select]
if(serial.read() == 'i')
would work well, , easier understand.

code: [select]
   serial.flush();     // clear buffer we've send on count...
any data in input buffer got deleted. there no affect on output buffer.

you really, yes, mean really, should not doing this.

code: [select]
 serial.flush(); //clear buffer miscillaneous junk none of previous conditions have been met...
see above, , stop doing this.

code: [select]
   serial.flush(); // you've checked e hasn't been pressed, clear buffer heck of (neatness sort of thing)...
neatness, ass. have no idea how data dumped, or if relevant or not.

code: [select]
 serial.flush(); //clean buffer heck of it....
no. heck of it, stop doing this.

quote
my problem when using arduino serial monitor have send "r" or "i" multiple times in order arduino enter "if" statements in void loop().

you don't suppose flushing of incoming data has this, you?

quote
does know why might have send string via serial 2 or more times in order arduino read ?

i think so.

quote
is there wrong serial monitor application?

not thing. code, on other hand...


Arduino Forum > Forum 2005-2010 (read only) > Software > Interfacing > Arduino Real-time Streaming Reliability Issue


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums