Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating a single channel digital waveform for NI9403 with configurable duty cycle and frequency.

Solved!
Go to solution
JSC81,

If my driver has a max step output of 300hz at 50% duty cycle then I will not be able to go higher then that...correct?

I am definitely not an expert on motor drivers, and my experience with motors in general is not extensive.  That question would be a good one to ask the vendor of the driver itself.  If the motor drive is supplied by NI, then you could try posting the question to the Motion Control and Motor Drives board.

 

1. If I remove the waituntilnext clock then I will have a duty cycle and frequency input and output into the DAQ, correct?

Again, removing the timing function from the while loop allows the loop to run as fast as it can.  This will cause the DAQ Assistant to update the output signal as fast as it can.  In the VI you sent me, there is a Digital Waveform going into the DAQ Assistant.  The frequency of the waveform and DAQ Assistant task determine the frequency of the output.

2. So by changing the duty cycle and leaving the frequency constant I should be able to increase or decrease the speed of the motor and keep the phase continuous , correct?

With motors that I have worked with in the past (namely the brushed DC and OSMC for the driver), yes, this is how it worked.  I would consult the manufacturer of the specific motor, or see if they have app notes or a user manual to be sure.

3. If my driver has a max step output at 300hz and 50% duty cycle, I will not get any better output if I go higher...correct?

Check the motor documentation.  My best guess is yes.

 

4. If I kepted my code in a while loop then I will continuously output the duty cycle and frequency to the DAQ until I hit STOP, correct?

Correct

 

5. To control the direction can I have a boolean switch connected to an array and this outputing into another DAQ assistant to a separate channel or is there a better way to accomplish this?

It sounds like a boolean output can control the direction of the motor.  There is nothing wrong with using 2 DAQ Assistants for the separate tasks.

 

6. Is there a way for simplicity to easily convert duty cycle and frequency to speed control such as steps/sec?

That depends on the motor you are using.  There should be some type of equation that describes the behavior of your motor with regards to the input signal it receives.  This is a matter of doing the math to produce the translation.  Again, consult the motor’s manual.

 

I am not sure how to set up my DAQ to output the frequency and duty cycle to the driver.

