LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Interfacing with Parallax servo controller -USB

I am trying to run the Parallax USB servo controller directly thru LabView, and stuck. I’m not very familiar with USB controls and commands, so help would need to come at a very basic level.

 I know the servo and controller are both working, as I can control them with Parallax’s software in real time. This means commands are being successfully sent via the USB cable.

The USB version of the controller comes with its own software, but that doesn’t help, so I looked for the manual for the older serial version, and DL’d the manual. I’ve  also downloaded the vi examples that are found at parallax.

http://www.parallax.com/dl/sw/labviewbs2.pdf

 

The problem is that the assumption is that the Servo Controller is receiving commands from a Basic Stamp, such as the Board Of Education. I need to address the SC without the middle-man, which I know is possible because the software for the PSC-usb lets me do just that.

I understand the SYNTAX of the examples in the manual, but am having problems with how its sending to the controller.

What I’ve tried:

 

If I use a terminal emulator, like RealTerm, if I send

!SCVER?

With a terminal carriage return, I get the version number.


If I set the input text in the labview program to “Code” (as suggested in an earlier post here) and type



!SCVER?\r

The Read Window outputs

!SCVER?
1.4


Which is somewhat confusing, but livable. It’s acting like it’s echoing the SEND string, as well as reading the actual output from PSCusb. Also, I set the VISA configure to send a terminal carriage return automatically, but still need to manually input the \r.


BUT when I try to enter commands that require more than one piece of information, like reading servo location or setting servo position, I get no response.

The examples in the manual give the commands as

[“!SC”, channel, rate, lowbyte, highbyte, CarriageReturn]

 

So, to send the servo from position 250 to position 1250 (one extreme to the other) with no delay on channel zero, the command string should be something like

!SC 0 0 250 1250 \r

 


I have tried all different combinations of spaces, quotes, commas, etc. and its still not getting the servo to move. I assume that there is some way that the BasicStamp software breaks up the commands. Clearly I can’t send

 


!SC002501250\r

 


As it wouldn’t be able to tell where channel stopped and rate started.

 


So, what do I need to do in order to get this thing to move? Do I need to send each parameter individually?  Any help would be greatly appreciated. I’m pretty sure if someone knows how to this with a terminal, I can make it work in labview.

Sincere Thanks!

0 Kudos
Message 1 of 22
(8,984 Views)
Hi da_stuart,
From what I gather, the command to move the servo also does not work in RealTerm either. No?
I am not familiar with that controller, but if you have a copy of "Serial Comm.vi", post it here.  I am curious to see what's going on in there, and how the commands are being sent. It does seem to me from the screenshot on the PDF that it's sending commands one at a time. You could try that and see what happens.

Thanks!
Ebele O.
National Instruments
0 Kudos
Message 2 of 22
(8,964 Views)
So, I finally figured out how to make things go! I'd been down with the flu and had more time than work usually allows for this project, so here is what I found out.
 
Clue 1 was that I could get the servo to move as advertised in a terminal emulator if i sent
 

33 83 67 0 0 222 4 13

 

as numbers, (with spaces enabled). 33 83 67 corresponding to !SC (the preamble) and 13 to carrage return.

 

After tinkering in LabView for a while, I wrote a program to automatically convert into high and low byte values from a given input. Im sure there is an easier way, but this worked for me.

 

I then built several small programs trying to figure out how to parse that number string in the VISA control. LabView being very precice kept sending the spaces as a space (\s), and if they were ommitted, sending the text as one big string. Finally, I figured out that it would work if I sent the values from an ARRAY that was converted into a text string using the Byte Array to String Conversion. Once that was in place, it was easy to add controls that replaced values in the array on the fly using control knobs and sliders.

 

The final program (posted) will let you adjust the servo channel, rate, and position on the fly. It should be fairly easy to adapt this to multiple servos, or to sequential programmed motion. I think this is enough to answer a LOT of people's questions and desires to have something like this!

0 Kudos
Message 3 of 22
(8,949 Views)

I am having problems using your VI for the servo controller. I am currently using the VCP drivers for the FTDI usb to serial converter chip (www.ftdichip.com). I am using labview8 student edition.

 

