Simultaneous control of two step motors via usb-serial controller unit from Applied Motion
5 次查看(过去 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 个评论
回答(0 个)
社区
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Export 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!