10-17-2018 04:07 PM - edited 10-17-2018 04:10 PM
Hello all. I am coming across some issues in running two stepper motors in parallel instead of moving in series as they currently are. I am using Thorlabs APT drivers to position both stepper motors to a specific location, but regardless of what I attempt I cannot make them both run at the same time. I am also fairly new to LabVIEW and parallelism so forgive me if the solution is minor. Attached is an image of the current set-up.
10-18-2018 01:18 PM - edited 10-18-2018 01:19 PM
Hi gbartolod,
Since LabVIEW operates on data flow, it is difficult to know in what order operations will occur.
To start, using an event structure would be better than continuously polling the start button/switch in a while loop.
Event-Driven Programming in LabVIEW
http://www.ni.com/white-paper/3331/en/
I would consolidate both sections of motor code together to use a sequence structure to ensure the motor operations are done in a specific order to help better synchronize their movement.
Flat Sequence Structure
http://zone.ni.com/reference/en-XX/help/371361P-01/glang/flat_sequence/
10-18-2018 04:47 PM
Is the Thorlabs library thread safe? an it be run in parallel? You might want to see if that is possible first. It could be the library does not allow parallel execution. I don't see anything inherently wrong with your code. I do agree with using the even structure for monitoring your button presses. Though any UI code (watching for button presses) should probably be done in parallel with your main code. I would also suggest using state machines rather than using sequence frames to control the flow of your execution. I'm surprised to see an NI employee recommending that. While sequence frames do have some limited use, they should generally be avoided for controlling all of your execution sequencing. State machines, producer/consumer, queued message handlers are all better ways to control execution over using sequence frames.
10-18-2018 08:31 PM
your architecture is wrong.
Since you initialize in parallel, the thread wait till your close the first initialization. (race condition determine witch one start first) The motion can be put in parallel for both motor, but initialize it only once and use the same reference to provide direction to both motor at the same time. Them close the reference only when you have finish with both motor.
Benoit
10-18-2018 08:34 PM
10-22-2018 07:24 PM
There is a manually operated APTUser utility that comes with the APT drivers that does allow for parallel movement. Also, according to an APT systems brochure by Thorlabs it should be able to. (https://www.thorlabs.com/images/PDF/apt%20Brochure%20US240206.pdf)
This was my attempt at making the system work in parallel, attached is what the system actually looks like in use.
12-14-2018 02:45 PM
does this work?
05-31-2021 03:56 AM
Could you share the code, please? Also has it worked for you? I experience similar issues.