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

6 ビュー (過去 30 日間)
Joachim Brodin
Joachim Brodin 2018 年 9 月 4 日
編集済み: Joachim Brodin 2018 年 9 月 4 日
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 件)

コミュニティ

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by