Matlab/Simulink and Barrett WAM

  • Presented at NEMS 2010 [ pdf ]

The Robotics Department at University of New Mexico (Professor Greg Starr, Matt Courtney) has developed Simulink models in Matlab for controlling the WAM arm. They have passed the code off to us and the following are some things to note while getting the software set up and running.

xPC Target Machine (attached to WAM via CAN PCI card, Serial cable/COM port)

  • Need to boot small Matlab kernel via CD or floppy disk
  • Very fast kernel, but does not have support for many hardware drivers (only supports some Softing CAN cards)
  • The one we have built is a Dell Optiplex GX260 with Intel PILA8460M (Ethernet card) and Softing CAN-AC2-PCI (CAN card)
  • Be sure to disable legacy USB support in the BIOS

Creating the xPC Target Boot CD
In Matlab, run the "xpcexplr" command. Use the following communication settings for your target PC:
  • IP Address: 192.168.1.10
  • Subnet Mask: 255.255.255.0
  • Gateway: 192.168.1.1 (you could also use 192.168.1.11 here - the host address - as long as packets are somehow routed to the host machine)
  • Target Port: 22222 (can be any unused port number)
  • Target Driver: I82559 (depends on the chipset of your ethernet card, in our case Intel 82551QM uses this driver; check the Matlab Docs)
  • Target Bus: PCI

Now that this is set up, click "Apply". Click "Configuration", go to the "CD Boot" tab, and create a CD image which you will boot on the target machine. Once you create the CD, insert it in the target machine and boot from it. If you see a hard drive error, notice that this is not a fatal error. However, in order to capture any data you will have to install an FAT32 partition on the hard disk.

xPC Host Machine (i.e. your laptop)

  • Must have Matlab installed with Realtime Workshop, xPC Target, Simulink, and a C Compiler (Open Watcom is a great choice here; full list is available at the link at the bottom)
  • Note: As of Matlab version 2009b, Mathworks only has an xPC Target package for 32-bit Windows

Running a Virtual Machine
As noted above, you must be running 32-bit Windows to have the xPC Target package. If you prefer to use Ubuntu as your primary operating system, you can set up a virtual machine to run Windows. Because a steady connection between the host and target is very critical, this is not the recommended setup. However, I have been using it with no issues for a few months now.

Setting up Networking in Ubuntu (using a virtual machine)
In Ubuntu, add a new wired connection called "Wired WAM". This is for the private network between you and the xPC target machine. Use the same MAC address as "Wired eth0", but assign a static IP of 192.168.1.11 (this can really be anything except .1, .10). Set the netmask and gateway to 255.255.255.0 and 192.168.1.1 respectively. Click the Routes button and check the box that says "Use this connection only for resources on its network". That will allow you to have internet access using your other connection (i.e. wireless).

Make sure you have VirtualBox configured to give Windows one network adapter using NAT. No more configuration is required once you boot up Windows, since VirtualBox will assign it a private IP address automatically.

Setting up Networking in Windows
You need two NIC cards as explained in the previous section. One acts as your internet connection, while the other is a private network between the host and target machines.

Connecting the host and target PC
A switch is ideal for setting up the private network between the target and host PC. In our case, we are using a router but this is not necessary and may even add a bit of overhead. Connect both the host and target to the switch ports. Do not connect the switch to the campus network - you will not be able to get it going over the campus network since Matlab uses a lot of bandwidth transferring data between your laptop and the xPC Target machine.

You should now be able to ping the target PC (192.168.1.10) from the host running Windows.

External Links

Topic attachments
I Attachment Action Size Date Who Comment
pdfpdf nems_matlab_wam.pdf manage 502.2 K 2011-05-10 - 15:47 JohnBehmer  
elseindd poster.indd manage 2644.0 K 2011-04-01 - 00:33 JohnBehmer  
pdfpdf poster.pdf manage 1518.8 K 2011-03-31 - 23:54 JohnBehmer  
Topic revision: r8 - 2011-05-10 - 15:49:47 - JohnBehmer
 
Copyright © 1824-2009 Rensselaer Polytechnic Institute (RPI)
110 Eighth Street, Troy, NY USA 12180 (518) 276-8326