Using a Smart Motor with Matlab
조회 수: 4 (최근 30일)
이전 댓글 표시
I have a Smart Motor made my Animatics (www.animatics.com). They have examples of how to control it using a COM object in C++ and Visual Basic. I have tried using the actxserver function but to no avail.
The VB sample is as follows:
Sub EngineUserSub()
On Error GoTo ErrorHandler:
' Create an instance of SMIHost object
Dim CommInterface As SMIHost
Set CommInterface = New SMIHost
CommInterface.OpenPort(“COM1”)
n = CommInterface.AddressMotorChain
‘ Send a command and get response
CommInterface.DefaultMotor = 1
CommInterface.WriteCommand(“RSP”)
Dim Response As String
Response = CommInterface.ReadResponse
MsgBox(Response)
If anyone has accomplished this or has any insight, it would be greatly appreciated.
Thank you, Ryan
댓글 수: 0
답변 (1개)
Daniel
2014년 4월 10일
편집: Daniel
2014년 4월 10일
The following may be helpful:
Note: a space acts as a delimiter for commands sent to the motor
function openmoveclose(x)
%open the serial port COM1
%apply the displacement x (in steps)
%close the port
% choose the serial port COM1
s = serial('COM1');
% set all the properties of the port
s.BaudRate = 9600;
s.DataBits = 8;
s.Terminator = 'LF/CR';
s.RequestToSend = 'off';
s.FlowControl = 'software';
s.DataTerminalReady = 'off';
s.parity = 'none';
%open the port
fopen(s);
%apply displacement
%allow 5ms second for initialization => prevent 'fuzzy' dismissal of the command
%clear the board memory
%remove hardware limits, set velocity and acceleration
preamble = ['EIGN(2) EIGN(3) ZS a=0 AT=9000 VT=283032 END'];
command = ['WAIT=5' ' ' 'PT=' int2str(sign(x)*round(abs(x))) ' ' 'G'];
fprintf(s,preamble);
fprintf(s,command);
%close the port
fclose(s);
delete(s)
clear s;
end
댓글 수: 0
커뮤니티
더 많은 답변 보기: Power Electronics Community
참고 항목
카테고리
Help Center 및 File Exchange에서 Use COM Objects in MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!