필터 지우기
필터 지우기

problem in sending serial data to monochromator controller

조회 수: 3 (최근 30일)
Shailendra
Shailendra 2014년 1월 17일
답변: Shailendra 2014년 1월 21일
I have a AMS DCB-241 Stepper motor controller controlling the Monochromator's grating motion.
I am trying to automate this system with MATLAB, i am using serial communication port USB-SIN11 adapter cable to connect computer to the controller.
With the propitiatory software commands like ex. '-1000' (move the grating to 1000nm clockwise), '+1000' move the grating to 0th positing anticlock wise) 'V=1000' (slew speed 1000 steps/s) etc...
When i send these commands through the Matlab code, Controller is NOT responding by moving the stepper motor in the monochormator.
Can you please help me out in resolving ths issue? Is there a problem with the code?
Kindly do the needful and oblige.
Here is the mat lab code i wrote:
s1 = serial ('com3', 'BaudRate', 9600, 'DataBits', 8);
fopen(s1);
fprintf (s1, 'i=50');
fprintf (s1, 'k=100,100');
fprintf (s1, 'v=1000');
fprintf (s1, '-8908');
pause (20);
fprintf (s1, '-213');
pause (10);
fprintf (s1, '-240');
pause (10);
fprintf (s1, '-133');
pause (10);
fprintf (s1, '+9494');
pause (20);
fclose(s1);
delete(s1);
Thanks in advance

채택된 답변

Walter Roberson
Walter Roberson 2014년 1월 17일
The documentation for the device indicates that you need to set hardware flow control.
I also see that it needs a Terminator of CR. At the moment I do not see documented what the default terminator is, so it would be best to specify it specifically
'Terminator', 'CR'

추가 답변 (1개)

Shailendra
Shailendra 2014년 1월 21일
Thank you very much for your help. I included 'FlowControl', 'hardware' &'Terminator','CR' also " fprintf (s1, ' '); " command, this 'spacebar' starts up the program.
I could solve the problem :)
Below is my modified Matlab program.
delete(s1);
s1 = serial ('com3', 'BaudRate', 9600, 'DataBits', 8, 'Parity', 'none','StopBits', 1, 'FlowControl', 'hardware','Terminator','CR');
set (s1, 'BaudRate', 9600, 'DataBits', 8, 'Parity', 'none','StopBits', 1, 'FlowControl', 'hardware', 'Terminator','CR');
fopen(s1);
out = instrfind(s1)
fprintf (s1, ' '); % ' ' (spacebar) for start-up
pause (5);
fprintf (s1, 'I=50'); % initial velocity = 50
pause (5);
fprintf (s1, 'K=100,100'); % Ramp slope, ascending = 100, descending = 100
pause (5);
fprintf (s1, 'V=1000'); % Slew Velocity = 1000
pause (5);
fprintf (s1, '-8908'); % move monochromator grating to 3335 nm wavelength
pause (20); % Delay of 20 S for the grating to move
fprintf (s1, '-213'); % move monochromator grating to 3415 nm wavelength
pause (10); % Delay of 10 S for the grating to move
fprintf (s1, '-240'); % move monochromator grating to 3505 nm wavelength
pause (10); % Delay of 10 S for the grating to move
fprintf (s1, '-133'); % move monochromator grating to 3555 nm wavelength
pause (10); % Delay of 10 S for the grating to move
fprintf (s1, '+9494'); % move monochromator grating to 0th location
pause (20); % Delay of 20 S for the grating to move
fclose(s1);
out = instrfind(s1)
delete(s1)
out = instrfind(s1) % Close the port S1

카테고리

Help CenterFile Exchange에서 Serial and USB Communication에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by