LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating customized signal

Hello all,

 

I've been trying to generate a customized signal on LabVIEW. It needs to be repeated periodically. I wrote a C-code and implemented it in the function block and put the block inside a while loop that is time-controlled using a tick counter. The signal works properly, when I tried plotting it within the while loop. However, when I try to read the data from outside the while loop, I am unable to. Is there any way I can extract the data outside the while loop or use a different timing mechanism that doesn't involve a while loop?

I tried using a queue but the values weren't passed outside the loop even when I used the queue.


Thanks!

 

sirius18

0 Kudos
Message 1 of 5
(2,879 Views)

Wow, you're determined to stick to a text based programming language even inside a LabVIEW block diagram!

 

I'm not sure your VI is working the way you want it to. There is nothing slowing down the while loop. It will loop as fast as the CPU can handle.

 

The timing primitives on your block diagram are just giving a millisecond timer value, they aren't providing any periodic timing.

 

Your formula node is supplying 1 value pair at a time, these pairs need to be collected somehow. When the XY graph is placed on the the block diagram a "Build XY Graph" express VI is also added to collect the XY data points for you, otherwise you will only ever see a single value pair. The bit that isn't obvious is that you need to wire the "reset" input to the "Build XY Graph" express VI. Otherwise its default value is True and it resets at every iteration and you only ever see one value.

 

There is a "First Call?" primitive you can use to reset the Build XY Graph VI once at the start and then switch over to collecting data.

I've also added a "Wait millisecond multiple" inside loop to slow it down and give you consistently timed data points. Without it you will get countess millions of unpredictably timed data points a second.

 

I think this will get you to the next step.

 

 

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 2 of 5
(2,870 Views)

Hello TroyK,

 

Thank you for the reply!

However, when I run your VI, the signal I want gets generated only once. I would like the function of the cosines to be repeated continuously. I was able to get it to run continuously in my C-code, but I wasn't able to get the data out of the while loop that I used. Using global variables didn't help either. 

Could I know if I am doing something wrong?

 

Thanks!

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

I've attached my VI where I've used a global variable.

 

Thanks again!

0 Kudos
Message 4 of 5
(2,845 Views)

Hello,

 

Sorry, I had to use a local variable. Problem solved 🙂

 

Thanks once again!

 

Sirius

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