LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to adjust a servo's position thru RS232 using a slider (multiple servos simultaneously)?

Hi everyone,
 
I need to control 4 servos using RS232 and a controller board (COM1 only).  One of the first things to do is to position each servo manually with a slider control.  Therefore I have 4 slider controls to position each servo.  I would like to move from slider1 to slider2, 3 and 4 at any time without causing any communication issues (COM1) by openning and closing this port as many times as required.
 
One way could be to set focus at each slider to allow me to change the position when mouse is over the slider control, then quit and close the port when mouse is away from this control.  Then repeat the same process for the rest of the servos.  Is this approach feasible?  I am not familiar with events and I will really appreacite any guidelines, ideas or sample code.  I am using LV 7.1.  Thanks,
 
Frank
 
PS. I have attached a simple vi that shows some aspects of this idea.
 
 
0 Kudos
Message 1 of 8
(3,448 Views)
Why would you choose the open and close the COM port. Are all device connected to the same COM port at the same time? Or are you changing the connector all the time, in that case why not by a 4 port serial card.

You could indeed use the event structure to determine which slider has focus and then connect to that servo and set the value.
Regards,
André (CLA, CLED)
0 Kudos
Message 2 of 8
(3,432 Views)

Hi André,

All 4 servos are connected to a servo controller card (COM1) and by using #0, #1, #2 and #3 at the start of the string command, I can select the proper servo.

What I need is a method to adjust each servo's position one at the time using some form of slider control (mouse control).   I am not sure if I need to open and close the COM port each time that I perform an adjustment, but I need to prevent open/closing a port that has been previously open or close by a prior servo adjustment.

In regard to your comment: "You could indeed use the event structure to determine which slider has focus and then connect to that servo and set the value."

Would you mind to modify my previous attached vi to accomodate your suggested approach for one servo only and I could expand from there.  Thanks,

Frank,

 

0 Kudos
Message 3 of 8
(3,411 Views)
Hey Frank,

If all 4 of your servos are connected to the same COMM port, and are controlled separately by 4 different commands, then there is no need to keep opening and closing the port. Just open it at the beginning of your program, and close it when you exit the program.

Then, I would suggest opening the example "Top Level Application Using Events" as your starting point. Add your 4 sliders to one event, (you can have multiple controls for the same event). Create 4 "References" for the sliders, and compare them with the "ctlref" for that event. Use a case stucture to determine which slider was changed, and send the proper command.

I'll see if I can create an example of what I mean.

B-)
0 Kudos
Message 4 of 8
(3,402 Views)
Here's what I mean...

However, it only sends one command at a time. You didn't say if your servo controller requires all 4 commands at once. If so, then you can remove the case structures and concatenate all 4 slider values into one string.







Message Edited by LabViewGuruWannabe on 11-15-2007 01:05 PM
Download All
Message 5 of 8
(3,395 Views)
Thanks LabViewGuruWannabe for your input and sample code . . . Could it be possible to convert this vi to 7.1?  Thanks  again,
 
Frank
 
0 Kudos
Message 6 of 8
(3,379 Views)
I can only go back to 8.0. Perhaps someone else on this board can convert it for you.

I hope I've helped.

B-)
0 Kudos
Message 7 of 8
(3,359 Views)
Hi B,
 
I have tried this code and works great!   This is exactly what I was looking for.  Thanks very much for your help! Smiley Wink
 
Frank
 
0 Kudos
Message 8 of 8
(3,353 Views)