12-29-2017 04:58 PM
Hi,
For my application I need to do 2 things:
1) data acquisition (analog input & analog output, using daqmx).
2) control a motor
I have succeed to do each of them individually but I am having a hard time to synchronise them to one program. Each of the programs have a while loop.
basically what I need to accomplish is to do the data acquisition (for like 10 sec) and then control the motor (like move it) and then do the data acquisition again (for 10 sec)
any thought?
thanks in advanced
12-29-2017 10:39 PM
hi naama2110
you wont get help unless you upload your VI or snippet where you are stuck.
LabVIEW has synchronisation pallet which has different techniques for synchronisation depending on requirements, read the help and go through examples you'll definitely find solution, if not come back here.. again with snippet or code.
12-30-2017 04:20 AM
thank you for your response.
here are both of the programs
thanks!
12-30-2017 04:21 AM
both of the files
12-30-2017 06:06 AM
Naama,
Suppose I asked you for help on a C++ program, and sent you a picture of a listing of the program. Would that be helpful to you? Do you want to type all of my code into your C++ Environment so you could test/edit/inspect it?
Do not send pictures of Block Diagrams. Attach your VI.
Bob Schor
12-30-2017 06:16 AM
thank you for your response, I have attached the VI.
12-30-2017 10:33 AM
12-30-2017 01:00 PM
One of the more interesting and fairly common LabVIEW Design Patterns is the Queued Message Handler. Now, there are almost "religious" arguments on this Forum about the differences between a Message Handler and a State Machine, but I'm not going to go there!
The idea of a QMH is that the Message Handler is a While Loop that (a) gathers (and lets the user manipulate) the Variables that are needed in the course of the Program, and (b) provides a method of doing "steps" in a user-defined order (sort of like a State Machine, see above paragraph).
In your case, you have two main Tasks, Data Acquisition and Motor Control. Let's start with Motor Control. Connect-to-Motor should easily be handled by a QMH Model, with a conventional Event Loop holding each of the Front Panel booleans and sending a Message (Read In-XOR, or Connect to Motor) to the Message Handler which would do the single operation involving a call to your DLL and reading (or writing) values ultimately saved on a Shift Register in the Message Handler. When all of your Variables are set, you can generate another Message that says "Run Motor". I haven't looked closely enough at your code to know where/how you determine the length of time that the motor runs, but when it stops, you can then send a Message (even from within the Message Handler!) to "Start Data Acquisition", which calls your AO-to-AI VI. When this finishes, it can issue the "Run the Motor" message again, allowing you to flip-flop between these two tasks, meanwhile allowing you to also handle changes to the Motor Parameters.
Hmm -- it's easy to say all that, but what does it mean? If you open LabVIEW and click "Create Project", you have the ability to create 4 "Example" Projects that you can study and learn about State Machines and the QMH. They are called "Simple State Machine", "Finite Measurement" (which uses Simple State Machine), "Queued Message Handler", and "Continuous Measurement and Logging" (which uses QMH). I strongly recommend studying these, particularly with a fellow Engineer or Student, as two heads are always better than one when approaching unfamiliar code, and trying to see how these ideas "map" into your particular situation. If you've got a friendly Instructor, feel free to approach her, as well ...
Bob Schor
12-31-2017 05:27 AM
Bob, thank you very much for your response. I don't have anyone I can consult because nobody works with labview, but I will try to learn it from youtube.
thanks again and happy new year!
12-31-2017 05:30 AM
thank you for your response. I have studied a bit state machine but I didn't see how I can use 2 while loop which I have in my VI.
I saw examples with case structure.
thank you and happy new year.
Naama