07-25-2023 04:55 PM
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
Solved! Go to Solution.
07-25-2023 08:34 PM
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.
07-26-2023 12:50 AM
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!
07-27-2023 02:05 PM
@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.
07-27-2023 02:06 PM
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
07-27-2023 02:14 PM
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.
07-27-2023 03:38 PM
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).
07-29-2023 01:52 PM
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
There are many videos in YouTube on controlling servo with LINX
08-02-2023 12:46 PM
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.