LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting single 32 bit real number to waveform for fft

Hi,

I have a program here where I need to send a waveform from server side to client side. While TCP protocol is working, the data I am getting on client side is single 32-bit real numbers. I am getting waveform when this is plotted but now, I need to get the FFT of this data. I have attached the photo of the circuit on client side. Can anyone give any suggestions please?

0 Kudos
Message 1 of 17
(1,171 Views)

Hi shreyaskarnad,

 


@shreyaskarnad wrote:

I have a program here where I need to send a waveform from server side to client side. While TCP protocol is working, the data I am getting on client side is single 32-bit real numbers. I am getting waveform when this is plotted but now, I need to get the FFT of this data. I have attached the photo of the circuit on client side. Can anyone give any suggestions please?


When you receive single samples then you need to build your waveform from those samples…

 

  • What about using an autoindexing output tunnel to create an array of samples?
  • Does your server REALLY send waveforms (containing more than one sample)? Then your client/receiver is implemented wrong: read the whole waveform…
  • How many bytes do you receive per TCPRead call? Does TypeCast really do what you need to do with the received string?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 17
(1,166 Views)

Thanks for reply sir,

The thing is I am completely new to LabVIEW and I got the program online which I modified a bit. I replaced the sinewave creator on the server side to function generator. The signal passing to client side is going very good. The moment I change frequency and amplitude on the knobs in given image, it is reflected in client side immediately. But the signal in sine wave or any wave I wish to get in frequency domain. to find the peaks in frequency as required for the further analysis

Download All
0 Kudos
Message 3 of 17
(1,159 Views)

Hi shreyaskarnad,

 


@shreyaskarnad wrote:

The thing is I am completely new to LabVIEW and I got the program online which I modified a bit. I replaced the sinewave creator on the server side to function generator. The signal passing to client side is going very good.


So on server side you typecast a SGL array to a string, but on client side you convert that string back to a scalar SGL value: does that sound right to you?

 

Recommendation:

  • Use FlattenToString on server side (instead of TypeCast).
  • Use UnflattenFromString on client side (instead of TypeCast). Use a SGL array constant as "type" input.

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 17
(1,125 Views)

Frankly speaking sir, I am fully confused. I have never used these functions before. Flatten and unflatten both require some additional parameters and I have no idea what those are...

0 Kudos
Message 5 of 17
(1,114 Views)

Hi shreyaskarnad,

 


@shreyaskarnad wrote:

Frankly speaking sir, I am fully confused. I have never used these functions before. Flatten and unflatten both require some additional parameters and I have no idea what those are...


First read the LabVIEW help for those functions.

Then use the same parameters for both functions - or don't wire the optional inputs to use their default values…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 17
(1,107 Views)

Sir I didn't understand what do you mean by Use a SGL array constant as "type" input.

0 Kudos
Message 7 of 17
(1,093 Views)

Some basic things.  An FFT requires that you have a value for deltaT and an array of data. 

 

To get started use

 

Programming -> Signal Processing -> Spectral -> Amp&Ph Spect

 

That function requires an array of signal values and a dT value.  You also have an input for unrap phase if you want to use it.  At first I would recommend that you do some tests using your produce a sine wave subVI to see what to expect.  Thus if you want to use the TCP function to pass the data you will also need to pass dT. 

 

Regarding flatten to a string.  Here is a hint when someone just tells you a function name.  tap cntl-spacebar at the same time it will give you kind of a search for function box.  Type in the function name and double click on the correct one.  Then tap Cntl-H to get the context help box and click on detailed help. 

 

It happens to be in

 

Programming -> String -> Flatten Unflatten String -> To string

 

Me if I was passing some thing that as a string I would probably do it by building an array where the first element is dT and the remaining elements are the data array.  I would then convert it to an string by using the function.

 

Programming -> string -> Array to string 

 

Then pass the string like you are.  On the receiving end I would take the string and run it through the function.

 

Programming -> String -> Spreadsheet string to array

 

I would then split the 1 D array at 1 and index the top array to 0 in order to get the value for dT and plug the bottom array into the FFT function.

 

Also the level of complexity that I like for passing variables is.

 

Within a single VI, local variables (better yet with a shift register and a wire).

 

From a single VI to a separately running VI I use global variables

 

From one computer to another I use shared variables, which tend to be tricky to set up but work very well.

 

I should look into the TCP write and TCP read to see what level of complexity they add as compared to the shared variables.

 

 

0 Kudos
Message 8 of 17
(1,071 Views)

@shreyaskarnad wrote:

Sir I didn't understand what do you mean by Use a SGL array constant as "type" input.


this from your receiver

alexderjuengere_0-1700766669775.png 

and that is from your sender

alexderjuengere_1-1700766808629.png

 

 

you are sending an array - serialized as a string - but are receiving a scalar, because you use a scalar not an array to de-serialize.

in your receiver, you are meant to change the scalar constant into an array constant 

 

alexderjuengere_2-1700767347181.png

 

 

https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/constants/array.html

0 Kudos
Message 9 of 17
(1,043 Views)

Sir I tried switching it to numeric array but on doing so I am not getting any waveform on the monitor in receiver end. When it is just a numeric constant at least I was getting waveform. 

0 Kudos
Message 10 of 17
(996 Views)