05-29-2015 12:31 PM
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
05-29-2015 12:54 PM
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.
05-29-2015 01:01 PM
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.
05-29-2015 02:03 PM
@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.
06-10-2015
09:28 AM
- last edited on
12-10-2024
05:49 PM
by
Content Cleaner
Please,
Try to respectect this rules, it could help you
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.
06-12-2015 10:06 AM
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?