Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

buffering recieve data from serial port

hi
i wrote a code for ARM lpc1768 (ADC) then tansfer data by serial port(9600 baud rate) then i recieve data correctly in labview
but there is an issue that when i wanna plot it labview because of the sampling frequency labview cant detect most of data and just detect the peak of the sin wave input
in matlab i can plot data correctly because matlab buffering data
can someone help me how should i do this in labview?
i attach my design and result
thanks

Download All
0 Kudos
Message 1 of 16
(5,562 Views)

1. No need for the outside loop.

2. You should not open and close the serial port constantly.  Just open it once (which is done with the Configure Serial Port) before your loop and close it once after the loop.

3. Since you are dealing with binary (raw) data, you will want to make sure the termination character is turned off.

4. That FOR loop is useless.  You can just wire the byte array straight to the chart.

5. Does the ARM constantly output the data once commanded or does it only output so many bytes after the command?  If it is a continuous output, how does it know when to stop?  You also would only need to send the request for data once.  If it is on X bytes after the command, then use a constant to tell the VISA Read to read that number of bytes.

 

The following snippet is assuming you only send X bytes per read request.

ADC_BD.png


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 16
(5,549 Views)

i omit the outside loop and for loop but it doesnt work!
since im new to labview would you exatcly tell me what to do?
i should deliver this project in a few days and still dont know how to solve this.
when i use datasocket for buffering data all of data detect correctly but there is problem that when it collect the highest value (255) then inestead of collecting next data (254) it start from the begining(0).
data transfer speed is so high(like 1KHz) that can make problem?

0 Kudos
Message 3 of 16
(5,544 Views)

@benyamin wrote:

since im new to labview would you exatcly tell me what to do?


My snippet wasn't clear enough?

 


@benyamin wrote:

data transfer speed is so high(like 1KHz) that can make problem?


At 9600 baud rate, you are bascially getting a byte every 1ms.  That is an eternity to a computer.  That is not your problem.

 

Perhaps you should share your ARM code so that we can understand the actual protocol you are using.  We can give a lot better advice with that information.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 16
(5,537 Views)

i cant figure it out what that (byte per second) function is !
i attach my code so you can realize the whole operation.
thank you very much

Download All
0 Kudos
Message 5 of 16
(5,535 Views)

Ok, so your ARM is just constantly sending data.  No command is needed to start it up.  This should be all you need to do.

ADC_BD.png

 

And since you should be sending data at about 1kHz rate (1ms per data point), I would use something like 50 in the Bytes per read which would give you 50ms worth of data with every read.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 16
(5,517 Views)

using visa for 1k /s rate with single data for every request is not wisdom method to work with visa in pc because it is maximum speed that is possible

so do this 
design a memory (fifo) in your board and arm program that could save 10 data and send it in array mode to pc 

then use visa with request every 100ms to solve this problem 

0 Kudos
Message 7 of 16
(5,507 Views)

also it is better to send a counter number beside your data to check and make sure  that you do not lost any data 

0 Kudos
Message 8 of 16
(5,506 Views)

using costumer and consumer(queu) method in coding also recommended 

0 Kudos
Message 9 of 16
(5,505 Views)

for last help 

it is better using send a comment to receive data instead of continuous sending data with your arm it could help you to better pc &arm synchronizing 
for example send log on comment to arm to start sending data





0 Kudos
Message 10 of 16
(5,504 Views)