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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with Saving data

Solved!
Go to solution

I have to write a program to generate random numbers till the Stop button is pressed, while saving the generated numbers. After the stop button is pressed, the largest of the generated Random numbers should be displayed

0 Kudos
Message 1 of 20
(2,593 Views)

Hi, 

 

You may have a look at the attached VI. It does what you asked. It would benefit you if you go through the "Getting started with Labview" doccument before trying examples like this and posting doubts.  


Regards,

 

Nitzz

(Give Kudos to good Answers, Mark as a solution if your problem is Solved;))

Message 2 of 20
(2,588 Views)

Thanks for the help, but there is one further issue. I will be using this as a part of another VI and i dont have to diplay the array of Random numbers. Will it be possible to remove it??

 

0 Kudos
Message 3 of 20
(2,582 Views)

Hi,

 

If you dont want to display the array of random numbers just delete it and clean up the broken wires. It will work fine and give you the maximum values. To make it clear, the random numbers generated are not strored in the array indicator but it is stored in the shift register. So deleting the indicator wont do any harm.

 

Regards,

Nitzz

(Give Kudos to good Answers, Mark as a solution if your problem is Solved:smileywink:)

Message 4 of 20
(2,578 Views)

Hi,

 

You may mark it as a solution if your problem is solved so that others may be benefitted.:)


Regards,


Nitzz

(Give Kudos to good Answers, Mark as a solution if your problem is Solved:smileywink:)

Message 5 of 20
(2,569 Views)

Guess it would be better if include the whole program..

 

i have this program, where when i press the start button it should generate of series of Random numbers and when the press the button marked as "Getpeak 1", it should get the meximum from the generated random numbers and calculate b1.

If the " Getpeak 1" is not pressed, the value of b1 stays as 1 and waits for the user to press "getpeak1"

0 Kudos
Message 6 of 20
(2,566 Views)

Hi,

 

Check this example, It does what you need.


Regards,

 

Nitzz

(Give Kudos to good Answers, Mark as a solution if your problem is Solved:smileywink:)

Message 7 of 20
(2,560 Views)

Thanks... i was able to tweak my program with your random number example....

Can you please check if there are any bugs??... I noticed one though, the get peak button doesnt return to the False state after i stop the program

0 Kudos
Message 8 of 20
(2,557 Views)

Thanks... i was able to tweak my program with your random number example....

Can you please check if there are any bugs??... I noticed one though, the get peak button doesnt return to the False state after i stop the program

0 Kudos
Message 9 of 20
(2,557 Views)
Solution
Accepted by topic author ullokey

Hi,

 

There were some mistakes in your code. I have edited them and have attached here. Have a look. 

Notes:

 

Always use a wait timer(wait till next ms) function inside a while loop if it is running for a long time. Otherwise the CPU usage will be very high.

         

When ever you build an array with build array in a loop, use a Shift Register. Otherwise only the last element will be built into the array and you will loose  the rest of the elements.

 

Minimize the use of Local variables in your codes because they may create race conditions.

 

To turn back the state of any button after pressing it, Right click button -> properties -> operation -> Latch when pressed. This will turn on the button once and again will turn it off.

 

If you still have any doubts, feel free to post it here..:)

 

Regards,


Nitzz

(Give Kudos to good Answers, Mark as a solution if your problem is Solved:smileywink:

Message 10 of 20
(2,551 Views)