cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel APT Stepper Motor control

gbartolod
Member

Parallel APT Stepper Motor control

Message contains an attachment

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.

7 REPLIES 7
JiwhanS
NI Employee (retired)

Re: Parallel APT Stepper Motor control

Message contains a hyperlink

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

https://www.ni.com/en/support/documentation/supplemental/06/event-driven-programming-in-labview.html

 

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

https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/structures/flat-sequence.html

 

Jiwhan S.
Technical Support Engineer
National Instruments
Mark_Yedinak
Trusted Enthusiast

Re: Parallel APT Stepper Motor control

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
bseguin
Active Participant

Re: Parallel APT Stepper Motor control

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

bseguin
Active Participant

Re: Parallel APT Stepper Motor control

Dear JiwhanS, Flat sequence are the worst thing to do in LabVIEW... error bus is the best way to prioritize object between each other. Flat sequence make the code hard to read and have the tendency to increase the size of the diagram. then you will complain that LabVIEW cannot zoom in and out.
 
Benoit

 

gbartolod
Member

Re: Parallel APT Stepper Motor control

Message contains a hyperlink Message contains an attachment

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.

lkwwind
Member

Re: Parallel APT Stepper Motor control

does this work?

lobzik_rff
Member

Re: Parallel APT Stepper Motor control

Could you share the code, please? Also has it worked for you? I experience similar issues.