From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

problem in acquirng data thru RS232

 i am acquiring data from serial port rs 232 instead of nidaq card but the problem is that my graph is not coming that smooth as i am providing a sine wave through function generator, although acc. to input data output value changes, but instead of showing sine wave graph is shpwing peaks of the amplitude that i provide, so i am not getting where actually is the problem, if any one culd help

0 Kudos
Message 1 of 5
(3,101 Views)

Because you did not include any data for us to look at, it is more difficult to detrmine what the problem might be.

 

Run your VI so that some data shows on the Waveform Chart. Stop the VI. From the Edit menu Make Current Values Default.  Save the VI. Post that VI with the data.

 

These possiblities come to mind.

1. Serial communications are asynchronous which means that the time between adjacent bytes can vary.

2. Your signal frequency and the sampling rate do not meet the Nyquist criterion.

3. You are only looking at two bytes of the received string for each iteration of the loop. You may be missing data.

4. You can probably get your numeric output in one step by using the appropriate formatting with Scan from String.

 

Lynn

0 Kudos
Message 2 of 5
(3,078 Views)

i am saving only 2 bytes bcs my actual data consists of 2 bytes only, other bytes represents channel name and next line address and i had tried almost all solutions to get the numeric output in one step by scan from string but but since i had to separate my data from channel name and next line address, i came across this solution only, if there is any better approach please let me know 

my data is like this 1C8F 0A, 1 represents the channel name and 0A is next line address so data is only C8F which is of my use 

 

Download All
0 Kudos
Message 3 of 5
(3,074 Views)

From looking at the graph and the data it appears that your data acquisition setup has at least two serious problems. 1. The remote device is saturated at both the maximum and minimum levels.  The repeated 5, 5, 5 and 0.1, 0.1, 0.1 data values indicate this.  You need to attenuate the signal before it reaches the device or reduce the internal gain of the device. 2. The sampling rate is too low to reproduce the waveform nicely.  You are only getting 8 or 9 samples per cycle.  While this meets the Nyquist criterion, it is too low to give you anything which looks like a smooth sine wave.  Do you know the data will always be a sine wave? Are you trying to measure amplitude, frequency, phase, or something else?

 

Your string is always two data bytes followed by a line feed, right?  How much of the string is the channel name? One bit, 4 bits, something else?  What numeric value does "C8F" represent?  What is the exact data format?

 

Lynn

0 Kudos
Message 4 of 5
(3,028 Views)

thanks for the help, i made some changes in my vi, and now i am getting the correct output.

0 Kudos
Message 5 of 5
(2,978 Views)