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

7 visualizaciones (últimos 30 días)
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

Respuestas (0)

Comunidades de usuarios

Más respuestas en  Power Electronics Control

Categorías

Más información sobre Data Import and Export en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by