Mini Maestro 12 with Linux in Matlab 2007a

I’m trying to talk to servos connected to the mini maestro 12 through matlab. I’ve installed the linux version of the maestro control center and I’m able to move the servo manually that way.

I can also see the maestro is connected to /dev/ttyACM0 and /dev/ttyACM1. However, when I try to create a new serial connection in matlab via serial(’/dev/ttyACM0’), I cannot open it.

The code worked fine on windows xp using ‘com3’ in place of ‘/dev/ttyACM0’.

I think this may have something to do with a symbolic link to the ACM0 connection, but I’m not sure. Does anyone know how to make matlab talk to this channel? Thanks.

Hello,

I am sorry that the serial port is not working for you! What happens when you try to open it?

-Paul

Hello I am having the same issue with MATLAB 2009b in Linux kernel 2.6.31. I have been able to get an older Pololu device (16 servo servo controller) to work by following this procedure:

Plugging in the older device --> Linux command prompt:

$ lsusb
Bus 002 Device 024: ID 10c4:803b Cygnal Integrated Products, Inc.

$ dmesg | grep tty
[77078.644447] usb 3-1: cp210x converter now attached to ttyUSB0

Where ttyUSB0 is the device I use for opening the MATLAB serial port with the following code (old_pololu_init):


clc
clear all
close all;

s1 = serial(’/dev/ttyUSB0’ ,‘Baudrate’,9600, …
‘DataBits’,8, …
‘Parity’,‘none’,…
‘InputBufferSize’,16384)

fopen(s1)


which gives me:

Serial Port Object : Serial-/dev/ttyUSB0

Communication Settings
Port: /dev/ttyUSB0
BaudRate: 9600
Terminator: ‘LF’

Communication State
Status: closed
RecordStatus: off

Read/Write State
TransferStatus: idle
BytesAvailable: 0
ValuesReceived: 0
ValuesSent: 0

I can then move the servos from my old pololu device using this command:

fwrite(s1,[128,1,3,0,127,0],‘uint8’)

and varying the last two columns of the uint8 matrix between 0,0 and 127,127
I can move the servo motor
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I have now upgraded to the Pololu Mini Maestro Servo controller. Following a modified version of the procedure above:

Plugging in the Mini Maestro–> Linux command prompt:

$ lsusb
Bus 003 Device 010: ID 1ffb:008c

$ dmesg | grep tty
[149398.188687] cdc_acm 3-1:1.0: ttyACM0: USB ACM device
[149398.200068] cdc_acm 3-1:1.2: ttyACM1: USB ACM device

Where ttyACM0 is the device chosen for opening the MATLAB serial port:


clc
clear all
close all;

s2 = serial(’/dev/ttyACM0’ ,‘Baudrate’,9600, …
‘DataBits’,8, …
‘Parity’,‘none’,…
‘InputBufferSize’,16384)

fopen(s2)


I then get the following output:

Serial Port Object : Serial-/dev/ttyACM0

Communication Settings
Port: /dev/ttyACM0
BaudRate: 9600
Terminator: ‘LF’

Communication State
Status: closed
RecordStatus: off

Read/Write State
TransferStatus: idle
BytesAvailable: 0
ValuesReceived: 0
ValuesSent: 0

??? Error using ==> serial.fopen at 72
Port: /dev/ttyACM0 is not available. No ports are available.
Use INSTRFIND to determine if other instrument objects are connected to the requested device.

Error in ==> mini_maestro_init at 10
fopen(s2)

I am able to get the mini maestro to run with the maestro control center which ensures that my device is working, but I feel that my linux machine is not able to recognize the device because there is no text after the bus device number fro the lsusb call:
Bus 003 Device 010: ID 1ffb:008c
Do you think I need to install a driver to run the mini maestro separate from the Maestro control center?

also from the instrfind command in MATLAB:

when the old code is run it adds a column to the Instrument array. This shows the result of running the mini maestro initialization code:

instrfind

Instrument Object Array

Index: Type: Status: Name:
1 serial closed Serial-/dev/ttyACM0

The next few lines show the output of instrfind after running the initialization code for the older pololu 16 servo motor controller:

instrfind

Instrument Object Array

Index: Type: Status: Name:
1 serial closed Serial-/dev/ttyACM0
2 serial open Serial-/dev/ttyUSB0

ANY SUGGESTIONS?

Hello,

What distribution of linux are you running, and what kind of computer do you have it on?

