Simultaneous control of two step motors via usb-serial controller unit from Applied Motion

조회 수: 8 (최근 30일)
I run the script under. When I comment out one or the other, of the motors, the script works fine, but when I try with both the script hangs and Matlab goes into a busy mode that no ctrl+c or other kill method can break. Matlab can then not even be closed, nor the OS - I actually have to force-quit with the power button. Suggestions?
s1=serial('/dev/tty.usbserial','Terminator','CR');
s2=serial('/dev/tty.usbserial4','Terminator','CR');
fopen(s1)
fopen(s2)
fprintf(s1, '%s\r', 'HR');
fprintf(s1, '%s\r', 'SK');
fprintf(s2, '%s\r', 'HR');
fprintf(s2, '%s\r', 'SK');
fprintf(s1, '%s\r', 'AC1'); %sets acceleration rate to 1 rev/sec/sec
fprintf(s1, '%s\r', 'DE1'); %sets decelleration rate to 1 rev/sec/sec/sec
fprintf(s2, '%s\r', 'AC1'); %sets acceleration rate to 1 rev/sec/sec
fprintf(s2, '%s\r', 'DE1'); %sets decelleration rate to 1 rev/sec/sec/sec
fprintf(s1, '%s\r', 'VE1'); %velocity to 1 rev/sec
fprintf(s1, '%s\r', 'FL10000'); %moves 10000 steps clockwise
fprintf(s2, '%s\r', 'VE1'); %velocity to 1 rev/sec
fprintf(s2, '%s\r', 'FL10000'); %moves 10000 steps clockwise
fprintf(s1, '%s\r', 'VE1'); %velocity set to 1 rev/sec
fprintf(s1, '%s\r', 'FL-10000'); %moves 10000 steps counter clockwise
fprintf(s2, '%s\r', 'VE1'); %velocity set to 1 rev/sec
fprintf(s2, '%s\r', 'FL-10000'); %moves 10000 steps counter clockwise
fclose(s1)
fclose(s2)
delete(s1)
delete(s2)
clear s1
clear s2

답변 (0개)

커뮤니티

더 많은 답변 보기:  Power Electronics Community

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by