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: 

labview stepper motor signal sensor( one signal measurement per one step)

Hello everyone. I am new to labview programming and i have a problem with a strucure tha i am trying to program. I have a structure where there is a stepper motor moving a plate and a reflective object sensor who measures a distance. This distance changes continuously and the signal from the sensor has almost a sinusoidal form. I have already built a VI where i define the steps of the stepper motor with "a for loop"..and i am taking the sensor signal with a daq assistant and collecting the data to a waveform chart "while loop". What i am trying to do is to take one signal measurement from the daq assistant per one step of the stepper motor. I tried to make it happen by defining in the properties (acquisition mode) of the daq assistant "one sample on demand" and the other choices but i didnt make it. I want strictly taking one signal measurement per one step without involving timing conditions. Finally my current thought is to make a mathscript (maybe??) inside the for loop of the stepper motor and in some way to combine the signal measurement with the steps. Thank you in advance. I would really appreciate if somebody could help me.

I attach my current VI. 

0 Kudos
Message 1 of 8
(3,088 Views)

Hi ChrisEv,

 

trigger the AI measurement using your pulse output to get one sample per pulse!

 

Btw. which hardware do you use? Does your hardware allow you to use AI triggers?

Best regards,
GerdW


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

First of all thanks for your answer. I am using NI USB-6343 and an easy driver to move the stepper motor. Can you be a little more specific for the trigger because i am new to labview programming and i am a little confused with some things in labview. 

Thanks in advance

0 Kudos
Message 3 of 8
(3,072 Views)

Hi Chris,

 

open the example finder and look for DAQmx examples explaining external triggering…

 

In LV2011 it is called "Acq&Graph Voltage-ExtClk".

Best regards,
GerdW


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

Hi GerdW,

 

Thanks again for your reply. I will check this out but i still cant find the solution with external triggering. In your opinion, could this be solved (one signal measurement per one step) with a mathscript node (matlab script) which will be in this already existing VI?? I am asking this because my goal is to initialize my signal so i can have an initial position (min value of my signal) where i can define later the positions that i want. 

Thank you in advance.

0 Kudos
Message 5 of 8
(3,025 Views)

Hi Chris,

 

you don't need mathscript nor MatLab to solve this problem.

 

All you need is DAQmx and suitable DAQmx hardware!

Best regards,
GerdW


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

Hi Chris,

 

I second Gerd's opinion. You can just use DAQmx. You can use one of the PFI digital inputs as clock. I also would recommend taking a look at some of the shipping examples. These examples can be accessed by going to Help in LabVIEW –> Find Examples and under Hardware Input and Output ->DAQmx 

Continuous Acquisition Using an External Clock and a Digital Start Trigger

http://www.ni.com/example/30009/en/

https://decibel.ni.com/content/docs/DOC-12185

0 Kudos
Message 7 of 8
(2,989 Views)

Hi GerdW & fblerg

 

Thank you for your answers. They helped me to do this and i actually did this with sample clock so i managed to take one voltage measurement per one step. I managed to initialize the signal by analyzing the data of the signal. I have a question about another way to define the steps of the stepper motor. With the current VI, i define the steps of the stepper motor from the DAQmx Timing>Samples per channel...so i define the steps from the front panel which it works. Is there any way to define the steps through the MATLAB script? I attach a VI where i am trying to do this but it is not working, apparently there is a mistake. I connected the samples per channel (DAQmx Timing) of the stepper motor to the MATLAB script but it seems the way i am doing this is wrong. I 'd really appreciate if someone could help me.

 

Thanks in advance

 

 

0 Kudos
Message 8 of 8
(2,866 Views)