From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

Servo motor control using only LabView

Hello,

Im a 2nd year physics student front The Netherlands.
I've god an assignment at the moment where we have tot balance a ball on a plate. I created a VI that Can motiontrack a ball on a plate, but now I need a way to move the plate. So I bought 2 servomotors and they are harder to program in Labview than I thought. The first thing I would like to make is a VI that can just make the servo move to a certain point. I know the basics of how servo motors work zo thats nog the issue. The problemen is making the werking VI.

Things im currently using:

Parallax servo motor (non continious)
Labview 2012 student idition (could use full version if needed)
Ni USB x series 6341 for the control of the servo.

Anyone able to help me with how to start? Maybe even help a little of coding?

Thanks in advance!

Thomas
0 Kudos
Message 1 of 11
(17,852 Views)
Sorry for the bad english, autocorrect on phones :p..
0 Kudos
Message 2 of 11
(17,834 Views)

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.


Message 3 of 11
(17,816 Views)

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?

 

 

Message 4 of 11
(17,812 Views)

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.

 

 

Message 5 of 11
(17,793 Views)

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.


0 Kudos
Message 6 of 11
(17,788 Views)

I second ToeCutter on that. I would rather do the same. Or purchase sbRIO if my application requires more labour. Smiley Tongue



0 Kudos
Message 7 of 11
(17,781 Views)

Ok, thanks, ill check again tomorrow and ill update the thread :)!

0 Kudos
Message 8 of 11
(17,771 Views)

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.

0 Kudos
Message 9 of 11
(17,742 Views)

Hi...

 

i need the details of the following link.. 

 

https://decibel.ni.com/content/docs/DOC-17537)

 

is anyone can help?

0 Kudos
Message 10 of 11
(17,027 Views)