LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Servo Control with LabView and NI USB-6009 DAQ

Solved!
Go to solution

Hello,

I am new to LabView and trying to create an application that will control two servos simultaneously. I have found plenty of solutions online using Arudino as a mediator but I want to solely use NI USB-6009 DAQ as the control. I would really appreciate it if someone could help me out with a solution. I have linked the servo information below.

 

Thanks

0 Kudos
Message 1 of 9
(1,043 Views)

USB-6009 may not have enough counters to generate the PWM signals to control the servos.

 

On the other hand, use the AO channels to drive the signal to the servos and it would work. All that you have to do is generate the PWM signal 20ms pulse cycle, 0.5-2.0ms high time using the AO channels.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 2 of 9
(1,011 Views)

Hi,

 


@santo_13 wrote:

USB-6009 may not have enough counters to generate the PWM signals to control the servos.

 

On the other hand, use the AO channels to drive the signal to the servos and it would work. All that you have to do is generate the PWM signal 20ms pulse cycle, 0.5-2.0ms high time using the AO channels.


The USB6009 does NOT support hardware-timed AO channels, all it brings are software-timed AO (at max 150Hz). So the approach to simulate PWM signals using AO pins with 20ms cycle/0.5ms ON is doomed to fail…

 

One of the more recent USB boxes (USB6002?) will fit slightly better for that task!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 9
(994 Views)

@GerdW wrote:

Hi,

 


@santo_13 wrote:

USB-6009 may not have enough counters to generate the PWM signals to control the servos.

 

On the other hand, use the AO channels to drive the signal to the servos and it would work. All that you have to do is generate the PWM signal 20ms pulse cycle, 0.5-2.0ms high time using the AO channels.


The USB6009 does NOT support hardware-timed AO channels, all it brings are software-timed AO (at max 150Hz). So the approach to simulate PWM signals using AO pins with 20ms cycle/0.5ms ON is doomed to fail…

 

One of the more recent USB boxes (USB6002?) will fit slightly better for that task!


Good catch, did not realize 6009 was very simple in feature. Better easier option would be Servo controller from Adafruit or Pololu with USB control.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 4 of 9
(961 Views)

Thank you so much for the reply and information Santosh,

 

I want to implement your solution but I am not sure how to go about creating the application to control the position of a servo. I am new to LabView so I would really appreciate it if you could write me a sample code for just like one servo using the solution you described.

 

Thanks again

0 Kudos
Message 5 of 9
(959 Views)

Hi GerdW,

 

Thank you for your reply. Is there any possible way I can control the servos with the USB 6009 since this is the only DAQ I currently have access to? If not, what other NI options (similar to your recommendation of USB 6002) would you recommend me using.

 

Thanks a lot.

0 Kudos
Message 6 of 9
(950 Views)

You should generally use a counter output for PWM since you can easily set the frequency and duty cycle (and change it on-the-fly) to drive your servo.  See this KB article for exactly how to do that:

Pulse Width Modulation (PWM) with NI-DAQmx and LabVIEW - NI

 

Unfortunately, your 6009 has a low-cost PFI solution to its counter and it can only read a DI, but not write a DO.  You will be forced to use a trick to get your digital output to do PWM.  That trick is linked in the KB above, but here is the page:

Software Timed Pulse Width Modulation - NI Community

 

However, since the best wait resolution is 1mSec and your device goes from full CW at 1mS to full CCW at 2mS, there won't really be any way to control it well.  It may drive from left to right, but will probably jitter around without a pulse width stable to at least a couple hundred microseconds.  You may be able to use the high resolution timer to get better results, depending on your PC.  Can't hurt to try it out though.  I would definitely use a Raspberry Pi for this type of thing.  If you want to stick with LabVIEW and NI hardware, you will likely have to upgrade to a better DAQ.

 

You should also look at the LabVIEW shipping examples to get ideas - Help > Find Examples... Hardware In and Out > DAQmx > Digital Output (and Counter Output).

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
Message 7 of 9
(939 Views)
Solution
Accepted by topic author robotek73

Or even cheaper option, get an Arduino (lot of cheap clones available in the market), load LINX and control the servo from LabVIEW.

 

https://forums.ni.com/t5/Hobbyist-Toolkit/bd-p/linx-toolkit?profile.language=en

 

https://www.labviewmakerhub.com/doku.php?id=learn:tutorials:libraries:linx:seeed-lotus-kit:control-s...

https://www.labviewmakerhub.com/doku.php?id=learn:tutorials:libraries:linx:sparkfun_inventors_kit:se...

 

There are many videos in YouTube on controlling servo with LINX

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 8 of 9
(906 Views)

Thanks santo_13. I started using and Arduino and tried to move to the DAQ 6009. But it seems like I'll be sticking with the Arduino based on everyone's feedback. Thanks for all the help everyone.

0 Kudos
Message 9 of 9
(848 Views)