From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

controlling speed of bipolar stepper motor with usb 6009

Hello,

I am working with a closed-loop control system where I need to control the speed of a bipolar stepper motor using NI USB 6009. Now the VI I designed in LABVIEW is running and controlling the speed of my DC motor but not running the stepper motor.
As PWM is not available in 6009. I would request if anyone can help me in this regard to show me a way how to control the speed of the stepper motor using LabVIEW.


Regards

0 Kudos
Message 1 of 8
(1,579 Views)

As you are a New Member, you probably haven't read many Posts on the Forum and seen questions, similar to yours, where someone (new) asks "How do I do X in LabVIEW", or "My code does not work", and don't provide us with their LabVIEW code.

 

To help us to help you, please provide as much information about "what doesn't work" as possible.  In particular, provide as much of your LabVIEW code as possible.  If you are using a LabVIEW Project environment, compress the folder containing the Project and attach the .zip file.  That will get us started -- it tells us (a) what Version of LabVIEW you are using (though that is also helpful for you to tell us, including whether you are using 32-bit or 64-bit LabVIEW), (b) what your code looks like (which gives us a clue as to your LabVIEW experience), and (c) lets us try executing your code and seeing what it does.  It might also be helpful to tell us something about the "bipolar stepper motor" so we know the requirements for driving it.

 

Bob Schor

0 Kudos
Message 2 of 8
(1,560 Views)

Thank you very much for your time and reply. 

Sorry for the inconveniences, as I am a new member so I missed out some informations while asking the question.

 

- The stepper motor I am using is,

NEMA 17HS4401 Bipolar Stepper Motor 

- The NI card I am using is,

NI USB 6009

- The motor driver I am using,

L298N motor driver

-The LabVIEW version is 2020 and 64bit

- The VI used to run DC motor is attached.(Motor Run.vi)

 

I know that the ni usb 6009 doesn't have an onboard counter so do I need to connect a counter hardware? Or is there any possible way to do it by LabVIEW code? 

 

I have a LabVIEW vi file which runs a stepper motor using Arduino uno. 

I have also attached that vi. If I want to modify this vi where I need to do the alterations. 

 

Please help me

Download All
0 Kudos
Message 3 of 8
(1,525 Views)

The Good News is that there are several articles (including here on the Forum) about generating a PWM signal using a USB-6009.  It is "not recommended" as it is software-driven, but LabVIEW is pretty capable ...  Also, a Web search for your Motor Driver (thanks for attaching this) shows how to hook up an Arduino to do the PWM.  There is a growing interest in using Arduino and LabVIEW, but that's not my area of expertise ...

 

Bob Schor

0 Kudos
Message 4 of 8
(1,517 Views)

Thank you for your time and help. 

I have checked several questions and answers regarding PWM signal generation for 6009 in forum but none of them are conclusive. In several of them the thread started with a question or someone facing problem while generating pwm signal in 6009. 

From those I got the idea that LabVIEW can generate the pwm signal for 6009 but the solution i could not find. 

If you can help me regarding this matter I will be very grateful. 

 

I actually don't want to use Arduino. I already got a 6009 and that is what I want to use. 

0 Kudos
Message 5 of 8
(1,498 Views)

Hi Jimmy,

 


@Jimmy_Watson wrote:

I have checked several questions and answers regarding PWM signal generation for 6009 in forum but none of them are conclusive. In several of them the thread started with a question or someone facing problem while generating pwm signal in 6009. 

From those I got the idea that LabVIEW can generate the pwm signal for 6009 but the solution i could not find. 


Two options with your USB6009:

  1. Use an AO to output a waveform containing your PWM pattern.
  2. Switch a DO pin as needed. This will allow for "slow" PWM signals as the USB6009 is limited to about 100Hz update rate for DO channels (due to software timing and USB bus)…

Edit: The AO of the USB6009 is also software-timed, so you run into the same problem as with DOs: you are limited to ~100Hz update rate…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 8
(1,491 Views)

@GerdW wrote:

Hi Jimmy,

 


Two options with your USB6009:
  1. Use an AO to output a waveform containing your PWM pattern.
  2. Switch a DO pin as needed. This will allow for "slow" PWM signals as the USB6009 is limited to about 100Hz update rate for DO channels (due to software timing and USB bus)…

Edit: The AO of the USB6009 is also software-timed, so you run into the same problem as with DOs: you are limited to ~100Hz update rate…


Drat!  It's been so long since I used the USB-6009 that I completely forgot it needs to do a USB command for every switch of the AO or DO line.  I've done A/D sampling at "reasonable" speeds with this device, but in recent times (like the last 5 years) I had access to more fully-functional USB multi-function units.  However, doesn't the (I presume "successor" to the 6008/9) USB 6001/6002/6003 have a (single) Counter/Timer, and advertise a rate of 5 kS/s for its DIO lines?  Oops, this output rate with a single Counter/Timer is for the Analog line (which you could use to "fake" a PWM signal.  If you really want to use DIO for PWM, then you need two Counter/Timers, one for Pulse Rate, one for Pulse Width, and that's the USB-6212, which is the "more fully-functional USB" unit I referred to, above.  It is also pricier ...

 

Bob Schor

0 Kudos
Message 7 of 8
(1,474 Views)

- the USB-6009 is probably not capable of handling the closed-loop motion control you're trying to do

 

- any other USB device will be quite limited for closed-loop control.  But if your needs are pretty undemanding, some may work well enough

 

- it sounds odd that you'd be looking to use PWM to run a stepper motor.  They're more typically controlled with a step pulse & direction pair of signals.

 

- for speed control, you'd probably generate a continuous pulse train with a counter and change the frequency on the fly.  Both M-series (62xx) and X-series (63xx) devices can do that with just 1 counter, though in most cases an X-series will be a better option.  (Either way, you'd probably also use 1 DIO line for the direction signal).

 

 

-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 8 of 8
(1,463 Views)