03-30-2016 03:07 PM
Hi everyone,
I'm running an experiment to measure the loads on a wing. Until recently, the wing was actuated by a simple RC motor (see here), but now I want to run the experiment with a Dynamixel AX-12 "smart" servo for finer control and more feedback. However, I'm not quite sure what the best method is for controlling the Dynamixel AX-12.
The AX-12 uses asynchronous TTL serial to communicate back/forth with a controlling device. I can control the servo with an Arbotix-M microcontroller, and I can program the microcontroller through the Arduino IDE. However, after reading this NI example, it looks like I can control the servo directly through my PC--no microcontroller necessary. I'm guessing the white paper uses this USB dongle, but before I chase serial control through a dongle+low-level serial commands, I wanted to see if NI has more "elegant" solutions to this problem.
Specifically, are there any serial add-ons or toolboxes that I can use with CDAQ devices for high-level smart servo control? Something like Linx for servos. Or do I have to "manually" parse serial commands to transfer data to/from front panel to data packets?
Thanks
03-31-2016 12:38 PM
Hi aeroAggie,
Thanks for posting in the NI Discussion forums to get an answer with your servo control question! I totally agree that you can control your servo directly through your PC with LabVIEW- no microcontroller required. You could actually contorl up to 254 of them, it looks like. Additionally, it doesn't look like you'll need the USB dongle you referenced. You should be able to connect directly through a COM port in your computer, unless of course you'd prefer to use your USB port for the commumications.
As far as a more elegant solution to the problem, what functionality are you looking for? I know there isn't a cDAQ module for Serial communications, but there is a cRIO option if that interests you (the cRIO 9870) whic, if you wanted to do closed loop control on your servos, may be a valuable option.
Otherwise, the example provides the option to queue up multiple commands for multiple Dynamixels. It stands to reason that you could input multiple commands for one Dynamixle and faux-automate the movements of the servos. Or, you could implement some timing mechanism for the larger outer while loop that would send a command to the servo, wait until you are ready to move on, and then send the next command you've queued up.
Let me know if this information helps or if you have any other questions!
04-07-2016 04:54 PM
Austin,
I apologize for the radio silence, and thank you for the response.
Last week, a friend helped me realize that the $50 "USB2Dynamixel" cable was nothing more than a plain FTDI cable with the RX/TX lines going to/from the USB device connected together*, so I just used bought a FTDI cable from Sparkfun and used that to control my servo. Now I just need to program a "read" function to the VI provided in NI's Dynamixel white paper so I can get "actual" position feedback.
*Detailed explanation for forum posterity: Dynamixel's servos use an asynchronous serial protocol to communicate (read this primer for more info). Essentially, this means that the servos send and receive comm signals on the same line. Therefore, all you have to do to communicate with a servo using a FTDI cable is connect the servo's "signal" port to the FTDI's TX and RX line. That way, your PC will receive Dynamixel's signals on the RX line and the servo will receive PC commands from the TX line.
04-08-2016 02:21 PM
Hey aeroAggie,
No worries on the response time. Glad to hear that you have a good hardware solution to the FTDI cabling. As far as the "read" function you're programming, do you feel like you have a good handle on what that would look like, as well as how you might program that with NI VISA commands? Are you still sending bytes serially on the Tx and Rx lines asynchronously?
04-10-2016 02:04 PM - edited 04-10-2016 02:29 PM
Austin,
Thanks for the follow up. I didn't have a good handle, but experimentation has led to a better handle, and now I'm very close to solving my problem.
I've created a program (feedback_control.vi) that does 2 things:
Note, I define "command" as a packet written to the servo using Visa Write.
I've tested part 1 through a couple angles, and it works well. I even deactivated part 2 and ran part 1 inside a while loop, and again I got the response I expected. Ultimately, I want to run feedback_control inside a while loop, so this is good. However, I'm stuck on how to implement serial reading.
In a separate program (50_deg_write_then_read), I successfully wrote a 50 degree command to the servo followed by a read command, but I had to wait 1 second before Visa Read would output the servo's response to the read command. Furthermore, VISA Read's output also included the 50-degree write command, the read command, the servo's status response to the 50-degree write command, and the servo's response to the read command---when I only want the response to the read command. I've pasted the response into a comment in 50_deg_write_then_read.vi, so see that if this sentence didn't make sense.
My questions for you:
I'd appreciate any and all help. Also, this has morphed into more of Serial-related post, so feel free to move it to that forum (if you have the permission). If not, can I just post a link to this thread in that subforum?
Attached:
Edit: In case you need it, here is the servo's manual.
04-11-2016 05:58 PM - edited 04-11-2016 05:59 PM
Hey aeroAggie,
At first glance, I'm thinking this may be an issue of the status packets being read along with the actual data you're looking for. On page 19/20 of the manual, it describes the write functionality, and then says, "Because it was transmitted with a Broadcast ID (0XFE), no status packets are returned." I think because you're writing to ID 1 (presumably your first drive) each write command returns a status packet, along with the read command with a status packet. This is why you see all 3 commands coming back when you read every byte at port. Try either implementing a read after every write (to read the statuses of each write), or sending everything via broadcast ID.
As far as the timing you're seeing, there's nothing apparant to me that would slow down your communications. I would recommend using NI IO Trace to record what data is being sent serially and observing the timestamps to see how fast LabVIEW and your device are sending data across the serial port (see http://digital.ni.com/public.nsf/allkb/282C5D41E2BA04F2862574BA007803B9)
Because this still relates directly to your servo control, we can leave it in the Motion board for now 🙂
Try these two suggestions out and see if that helps!