10-26-2023 01:42 PM
Hello,
I am looking to turn off the laser automatically after execution or completion of run or hit stop. Currently, I have used Boolean toggle switch but everytime I need to turn off the laser manually after I stop the program. I have attached the VI file. I request to please kindly help and provide the solution for the same.
Regards,
Madhu
10-26-2023 02:02 PM
I believe we have already mentioned that you will get a LOT more help if you back-save (Save for Previous...) to 2018 or so. That way many more people can open your VI.
Having said that... This a forum to help people LEARN LabVIEW. It is not a code writing service. You need to put in some effort to learn LabVIEW rather than just asking us to "provide the solution". Please read through the tutorial and you may not need any help. LabVIEW Tutorial (ni.com)
If you still get stuck, we will be glad to help you. But at least try to program it yourself, and post your attempt so we can guide you...
10-26-2023 04:16 PM
I agree with you and am sorry for not providing the previous version of VI file, I have attached the 2018 version for the reference.
I completely understand that this forum is to help people Learn LabVIEW. I am also learning it through Udemy and LinkedIn learning courses. I just requested for the help not a solution (it was by mistake).
I tried to develop this VI logic by seeing the LabVIEW videos for beginners like me. Now, I got stuck here not understanding how to proceed further to automatically turn off the laser after the execution (or run is complete). So, I thought to get some insights from the experts in this forum.
I am sorry for creating the confusion here. Your insights will be highly appreciated.
Thanks,
10-26-2023 04:52 PM
The attached file isn't "The execution". This is a subVI that turns on or off a laser, which I assume does work. Presumably this is run by some other code and you want it to run after finishing that automatically. We need to see the "other code".
When you run the "other code" are you stopping the program by hitting the built-in "stop sign" button (the "Abort button") or something else? If you're using that stop sign... stop doing that. It is an immediate hard stop of all code, no commands possible after pressing it.
Unrelated to your original post, but spotted in your code:
Using "Bytes at port" is a bad idea. I recommend this video:
VIWeek 2020/Proper way to communicate over serial
10-26-2023 09:23 PM
A common "Design" for programs that have multiple "steps" that need to be done in sequence is a "State Machine". Are you familiar with this concept? When you start a new Project, you can use LabVIEW's "Queued Message Handler" template, or use JKI's "JKI State Machine" (look in the LabVIEW Tools Network, using VIPM), or the DQMH "Delacor Queued Message Handler" (an "award" winner). In the "Exit" state, the last bit of code you execute before closing all the executing loops, you could turn off the Laser -- problem solved.
Look at the organization of your Top-Level VI. If it is at all "complicated", you would be advised to reorganize the "Main" VI and identify the body of code that handles "closing down" various loops, stopping DAQmx Tasks, closing files, etc. and put the code to turn off the lasers there. Designing the Top Level VI (possibly as a State Machine) first makes the problem of how to successfully "turn it off" (and turn off everything, like Lasers, that need to be turned off) much easier to handle.
Bob Schor
10-27-2023 08:53 AM - edited 10-27-2023 09:52 AM
There is no problem with asking for help and sometimes the best way to learn is to see finished code. It's always OK to ask for an example or have someone who has experience get you started. We just like to see an effort and will often respond with "What have you tried???" if we don't. It sounds like you are really trying to learn, and enjoy LabVIEW so there is no need to apologize.
Thanks for posting your 2018 version. I'm sure it will help us to help you...
10-27-2023 09:46 AM
To continue your other post where I mentioned the need for subVIs and how to wire them through the connector pane: Re: Two laser diode connected onto single VI logic - NI Community
Here is a quick, basic example of how turn your code into subVIs and use them in a MAIN VI. Notice how I broke apart the code into logical parts so they can be reused as needed.
This program opens the COM port, then turns the laser off before it starts the loop. In the loop, it toggles the laser and you can set the time delay. When you press STOP, the final shutdown VI will run and turn off the laser before it closes the COM port VISA reference. Notice the LaserOnOff.vi subVI inside the shutdown.vi subVI here. This is how to build re-usable code.
Look through the subVIs and see how I did it and continue the tutorials...
10-27-2023 09:51 AM
BTW, both Kyle and Bob are completely correct in their comments. I left the Bytes at Port for now and didn't bring the very popular State Machine into it since you are still working on the basics.
The first step to move on here would really be to put all the code into a project, so it stays self-contained. You will learn about that in any tutorial...
10-28-2023 03:51 PM
Thank you so much for your detailed explanation and updated VI files. It helped a lot and also encourages me to learn these things to build my own VI in future.
10-29-2023 08:34 PM
I must admit that my first thought when I read your subject line, didn't have anything to do with LabVIEW. My first thought was, "No, Mr. Bond, I expect you to die."