LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Outputting sine wave to motor

I'd like to drive a motor with a sine wave. I would like to specify the frequency and amplitude of the wave. When I try using the Simulate Signal express VI, I get a very jerky, discrete motion of the motor which seems to depend on the frequency and amplitude of the Simulate Signal parameters. The motor seems to rotate back and forth with a frequency that's totally different than I specify.

 

Is there a more appropriate VI that I should use to drive the motor with a sine wave?

 

Thank you.

0 Kudos
Message 1 of 21
(5,752 Views)

What type of motor and what are you using to drive (amplify) the sine wave to apply to the motor?

 

The jerkiness may be because the motor has a non-linear response to the voltage applied. Also, the motor probably has an upper limit on frequency response where it just can't move fast enough when the sine wave exceeds a given frequency.

 

-Ak2DM

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 2 of 21
(5,748 Views)
what hardware you are using to generate(Analog Out) signal?.........did you try to capture the waveform given to Motor on any Oscilloscope?.....
Anil Punnam
CLD
LV 2012, TestStand 4.2..........
0 Kudos
Message 3 of 21
(5,732 Views)
Your DAQ unit are not able source the current needed to drive a motor. But the result may be that you damage you DAQ unit. So I recommend that you stop your current activities and go back to the drawing board


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 4 of 21
(5,714 Views)
Thanks for all of your suggestions so far, but it doesn't seem that the motor's jerkiness is due to any limitations or non-linearities in the amplifier or motor. I'm using a Copley Accelnet amplifier to drive a Maxon brushless motor. I'm controlling the amplifier with the NI-PXI 7358. I can use the Copley software (CME2) to output a sine wave up to 70Hz, which the motor follows very nicely.

But when I use Simulate Signal, it seems that the output command is very quantized and differs from my desired frequency. For example, if I want a 10.1Hz output sine wave (default) and I leave 'Samples per second' at 1000 and 'Number of samples' at 100, my motor shaft output frequency is extremely slow: around 0.05Hz. But if I change frequency from 10.1Hz to 10.4Hz, the motor shaft output freq jumps to ~0.19Hz. The 'Run as fast as possible' box is checked.

When I double-click the Simulate Signal icon to change the parameters, there's a Result Preview in the upper right of the properties window. This shows a dotted sinusoid that scrolls across the screen. The motor seems to be doing exactly what is shown in the result preview. So the basis of my confusion is: why does the resulting sinusoid oscillate at a totally different frequency than my desired frequency of 10.1Hz? And how is the resulting frequency determined from the 'Number of Samples,' Samples per second,' and desired frequency?

Thank you
0 Kudos
Message 5 of 21
(5,675 Views)

try to capture the waveform generated by PXI 7358 by connecting an ocsilloscope at its output....and observe the waveform there..............

 

try generating signal as in attached VI

Anil Punnam
CLD
LV 2012, TestStand 4.2..........
0 Kudos
Message 6 of 21
(5,663 Views)

Why don't you post the VI as you have it now?

 

It may be an issue of the datatype you are using or a mismatch between how you generate the sine wave and the parameters you pass to the analog output VI.

0 Kudos
Message 7 of 21
(5,649 Views)

Thanks a lot for your help, I started over and implemented Anil's VI (attached). This sine wave is now much smoother. I no longer get the quantization problem (turns out I had a 'Wait Until Next ms Multiple' in the loop). But I still don't get the same output frequency as what I input.

 

For example, if I type in that I'd like a frequency of 10Hz, I get no movement out of the motor. When I enter 10.005Hz, I get 1.18Hz out.... see below:

Input freq (Hz)    Experimental Output Freq (Hz)

9.5                     extremely fast

9.995                 1.18

10                       0

10.001                0.22

10.003                0.70

10.005                1.18

10.5                    extremely fast

11                       0

 

It seems that for integer frequency inputs I get no movement. For integer+1/2 I get the fastest output freqs. Is there a better way to simply output a sine wave to my motor with a specified frequency?

 

Thanks again.

      

 

0 Kudos
Message 8 of 21
(5,610 Views)

Your sine wave generation looks okay.  The problem must be in one of those Flexmotion subVI's.  I don't have that module, so there is no way I can look into them.  My guess is that the motion control parameters aren't set right for you motor.

0 Kudos
Message 9 of 21
(5,587 Views)

Hello matthewg,

Unfortunately, it appears at first glance that you have a major design problem with your code.  As the members in this forum have already pointed out, there is nothing wrong with the sine wave being generated.  After taking a quick look at the VIs you are using to control your PXI-7358 motion controller (and in the end, drive your motor), the problem is the way in which you are using the sine wave.  The biggest problem is that the VI that you showed us in your other post is that you are writing a waveform of data to the Load Target Position.flx on the Target Position input.  If you open up this subVI, you will see that the input is actually an I32, which means that the Waveform data type is being cast to an I32.  If you run the VI Snippet below, you will see that when a waveform data type is cast to an I32, only the last value of the waveform is used, and cast to its nearest integer representation.

 

WF_to_I32.png

 


That would most likely be the explanation for the strange behavior that you are seeing from the motor.  Whenever you have an integer frequency input to the Sine Waveform.vi, its last point will always be ‘0’.  In addition to this, it looks like you are re-configuring the device every iteration of the look using Set Operation Mode.flx.  I am guessing that this re-initializes the motor controller every iteration, and basically keeps immediately moving to a desired position, with no control over the speed and acceleration at which it moves.

 

 From the look of your code, it seems as though you wish to use the absolute position to control the rate at which the motor moves.  I believe that setting the position mode to “velocity” is best in this situation, but even so, it appears as though there is an example in the LabVIEW Example Finder (Help » Find Examples…) for what you are trying to do that uses "Absolute Position".  In the example finder, on the Browse tab, go to the Hardware Input and Output » Motion Control » NI 73xx » Straight Line Move folder.  There you will find a couple of VIs that seem to resemble the operation that you are looking for: Sequence of One-Axis Moves (Onboard).vi and Sequence of Blended One-Axis Moves.vi.  You will see that these examples continually spin the motor by giving is a set of desired positions, and control the velocity and acceleration at which the motor moves from position to position using Load Velocity in RPM.flx and Load Accel/Decel in RPS/sec.flx, respectively.  These should be enough to get you going in the right direction.   If, after trying these examples out and customizing them to fit your needs, you continue to have difficulties, your best bet for support would be in the Motion Control and Motor Drives forum.
Chris_G
Sr Test Engineer
Medtronic, Inc.
Message 10 of 21
(5,460 Views)