09-18-2009 04:15 PM
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.
09-18-2009 04:27 PM
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
09-18-2009 10:18 PM
09-19-2009 05:07 AM
09-21-2009 03:18 PM
09-21-2009 03:54 PM
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
09-21-2009 07:09 PM
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.
09-22-2009 02:33 PM
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.
09-22-2009 03:00 PM
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.
09-28-2009 01:35 PM
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.
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.