Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Emergency!! Convert Visa Serial Read into analog waveform!

Solved!
Go to solution

Guys, can anyone suggest a solution to convert this serial read into a time-info waveform data? Since my project is have to take the value from EMG sensor and convert it in frequency domain via FFT.

This is my final project. I will appreciate for your help!image.pngimage.png

0 Kudos
Message 1 of 7
(2,959 Views)

Below is the VI.

0 Kudos
Message 2 of 7
(2,958 Views)

There are a few options here.

1. Assume your device puts a measurement out at a specific rate.  Use that rate for the dt.

2. Use the Get Date/Time In Seconds to get the current timestamp and use that as the T0.

 

Since you are worried about an FFT, I would go with 1 and use a FOR loop to get a bunch of samples into an array before doing the FFT.  Having that number of samples being a power of 2 (2, 4, 8, 16, etc) will really help the calculations.


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 3 of 7
(2,929 Views)

ya I have tried option 2 but it didn’t work, it only value changes in time of 0. Other time such as 1s or further are not showing the value.

 

How to set the sampling rate and array?

0 Kudos
Message 4 of 7
(2,916 Views)

@tank0210 wrote:

How to set the sampling rate and array?


Put the VISA Read inside of a FOR loop with the values autoindexing out.  This will build your array.  You then use Build Waveform with the array going into Y and your sample rate into dt.


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 5 of 7
(2,914 Views)

Thanks for your help!
By the way how should I control the actual timing in the loop?
Because it seems like running faster than actual time and labview cannot show actual timing.

Or just let it be?

Here is my arduino code on sampling rate.

 

void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);

// print out the value you read:
Serial.println(sensorValue);
delayMicroseconds(1000);
}

0 Kudos
Message 6 of 7
(2,904 Views)
Solution
Accepted by topic author tank0210

@tank0210 wrote:

By the way how should I control the actual timing in the loop?
Because it seems like running faster than actual time and labview cannot show actual timing.


On the LabVIEW side, the loop rate should be determined by the rate at which data comes in.

 

But looking at your timing, you will likely run into problems.  With a Baud rate of 9600, you can basically do 960 bytes/second or ~1.04ms/byte.  Your Arduino is trying to go faster than that.  So the first thing I would do is try to set your Baud rate to be a lot faster.  115200 the fastest commonly used Baud rate, so I would try using that.


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 7 of 7
(2,902 Views)