Problem with the number of successive serial commands (fprintf())
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I am having a problem with the number of successive serial commands (fprintf())sent through a USB serial port. I am doing a project where I have to send a number of commands to move two stepper motors into specified coordinates. The motion controller I am using is a JAF motion controller (<http://www.jafmotion.co.uk/)>.
The code below is executed after pressing a button on a MATLAB GUI:
if true
s = serial(‘COM4′);
fopen(s);
fprintf(s, '-3262 -1920;');
fprintf(s,'PD4000;');
fprintf(s, '-5234 -1231;');
fprintf(s,'PD4000;');
fprintf(s, '-5123 -5122;');
fprintf(s,'PD4000;');
fprintf(s, '-9872 -1221;');
fprintf(s,'PD4000;');
fprintf(s, '-5123 -7272;');
fprintf(s,'PD4000;');
...
fclose(s);
end
The numbers inside the brackets are the coordinate system specified by JAF.
The problem is that the stepper motors only move to a particular point (Say -5123, -5122) and then stop. Any number of successive fprintf() commands below 16 seem to work but any fprintf() statements after the 16th one don't do anything.
I am pretty sure this is a software problem, not hardware. I have tried changing the input and output buffer sizes to 1024 (default is 512) but no effect.
Any ideas why this is happening?
Thanks a lot !
Regards,
Mo
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!