LabVIEW

cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

Sine Wave output to Servo Drive

I have a State Machine architecture for complete control of a test rig. ( LV7.1 + PCI6229 + Win_XP )

In  State_2, I need to drive a Servo motor ( in a sine wave pattern )whose driver amplifier is configured for Velocity mode. The 2000 rpm (CW) corresponds to +10V and 2000 rpm (CCW ) is with -10V. Thus the drive rpm is in direct proportion to the command volt and polarity.

I have used a  Basic Function Genarator.vi to produce the required Sine output. Query is : Will this set up work  as expected  from the Timed loop of 50ms ?  Will the loop timing have any effect  on the frequency generated ?

Thanks

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 5
(3,904 Views)

Raghunathan -

The answer to your first question really depends on what exactly you are "expecting" the VI to do in the first place. It's probably best in your case simply to think of the timed loop as nothing more than a while loop with a built-in delay. Thus, in your example, one iteration of the loop will execute every 50 ms. The loop timing has nothing to do with the sine wave generation or the way that data is output from the DAQ card, so to answer your second question, the timed loop itself will have no effect on the sine wave frequency that you write to the card in "State 2".

Kind Regards,

E. Sulzer
Applications Engineer
National Instruments
0 Kudos
Message 2 of 5
(3,884 Views)
Dear Sulzer,

Yes I am using the Timed loop as a while loop with built in delay. I normally do this  as the timed loop gives you an elegant option of changing the loop timing on the fly and many other options.

Coming to my query, let me explain  a little bit :

- I have started the Sine wave generator.
- For the first  50ms call, it would have sent in the programmed  number of  samples ( in my case I have used the default values) to output.
- Loop waits for  50 ms
- The second call to the Sine wave generator happens. Now it will put out another chunk of samples.
- Question is : Will the second chunk of data smoothly merge with the first chunk of data ?

The sine wave generator is a continuous process and I am reading the values in specific intervals. So will the read values be a smooth representation of the wanted  waveform is the real question.

Regards

raghunathan



Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 5
(3,882 Views)
Raghunathan,
 
According to the way you implemented things in the code you posted, you are actually not writing sine wave data to the DAQmx Write function every iteration. In the "states" where the sine wave generation does not execute, you are writing default data to the DAQmx Write function. This means that it won't really matter whether the data matches up or not.
 
If, however, you were to modify your code such that new sine wave data was written to the DAQmx Write function every iteration, whether or not it will match up with the previous data depends on 3 variables (none of which relate to the timed loop): (1) the specified frequency of the sine wave, (2) the sampling frequency of the sine wave generator, and (3) the number of samples returned by the sine wave generator. The way to tell whether subsequent sine waves will match up depends on the following equation:
 
(sine wave frequency * # of samples) / sampling frequency
 
If the result of that equation is an integer (divides evenly), then your sine waves will match up. Otherwise, there will be some kind of discontinuity between them. In your specific example, the equation follows: 7.25 *1000 / 1000 = 7.25. Thus, those values currently will not match up.
 
Kind Regards, 
E. Sulzer
Applications Engineer
National Instruments
0 Kudos
Message 4 of 5
(3,872 Views)
Dear Sulzer,

I follow what you say. In fact  the sine wave function by default "remembers " the last call values and continues from there for the next call. I had to read the help document in detail to know this "truth".

I will now manage my sample size and frequency to get  an integer result for the equation that you had indicated. As to the other States where I do not need the Sine function, I shall simply set the Reset input of the function to true. That should handle those default cases.

Thanks for the support.

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 5 of 5
(3,869 Views)