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: 

Stop button problems, among other things

Hi,

It's my first time posting and my first time using LabView, so sorry if this post is in the wrong section or missing details. Please let me know what is missing and I will do my best to fill in.

I've designed a program that controls a step motor as part of a spectrometer setup. I'm using the SCB-68 which is connected to a coaxial cable which goes to the detector. The motors are connected to a card that's in a PCI slot. One of the problems we've been having is the "scan" feature: if one accidentally inputs the wrong values for the scan and attempts to stop it, it works only if the data acquisition hasn't already started. If the data acquisition has started, one has to wait for the scan to complete. This is problematic, since some scans can take as long as 35 minutes. I'm not sure why the stop button doesn't work.

 

The logic behind the scan is: if at correct starting postion, start scan/data acquistion. If not, move to postion and start scan/data acquisition.

Also, we've found that when a number that was previously used to start a scan (say pos: 11000) is put into the same field on the front panel, the scan will automatically start without the user having pressed the "Scan" button. 

I've spent nearly 3 hours trying to wrap my head around why these things are happening, but I can't figure it out.

Thank you in advance

0 Kudos
Message 1 of 6
(4,450 Views)

I'm missing a lot of SubVIs so it's hard to see what the program does, plus it looks pretty big.

 

However I am fairly sure the problem is that you have everything in one massive While loop in frame #1 of your stacked frame sequence.  If you press "Stop" it doesn't register it until the while loop completes and it re-reads the status of all of your buttons.  Which is probably 35 minutes given what you said.

 

You should have two separate loops.  Look up "producer-consumer" architecture for more information, but for a quick and dirty fix, you could try moving the Stop button and the MCStop.vi that it connects to into their own While loop.

Message 2 of 6
(4,434 Views)

OK yup you are new!  We all started somwhere.  My advice "Refactor now before you make it any worse."

 

What you need is an event driven queued state machine.  what you have is a mess.  So go search for Producer Consumer (Events).

 

Then read "A trip to Grandmas" before designing the consumer state machine.


"Should be" isn't "Is" -Jay
Message 3 of 6
(4,427 Views)

@Kyle97330 wrote:

[...] If you press "Stop" it doesn't register it until the while loop completes and it re-reads the status of all of your buttons. [...]


I thought that, too, but there's that pesky Stop2 button inside the loop.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 4 of 6
(4,393 Views)

Please,

Try to respectect this rules, it could help you Chat heureux

http://www.ni.com/newsletter/51735/en/

 

So, don't when you have a loop "A" inside a loop "B", loop B is blocked while loop A if finish.

0 Kudos
Message 5 of 6
(4,261 Views)

Hi,

I have since been working on changing my program into a producer/consumer setup. I have a question regarding my scan feature in a case structure. I have it set up so that:


If (Actual Position - Target Position) < 3 --- True:  Start Scan with given parameters, False: Goto start position and then start scan.

This leads to occasional situations that if the Start position matches the current Actual position, the scan will start automatically without a button press. How can I solve this?

0 Kudos
Message 6 of 6
(4,215 Views)