01-09-2014 11:53 AM
01-09-2014 12:10 PM
01-09-2014 12:57 PM
Hi Thomas,
Servo motors accept "PWM (Pulse Width Modulated)" signals to work. This signal has a total PERIOD and a range of DUTY CYCLES by which the motor moves a certain degree. Refer to your servo motor's datasheet for total pulse duration, frequency and range of pulse widths (duty cycles) to create a PWM signal. There are many tutorials on PWM over the internet.
As per the LabVIEW code is concerned, I think this thread and this page will help you.
01-09-2014 01:12 PM
Hello, I know how the PWM works, and I used the vi given in the 2nd link (https://decibel.ni.com/content/docs/DOC-17537)
This VI is extremly slow, took at least 1 second for the servo to react.. The link says the DO of the Mydaq will not be able to send the pulses. Is it possible to send the pulses digitally from the 6341 though? I would like use the 6341 as fast as the microcontroller works in this video: http://www.youtube.com/watch?v=sGOpeKWw7go. Whats the easiest way to send pulses to the 6431 digital/anolog? Or is it even better to use the counter output?
01-09-2014 01:57 PM
Your link (https://decibel.ni.com/content/docs/DOC-17537) gives you everything you need, assuming that the vi (which I haven't downloaded) is similar to the code block displayed there.
Their loop is updating every 75ms, so I can't see how you're getting so much delay? Obviously it will take a bit longer on first run with all the setup, but once it's going, it should be very responsive to angle changes.
The only possible source of delay I can think of is the sample buffer length you're allocating. The delay will be pretty much the same as the buffer duration, so you can try cutting the buffer down, but there is a trade-off; a shorter buffer has less 'cushion' and therefore more chance of an underflow if the OS goes off to do something else for a bit. In any case, your buffer length needs to be at the very least a bit longer than your loop interval of 75ms.
If you can't get the buffer length sufficiently short without underflows, then you're bang out of luck. Windows is not deterministic. You could by an arduino for something like £15 and program that to generate the pwm waveform. Communicating with the arduino from LabVIEW on a connected PC via serial will allow you to command speed changes.
01-09-2014 02:01 PM
Which DIO line are you using? The NI-6341 has four 32-bit counter/timers. Refer to the following link on how to use counters in DAQ for PWM.
http://www.ni.com/white-paper/2991/en/
Regards.
01-09-2014 02:04 PM
I second ToeCutter on that. I would rather do the same. Or purchase sbRIO if my application requires more labour.
01-09-2014 02:18 PM
Ok, thanks, ill check again tomorrow and ill update the thread :)!
01-09-2014 05:23 PM
Oh, one more thing- the 'wait ms multiple' in that loop is unnecessary and bad programming form. The loop rate should be determined solely by the analogue write, which should wait until there is sufficient buffer space for a write.
09-28-2014 01:40 AM
Hi...
i need the details of the following link..
https://decibel.ni.com/content/docs/DOC-17537)
is anyone can help?