Hardware timed Digital Output is not supported for your device.  Therefore, outputting a signal at a hardware-timed frequency will also not be possible.  As a result, the only option you can choose for output timing on the digital lines is On Demand.  This mode simply takes the signal you feed into the DAQ Assistance (either high or low) and updates the line with the new value.  To control the frequency that this update occurs at, you could explore changing execution rate of your While Loop.  Something like the figure below may do, with execution timing.  It uses some basic logic to determine the duty cycle and frequency of the output signal.  For this one, I chose to allow increments of 10 for the duty cycle, and update every 10 samples (1 period of the square wave) every period of desired by the user (determined by the inverse of the frequency.

The other case of the case structure is just a True constant.

PWM.png

Chris_G
Sr Test Engineer
Medtronic, Inc.
0 Kudos
Message 11 of 24
(3,706 Views)

Chris you have been great.

 

So from what I understand if I want to use the USB6009 D I/O I cannot use the waveform generators, correct?

 

I will not be able to use this because inputing the duty cycle and frequency is a hardware timed operation, correct?

 

 

So for the DAQ assistant I will have have to chose (on demand) sampling and then vary how often it samples with the while loop, correct?

 

Before I was getting an error from my DAQ assistant:

This is the error I received:

 

Error - 200077 occured at DAQ Assistant

Measurments requested value is not a supported value for this property.

 

Property : Samp Timing Type

You have requested : Sample Clock

You can select: On Demand.

 

I am guessing this is because my DAQ does not support waveform input, correct?

 

 

So in your example you are generating your own waveform (in theory) with just numbers and we are not using the digital waveform vi.

 

This is very nice, I did not think of it this way.  

 

In your example does the wait control the execution timing of the while loop?

 

Would I also be able to change the structure to a for loop and just include a wait for structure which I could vary.  

 

Would this vary the rate at which each iteration occurs for a given number of steps?

 

Thanks for the advice. 

 

Jerry

 

 

 

0 Kudos
Message 12 of 24
(3,693 Views)

So from what I understand if I want to use the USB6009 D I/O I cannot use the waveform generators, correct? 
Correct.  Waveforms are signals that need to be output with a hardware-timed sample clock, which your device does not have. 

 

I will not be able to use this because inputing the duty cycle and frequency is a hardware timed operation, correct?
In normal DAQmx hardware timed waveforms, yes, the duty cycle and frequency are hardware-timed.  Obviously you can get around this (to some degree) using a VI like the one in my previous post. Now this method is not nearly as accurate as a hardware-timed device, (since Windows has to do so many other things besides execute your VI, but you may be able to get your application running this way). 

 

So for the DAQ assistant I will have have to chose (on demand) sampling and then vary how often it samples with the while loop, correct?
Correct, unless you wish to use a different device that has hardware timing.  The alternative would be to use low-level DAQmx VIs (instead of the DAQ Assistant) to perform a pulse output task where you can change the frequency and duty cycle on the fly.

 

Property : Samp Timing TypeYou have requested : Sample ClockYou can select: On Demand. I am guessing this is because my DAQ does not support waveform input, correct?
Correct.  The 6009 only supports software-timed Digital I/O.  Outputting a digital waveform requires there to be a sample clock for the task, which would then make it hardware-timed Digital I/O. 

 

In your example does the wait control the execution timing of the while loop?
Yes it does.  You can see this if you take a look at the context help for the function by pressing CTRL+H on your keyboard, and hovering your mouse over the function.

 

Would I also be able to change the structure to a for loop and just include a wait for structure which I could vary.
A for loop is probably not a good choice here, because it will run a finite number of iterations.  If you want the application to just run until a user presses a stop button, then the while loop is the way to go.  The behavior of the timing with a Wait function would be the same in a for loop as it is in a while loop, however.

 

 

Would this vary the rate at which each iteration occurs for a given number of steps?

Yes. 

Chris_G
Sr Test Engineer
Medtronic, Inc.
0 Kudos
Message 13 of 24
(3,671 Views)

Chris,

 

Thanks for everything,

 

I have a few more questions if you dont mind.

 

1. If I output (in your example) a frequency (numerical) and a duty cycle (numerical) to the DAQ through a digital output how will the driver know to take those numbers and drive the motor?

 

I ask this because I am having trouble and the motor is not responding to any output from this method and I was wondering if I am running it improperly or if I need to add another process.

 

Thanks again,

Jerry

 

 

0 Kudos
Message 14 of 24
(3,659 Views)

Hi Jerry,

 

You might want to investigate the input required for your motor. The code is only responsible for generating the appropriate pulse train to control yor motor. It's up to you to define those parameters in the code.

 

Regards,

Glenn 


Regards,
Glenn
0 Kudos
Message 15 of 24
(3,644 Views)

Hey Glenn,

I am having trouble outputting from the DAQ to the driver and therefore cannot get the motor to lock and then rotate. I have included my VI...may be you could take a look see and perhaps give me some advice.

 

Below is the input instructions to the driver.  They are all digital inputs.  

 

DISABLE PIN
TERMINAL 7 Disable
This terminal will force the winding currents to zero when shorted to ground (TERMINAL 12).

 

The DISABLE input on the G203V is optically isolated and requires logic “0” to DISABLE. Once it is disabled, the motor windings go open
and the motor freewheels.

 

STEP AND DIRECTION INPUTS

 

TERMINAL 8 Direction
Connect the DIRECTION line to this terminal.

 

TERMINAL 9 Step
Connect the STEP line to this terminal.

 

TERMINAL 10 Common
Connect this terminal to the controller GROUND

 

These 3 inputs are optically isolated from the rest of the drive. They will operate with 2.5V, 3.3V or 5V logic outputs with 2.5mA
minimum source drive current. The STEP input’s maximum rated frequency is 350kHz with a 50% duty-cycle waveform. The
G203V steps the motor on the 0 to 1 logic (positive) edge of the STEP signal.

 

 

If you get a chance would you be able to have a look and see if I am outputing everything correctly and if the VI makes sense.

 

I need to enable the motor, choose a direction, frequency, duty cycle, then press start and output this through the DAQ to the driver.

 

Thanks much,

Jerry

0 Kudos
Message 16 of 24
(3,602 Views)

Hi Jerry,

 

Can you provide some detail on the function of the DAQ Assistant_0 and the MyVoltageTask? Also it appears you are only outputting a single value on all tasks.

 

Regards,

Glenn


Regards,
Glenn
0 Kudos
Message 17 of 24
(3,587 Views)

Thanks for getting back to me sorry I was a little vague on explaination.

 

I am trying to run a stepper motor using software timed pulse width modulation. I need to output to 3 driver inputs which I included in the post before (DISABLE, DIRECTION, STEP).  

 

I am using the USB 6009 which does not have a hardware counter method so I am forced to use software timed.  The only option I can use with my DAQ is Sampling ON DEMAND.  So I have to loop it some how and send it one sample at a time for a certain period of time.  

 

 

DAQ Assistant_0 is digital output "1 sample ON DEMAND" to the "disable" input on the step motor driver. (I basically turned my DAQ Assistant to a DAQmx task.  Not sure if this is the correct method)

 

MyVoltageTask: Not sure where you see  but I do not think I am using it.

 

I am also digitally outputing  Task = "Direction" to the direction input.

 

The third should be to control the step of the motor and this should be a frequency and a duty cycle.  I want to keep the duty cycle constant and change the frequency to change the speed of the motor.  

 

 

 I have other Tasks available " Load Cell, LVDT, etc" but I am not using them right now.

 

 

I am not sure if I am outputing correctly to the Step Driver.  I have the driver input criteria but I am not sure my program is doing this correctly.  

 

Thanks,
Jerry

0 Kudos
Message 18 of 24
(3,563 Views)

Hello Jerry,

 

I found the following KnowledgeBase article that has proven effective for your application.

 

Software-Timed PWM Using a Digital Output Line

 

Regards,

Glenn

 

 


Regards,
Glenn
0 Kudos
Message 19 of 24
(3,547 Views)

So I have some questions about program response and timing.

 

I have an ocilloscope hooked up to the leads coming from the DAQ.  If I run the program you drew up and I set a constant duty cycle of 50 and a frequency of 0-50Hz then it is accurate (a bit noisy but accurate).  However, if I ramp up past this then it doesnt seem to want to go higher then about 50-60hz.  

 

Is this fixable or is this the software issue with timing.  I expected that we should at least be able to get a couple hundred Hz out of it.  60-80% of 1khz possibly.  Is this not correct?

 

Is it taking to much time to output the 0 or 1 and this is causing the issue?

 

Would it be possible to output a waveform somehow or impossible with this DAQ?  Any ideas with this problem?


Thanks,
Jerry

 

 

0 Kudos
Message 20 of 24
(3,528 Views)