I have removed the shunt jumper to configure the controller for servos 0-15, and can control it from the parallax software. If I send the controller !SCVER? with the parallax basic stamp debugger, I receive the expected 1.4 version number, however I can't get a response when sending 33 83 67 0 0 222 4 13 from the debug window (it also doesn’t work when sending 33 83 67 0 0 222 4 and then a carriage return from a macro).

 

When I try to use your VI, I can't get the servos to move when sending at 2400 baud. I am configured to have the servo controller recognized as COM4, and this is detected in the pull down box.

 

The sent string window in the VI does not display a string, so it is probably not being sent. I am confused about the bytes you are sending. You say that you are trying to send [“!SC”, channel, rate, lowbyte, highbyte, CarriageReturn], however I can't find where the “!SC” and CarriageReturn are being sent.

 

I tried modifying the VI(attached) to include the numeric bytes for “!SC” and CarriageReturn but It till won't display the sent string, do you know why this isn't working?

 

Thanks,

Andrew Seltzman

Andrew Seltzman
0 Kudos
Message 4 of 22
(8,838 Views)

I got servo communication to work by replacing the empty array in the original VI with a string constant, casting the string to a byte array, replacing the required byte and casting it back to a string.

 

I am now having a problem with array indexing in the for loop. I want to use a cluster containing the position values for all 16 servos as an input, and use a feedback node to compare the current value of a position to that of the position value during the last iteration of the loop. I want to transmit the value to the servo controller only if it has changed since the last iteration. The problem is that while the not= function set on compare elements produces the correct array containing T/F depending on whether the value has changed, when I try to index the array, only the first element (servo 0) is sent to the case structure, and consequently only the first servo can be controlled. If the VI is rewired so that the case structure is always true, all servos van be controlled, however the update is slow due to the low rate of continuous data transmission of needless updates (the 50ms delay is there in the VI so that I can see the data values on the probe output, without it is slow to).

 

My question is why is only the first element of the Boolean array indexed? How can I fix this?

 

I don't want to use an event structure since the front panel sliders are only for testing purposes and I don’t want to really on front panel events to update the servo positions, the only thing that I can depend on is checking whether the data on the input changes. For refference, this is going to be built into a VI that only takes the com port and cluster as inputs.

 
Is there a way to use an event structure in this way to detect if a data value changes?
 
 
This was written in LV8 student, there is an attached picture for those with LV7.
 
 
 
 
Andrew Seltzman
Download All
0 Kudos
Message 5 of 22
(8,812 Views)

This thread is kind of old but I have a couple of questions about this servo controller. I am using usb parallax servo controler with the board of education but i don't want to use the Basic stamp  editor. With the code written are you bypassing the board of education and plugging into the servo controller? And also is there a good resource that you used to get visa to assign USB ports? Every time i try to assign a USB port i can't use any of the other USB ports.


thanks,

Eric
0 Kudos
Message 6 of 22
(8,689 Views)
This code controls the servo controler directly over the USB port. The servo controler containss an USB to serial converter on board, when plugged into the computer it should show up as a serial port (port number can be changed under control panel), and can be used with the VISA Serial interface. You may need to download the FTDI drivers for the USB to Serial converter chip for the computer to recognize it.
 
I used the VCP version of the drivers.
 
Attached is a copy of a fully operational servo controler program for LV8. The problem in the previous one was that the feedback node was inside the for loop.
 

Message Edited by Seltzman on 09-21-2006 04:53 PM

Andrew Seltzman
Download All
0 Kudos
Message 7 of 22
(8,676 Views)
Andrew,

I can't get your program to work. What servo controller did you use, the 28823? And did you have any problem setting it up? I try to send and the green LED lights up while i'm sending, but nothing happens. Any ideas would be a great help.

thanks,

Eric
0 Kudos
Message 8 of 22
(8,656 Views)
I had the exact problem when I first hooked up mine. It turns out that the factory default is to have the selection jumper(under the reset switch) address the servos as 16-32 instead of 0-15. You will need to remove it to address the first 16 channels. Then the controller should work.

Message Edited by Seltzman on 09-23-2006 12:18 AM

Andrew Seltzman
Message 9 of 22
(8,654 Views)
Thank you for your help Andrew, i  got the servo contoller to work and haven't had any problems yet. I was just wondering if you had written a program to verify the servo postion?

thanks again,

eric utter
0 Kudos
Message 10 of 22
(8,616 Views)