I am using Matlab to control the linear stage now and I can read out the every positions of the linear stage as it moves. The problem is that I need to wait some time after each linear stage movement if I want to read the positions correctly. The waiting time is proportional to the acceleration, speed and step-lengths. So it takes quite a long time to finish a for loop. Do you have Matlab codes that are very efficient to read the position values?
Hi Thanks for your help.
I do find out the motor is Bslide and speed is 1.8degree/step. What does 1.8degree/step mean? And I also want to ask how can i force velmex to stop in Matlab for loop? I used fclose(), but it didn't work.
Hi Thank you for the information. I searched internet but didn't find anything useful. I tried to read the position in Matlab, but it take a waiting time for me to get the correct position. The waiting time is related to the speed, acceleration and step length. I wonder if a waiting time is also needed in Labview if I want to read correct position? My boss think the waiting time is too long and unacceptable. Do you have any thoughts to solve it?
/Nancy
either way, its still really 10seconds of waiting (you just do not notice it cause something is happening during the first part of the time-slice
All languages have (or should have) a setting for timing out if an answer is not found. This is determined in some languages by seeing a particular character or characters indicating that it is the end of the transmission.
For example. Labview has a Line-Terminator (I think it is <CR><LF>) but also has a setting to ignore the timeout, or to change the timeout
Matlab I have not found docs to similar but they have to exist (REALLLY BADD PROGRAMMING if there is not one), but since most people do not question it then its hard to find an answer.
If you can post code to show what you are doing that would help tremendously in solving the problem
Hi Charles, Thank you for your reply.
In the following matlab code what I did was to move the motor 1 for 2000 step and then read out the position value. There is a pause(t) inbetween, which is necessary if I want to read out position correctly.
fprintf(obj1,'C,I1M2000,R');
pause(t) % again pause is needed
fprintf(obj1,'X');
t(pause time) is related to speed,accerlaration and step length in a way just as what we did in high school physics.
For example, speed = 2000 step/s, accerlaration = 3 ( which is corresponding to a=12000 stpes/s^2 and initial speed = 190), step length = 2000, if we refer to Note#106 (a document on velmex homepage regarding accerlaration) we get t=0.405s. It is like we need to wait for the machine to stop and then we can readout the value. But in reality, the waiting time is obviously larger than 0.45s, it is like I have to wait about 5 seconds after the motor stopped for matlab to read out the position.
Matlab code for reading out pause (t)
v = 2000; % Velocity which we difined with S1M2000
a = 12000;
v_0 = 190;
d = 500; %length of each step, for simlicity we use the same value for all axis movement.
t1 = v/a;
d1 = v_0*t1+0.5*a*t1^2;
t_margin = 0.02;
if d1<d/2 %trapezoidal profile
t2 = (d-2*d1)/v;
t = 2*t1+t2+t_margin;
else %triangular profile
f = @(x)0.5*a*x^2+190*x-d/2;
t2 = fzero(f,0);
t = 2*t2+t_margin;
end
Just like you said, if Matlab has this timeout problem (10 second?) that's a lot. What can I do?
Hi I found out the slide model is MN10-0500-E01-21. E01 means per 1000 step the advance will be 0.125inch(3.175mm). Is it right? Thanks!
Now I am confused. I looked up in the document 'table for advance per turn for VXM M motor' and found that E01 is corresponding to 0.125inch for 1000 step...
/Nancy