LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Requesting Help Outputting a Square Wave Through Digital Output

Solved!
Go to solution

Hello LabVIEW professionals,

 

I am a LabVIEW novice who has tried to extensively search for a way to do what I assume is a simple job. For the past two weeks I have googled and watched youtube videos and even looked at a LabVIEW textbook, all to no avail.

 

I am trying to write a program that outputs a logic signal square wave (+5 V high, 0 V low). Creating the square wave was not a challenge, as I used the simulate signal VI, and it can even take in a frequency from the user. This square wave will be sent to a stepper motor controller that will view the rising edge of the square wave as a trigger to step the motor. In this way, by altering the frequency of the square wave, the user can alter the speed of the motor.

 

I have figured out a way that is probably incredibly inelegant, but works to output an oscillating logic signal. After punching in a desired frequency, the user pushes a button to run the motor. This button starts or stops a while loop which the signal generation and output are located within.

 

With the background info out of the way, let me explain my problem. The timing given by the user, the frequency, is dependent upon the wait time between different iterations of the loop. I can "eye-ball" the correct amount of time to tell the loop to wait in order to get a frequency of 1 to correctly oscillate, however there are issues when going to higher frequencies. For instance, at a frequency of 10, according to a test indicator I have, the value doesn't oscillate at all. I assume this is due to a sampling issue where the program only samples in such a way that it only hits high or low logic values, but everything I have tried has not fixed the problem or just created new ones. I have attached the program to this post.

 

I apologize if there are any horrible or disgusting coding methods in here. Like I said above, I only started working with LabVIEW about a month ago and I don't really have a teacher or anyone around to help.

 

Thank you!

0 Kudos
Message 1 of 6
(1,485 Views)
Solution
Accepted by topic author Nick411

What data acq device(s) do you have available for generating the step pulses for the motor controller?  You'll be much better off approaching this as a counter pulse train output task than as a digital output task.  Hopefully you have a device with counters available.

 

Have a look at some of the shipping examples to starting learning how to use normal DAQmx functions.  Among many of us who've been around this stuff a while, the DAQ Assistant is notorious for rapidly delivering newer users to a complete dead end.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 6
(1,474 Views)

Hey Kevin,

 

Thanks for the quick reply!

 

The DAQ I have is the PCIe-6361. It is sad to hear the DAQ Assistant isn't a good resource, since most of the intro videos I watched from NI used it. I found this link when looking for where to find the shipping examples, I hope it is correct for Windows 10.

 

Thanks again,

Nick

0 Kudos
Message 3 of 6
(1,469 Views)
Solution
Accepted by topic author Nick411

My advice would be to start here. Skip the part about the DAQ Assistant and concentrate on the LabVIEW code. Note that this is part of the Getting Started with NI-DAQmx series. 

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 4 of 6
(1,444 Views)

Hey GovBob, thanks for the great resource. I saw many chains of VIs that used the DAQmx VIs but couldn't find a good resource to explain them. Don't know how I missed this. Either way, thank you very much!

0 Kudos
Message 5 of 6
(1,437 Views)

LabVIEW shipping examples can be accessed from LabVIEW's Help menu.

Help->Find Examples...->Hardware I/O->DAQmx.

 

The DAQ Assistant is kinda like putting on stilts when first learning basketball.  Sure, you get to make short easy shots right away because you're right there at the rim.  But if you ever want to play an actual full court game against other people, those same stilts are a major handicap, drastically limiting what you'll ever be able to do on the court.

 

Back to good news -- your 6361 is a very capable device and will let you approach this task more simply with a counter output task instead of a digital output task.   The examples will help you get started.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 6 of 6
(1,427 Views)