LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

receive data to array using serial communication

Hi , i did a search in the community and i cant find what im looking for.

Im using arduino to sample 10s of a signal , with resolution of 8bit and samplin rate of 5.25Khz , i stored the samples into byte array size 52500 . I need to send this array using serial communication , store it , as array , and plot it on a graph , the plot will be after the array is received in labvew , i dont need a real time plotting . only an array and the plot of it . any ideas ? VI examples ?

 

0 Kudos
Message 1 of 15
(4,815 Views)

i've just download it . but i prefer the standard way.

0 Kudos
Message 3 of 15
(4,787 Views)
What's the 'standard' way? Each sketch is custom though the serial interface does not change much. How are you sending the byte array?
0 Kudos
Message 4 of 15
(4,784 Views)

Here is why i made in Labview : 

Capture.JPG

 

and i write a simple code just to check , here is the code :

void setup() {
// put your setup code here, to run once:
Serial1.begin(9600);
Serial.begin(9600);
}
byte arr[] = {1,2,3,4,5,6,7,8,9,10};
int F_Start = 0 ;
int i = 0 ;
void loop() {
// put your main code here, to run repeatedly:
if (F_Start == 0 ) {
analogReadResolution(8);
for ( i=0 ; i<10 ; i++) {
//arr[i] = analogRead(A0) ;
Serial.println(arr[i]);
Serial1.println(arr[i]);
if ( i == 9 ){
F_Start = 1 ;
}
}
}

}

 

the final code will have a byte array of size about 55000.

i don't know what im doing wrong.

 

Download All
0 Kudos
Message 5 of 15
(4,771 Views)
The way you have it configured, you will only read one byte at a time. The configured function, which should be outside the loop, had the termination character enabled. You are spending a termination character after each byte. A read automatic terminates when a termination character is detected, no matter what you specify for the byte count. You could read a single byte and just wire that to a chart or disable the term character with the VISA Configure. You do not want a term character when you are sending U8 data.

When you read multiple bytes, just use the string to byte array function instead of that shift register.
0 Kudos
Message 6 of 15
(4,763 Views)

I'm really new to labview and i hardly understand what you meant for , can you please modify it , the way you think it should work ?

0 Kudos
Message 7 of 15
(4,759 Views)
Sorry, I'm posting from my phone. You need to take some of the free tutorials. The enable termination character is one of the inputs to VISA Configure Serial Port. Just wire a false constant to it.
0 Kudos
Message 8 of 15
(4,744 Views)

i've change the VI , it seems that it receive the data , and shows the chart real time.

what i need is to save it to array and when i push stop on the while loop , it shows me the plot of the received array.

few hours im trying to solve it and without success.

hope you can help me . Smiley Wink

Capture.JPG

0 Kudos
Message 9 of 15
(4,725 Views)
You did not use the String to Byte Array function like I said. Use quick drop or the search button to find it. The chart should update as you run. You don't need to save it as an array though you have to make sure your history length is set long enough. The default is only 1024 points.
0 Kudos
Message 10 of 15
(4,706 Views)