MATLAB 64 bit Rotary Stage Control Problems

235 views
Skip to first unread message

Ed Kelley

unread,
Jan 9, 2013, 11:40:00 AM1/9/13
to velmex-...@googlegroups.com
Hello all,

Having some problems running VMX and large rotary stage with MATLAB:

1. COM Port: In attempting the instructions for running MinimumCodeToMoveMotor.m the MATLAB software didn't work after a fresh warm boot. I noticed that the PortOpen command default was set to COM1. After changing to ComPort 7 it still doesn't work (NOTE: You never say to change to COM7 or any other number, you don't say how to tell what ComPort is being used either, might help in the instructions). Was that the correct thing to do?

2. Next, when attempting to run the software:
>> MinimumCodeToMoveMotor
Error using calllib
Library was not found

Error in DriverTerminalShowState (line 6)
calllib('VxmDriver', 'ShowTerminalSimple', ParentHwnd)

Error in MinimumCodeToMoveMotor (line 7)
DriverTerminalShowState(1, 0) %Show Terminal on Desktop
>>

3. I tried to the load-driver command directly:
>> LoadDriver
Error using loadlibrary (line 254)
A 'Selected' compiler was not found. You may need to run mex
-setup.

Error in LoadDriver (line 2)
LoadDriver = loadlibrary('VxmDriver', 'VxmDriver.h')
>>

Any ideas?

COMPUTER: Windows 7 Ultimate 64 bit i7 processor at 1.6 GHz
SOFTWARE: MATLAB 8, 64 bit
Velmex software works (COM7): VMX (with analog joystick) and rotary stage.

Thanks, --Ed

Charles Emrick

unread,
Jan 9, 2013, 1:03:52 PM1/9/13
to velmex-...@googlegroups.com
Hi Ed,
One thing that I see is that you are trying to use the VXM driver with 64bit Matlab, but the driver is 32bit so it will not work.

I know Cliff has been working on a 64bit version but it could be quite some time. One work-around he gave me was to use Matlab's own intrinsic commands to control a serial port
http://www.mathworks.com/help/matlab/ref/serial.html

It should be pretty straight forward to open the port, send Vxm commands and then close the port.

In your case the settings you will need are
Port: Com7
Baud: 9600
Data-Bits: 8
Parity: None
Stop-Bits: 1

From there if you send a capital "V" then wait 100ms and read back the port you should get back one of the following characters. "R,J,B,b"

From there you should be able to send VXM commands and have it react.

(Oh and make sure COSMOS is closed when you try to open the port from Matlab or you will not be able to take control of the port)

Ed Kelley

unread,
Jan 9, 2013, 7:19:04 PM1/9/13
to velmex-...@googlegroups.com
Thanks, Charles, for the quick feedback. It works! Why bother with anything else? If you could quickly look at the following code, which works, and make any suggestions, it would be appreciated. Am I on the right track or am I making some egregious mistake?

vmxp=serial('COM7','BaudRate',9600,'DataBits',8,'Parity','None','StopBits',1);
%get(vmxp,{'Type','Name','Port','BaudRate','DataBits','Parity','StopBits'})
fopen(vmxp)
fprintf(vmxp,'V')
out=fscanf(vmxp,'%c',1)
fprintf(vmxp,'F C I1M400, R')
pause(1);
out=fscanf(vmxp,'%c',1)
fprintf(vmxp,'F C I1M400, R')
out=fscanf(vmxp,'%c',1)
fprintf(vmxp,'Q')
fclose(vmxp)

And joystick operation returns.

VelmexControls

unread,
Jan 9, 2013, 7:51:09 PM1/9/13
to velmex-...@googlegroups.com
Charlie knows better than I but since the move is short is should be ok. (If I look at it as "Pseudo-Code" cause each language has its own quirks)
and the code looks like what I used to know (C or C++ back in the day)

not sure about the order though but the way I read it is
vmxp=serial('COM7','BaudRate',9600,'DataBits',8,'Parity','None','StopBits',1);      ;<--- Initialize a variable to what port is to be opened and its parameters
%get(vmxp,{'Type','Name','Port','BaudRate','DataBits','Parity','StopBits'})             ;<--- Either get whats at the port? or get the paramaters?
fopen(vmxp)                                                                                                 ;<---- Open the port
fprintf(vmxp,'V')                                                                                             ;<---- Send the Verify command to see if you are communicating
                                                                                                                  ;<---- I would add a time delay cause Windows will not return immediately (100ms should suffice)
                                                                                                                  ;<---- Unless of course fscanf is a "blocking-call" that will NOT return until it gets an answer???
out=fscanf(vmxp,'%c',1)                                                                                ;<---- Scan the port for 1 character
fprintf(vmxp,'F C I1M400, R')                                                                          ;<---- Send VXM commands
pause(1);                                                                                                     ;<---- Pause (Guessing 1ms???)
out=fscanf(vmxp,'%c',1)                                                                                ;<---- Read the Response Character
                                                                                                                  ;<---- Later in debugging you may want to examine what the response was? but for 1st moves this is OK
fprintf(vmxp,'F C I1M400, R')                                                                          ;<---- Send Next command
out=fscanf(vmxp,'%c',1)
fprintf(vmxp,'Q')                                                                                            ;<---- Bring VXM Offline again (so that Jogs will work)
fclose(vmxp)                                                                                                ;<---- Close the Port


All in all a nice beginning sequence *G*

Forgive my comments, but I am not a C programmer nor a Matlab Programmer so I just read it the best that I could *S*

Ed Kelley

unread,
Jan 10, 2013, 2:15:26 PM1/10/13
to velmex-...@googlegroups.com
Yup, you read it correctly. Pause is for 1 s. OK I'm off and running. Thanks for pointing me in the correct direction.
Reply all
Reply to author
Forward
0 new messages