From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Movement, Measurement and time between them

Solved!
Go to solution

Hello friends, 

 

I have a doubt with my program. I've made a statemachine (using Lab 9.0, no possible to use a new one) to move two motors and make a measurement (IV curve). Motors move and measurement is done, however this measurement is made meanwhile motors are moving, why? 

 

What should I do? I want the motors move, then make the measurement, when this is made, then move motors again and so on. 

 

Any idea? All help is appreciated. Smiley Wink

 

Attached you can find the program (sorry because of the drivers, they are Thorlabs for motors and Keithley 2400 for Measurement)

0 Kudos
Message 1 of 14
(3,156 Views)

No attachment.

 

My initial thought is that you need to add a wait after moving the motors to allow the system to actually respond before you take the measurements.  Hard to say for sure until we see some actual code.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 14
(3,153 Views)

You´re right Crossrulz, I forgot to attached the code, sorry!! Smiley Embarassed

 

Here you´ve got it! I´ll wait for your answer!! 

0 Kudos
Message 3 of 14
(3,126 Views)

Hi lacorgui,

 

you need to wait for your motor(s) to reach it's postion. Right now you just send a command to the motor(s) but you don't wait for them to finish movement…

 

Setting a callback is not the same as waiting for finished movement!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 14
(3,122 Views)

Hi GerdW, 

 

I added the callback as a possibility but I do not know exactly what expect from it. I understand that I have to wait for the motor to reach its position, but how could I make this? 

 

Thanks

0 Kudos
Message 5 of 14
(3,117 Views)

Hi lacorgui,

 

well: don't change the state until it reaches it's desired position…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 14
(3,114 Views)

I see.

 

The thing is that if I run the program with the "light" (like in a probe mode) it works fine: first move, then measure once motor is stopped.

 

However, if I run the program directly measure is taken while motor is moving to next position. I will need the program to make thousand of measurements in a sample for long periods of time so I have to be sure that the motor stops and then measures. 

 

My question is your point: how can I tell the program to wait in the state until it reaches the position?

 

(Thanks for your help)

 

 

0 Kudos
Message 7 of 14
(3,111 Views)

Hi lacorgui,

 

you set a new position and you read the current position.

What about a simple comparison if "current postion" is (nearly) equal to "set position" and changing the state based on that comparison?

 

That's how a state machine works: you have some rules to decide which state to go…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 14
(3,105 Views)

Ok, I´ll try that. Smiley Wink

0 Kudos
Message 9 of 14
(3,103 Views)

lacorgui wrote:  The thing is that if I run the program with the "light" (like in a probe mode) it works fine: first move, then measure once motor is stopped.

That is called Highlight Execution.  Things with instruments tend to work so much better with Highlight Execution turned on purely because it slows your code down to a crawl.  This just screams the need to add in waits.  The state machine approach is the better way to go.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 10 of 14
(3,076 Views)