I do not know much about Matlab, so let’s make sure that you have basic access to the device first. Can you run the commands “ls -l /dev/ttyACM0”, “echo hi > /dev/ttyACM0” and “groups” and post the output and any new information that shows up in dmesg? For example, the device might have not been created correctly, or you might not be in a group with access to it.

-Paul

Paul,
Good idea, thanks! I will try this and get back to you on Monday. I am running Linux Mint 8 (Helena) which is a knock off of the Ubuntu distribution.

I had taken a look at the Pololu software development kit and it was all about building GUI’s to control the device. If am not able to do it in MATLAB, I still want to control the device from source code not GUI.

Thanks!
Steve

output of dmesg when device is plugged in:

62731.724145] usb 3-2: new full speed USB device using uhci_hcd and address 2
[62731.932178] usb 3-2: configuration #1 chosen from 1 choice
[62731.982337] cdc_acm 3-2:1.0: This device cannot do calls on its own. It is not a modem.
[62731.982408] cdc_acm 3-2:1.0: ttyACM0: USB ACM device
[62731.988828] cdc_acm 3-2:1.2: This device cannot do calls on its own. It is not a modem.
[62731.988892] cdc_acm 3-2:1.2: ttyACM1: USB ACM device
[62731.991670] usbcore: registered new interface driver cdc_acm
[62731.991683] cdc_acm: v0.26:USB Abstract Control Model driver for USB modems and ISDN adapters

oem@RoboCat ~ $ ls -l /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0 2011-04-27 10:00 /dev/ttyACM0

oem@RoboCat ~ $ groups
oem adm dialout cdrom plugdev lpadmin admin sambashare

Hello,

Could you also do the “echo hi” test that I suggested?

-Paul

oem@RoboCat / $ echo hi > /dev/ttyACM0
oem@RoboCat / $ echo hi > /dev/ttyACM0
oem@RoboCat / $ echo hi > /dev/ttyACM0
oem@RoboCat / $ echo “hi” > /dev/ttyACM0
oem@RoboCat / $ echo “hi” /dev/ttyACM0
hi /dev/ttyACM0
oem@RoboCat / $ echo hi /dev/ttyACM0
hi /dev/ttyACM0

Did not output anything at first got rid of the quotes and it printed it to the screen??
I’m running this on an embedded computer Sumit-104 made by Ampro (CoreModule 730)

Hello,

It looks like the user “oem” has access to the Maestro’s serial port. Are you running Matlab as “oem” or as some other user?

-Paul

I am running as MATLAB as oem. Was the echo command supposed to give an output? Maybe I should run as the echo command as sudo? I’ll try this with MATLAB too. I can’t remember if I was running MATLAB as sudo or not. Let me check…

Steve

The echo command makes the green light flash regardless of being sudo . MATLAB still does not recognize the device even when opened as sudo (administrator) Do you know how to send a stream of hex values using echo? Anything I can do in the Linux terminal I can do in MATLAB by putting ! before it. I want to gain control of the pololu device by sending hexadecimal streams as in section 5e of the Pololu Maestro Users Manual. Any ideas?

The code from this page is working for python:

[Help controlling Micro Maestro from python / Linux)

This is a start…

Hello,

No, echo does not give any output - it was just a test to make sure that you actually had permission to write to the port. If the Python script works, then you really just have to figure out what that Matlab error means. I would consult Matlab support now if I were you. By the way, do you have normal (non-USB) serial ports that you could try opening instead? Even if there is no Maestro connected to them, it would be nice to see whether they give you the same error or not.

-Paul

Hey paul,

I figured it out!! Unfortunatly I do not have any other serial ports other than the 4 usb port so I googled “matlab not recognizing serial port”

This link had the solution:
mathworks.com/support/soluti … n=1-3ZT8GP

Turns out Linux MATLAB only recognizes serial port names of the form /dev/ttyS[0-255].

The site gave two ways to fix the problem, but the easiest way is just to paste the symbolic link at the top of the MATLAB m-file:

!sudo ln -s /dev/ttyACM0 /dev/ttyS101

[Or this could be called in the Linux Command prompt:
sudo ln -s /dev/ttyACM0 /dev/ttyS101]

Then open the symbolic serial port and run the code…

s2 = serial(’/dev/ttyS101’,…
‘Baudrate’,9600, …
‘DataBits’,8, …
‘Parity’,‘none’, …
‘InputBufferSize’,16384)

fopen(s2)
fwrite(s2,[170,12,4,0,112,46],‘uint8’)
fclose(s2)

Thanks for the help!

Great! Thanks for posting the solution.

-Paul