09-27-2013 06:43 AM
Hello, everyone,
I'm trying to use MathScript to realize this code
s1=serial('COM3'); %from Matlab
but I can't find the right command in MathScript for COM-Port reading, someone know that?
yours
Adam
Solved! Go to Solution.
09-27-2013 06:55 AM
09-27-2013 07:05 AM
i have tried that, believe me, but i have problems with the datamatrix like i said, you can see it in the attachment, somehow i believe i have did it wrong with the fread command, because there is always error.
PS:
fprintf(s1,'isready'); % 'start' senden
A=fscanf(s1,'%s')
A=fscanf(s1,'%s')
fprintf(s1,'rdatb %04X\n',points-1); % Auslesekommando
pause(0.05);
A=fscanf(s1,'%s'); % read echo
A=fread(s1,2);
B=fread(s1,[2 points]); % read datamatrix
C=bitshift(B(1,:),8);
y2=fliplr(C+B(2,:));
09-27-2013 07:46 AM
I'm sorry but you have no data in any of your controls or indicators, no mention of what the error is, and a VI that is extremely badly written. You can fix the first problem by going to the edit menu and selecting Make Current Values Default, saving the VI, and attaching that. The last problem requires you to eliminate all local variables and the stacked sequence structure.
09-27-2013 07:56 AM
actually all the data is given in the controls, and they are all made as the default values, and i also connected it with the hardware. And for the sequence structure, i have to do it this way, because i have to make the data flow run like that.
% --- OTDR-Parameter -----------------------------------------------------------
points=1008; % Anzahl Messpunkte (0 - 16000)
delay=0; % Anzahl Wartepunkte (Start der Messung)
int_averages=64; % Anzahl interne Mittelungen (0 - 255) Vorsicht über 64!
resolution=0; % Abtastrate 0-10ns 1-20ns 2-40ns 3-60ns 4-80ns usw.
pulsewidth=2; % Pulsbreite in 10ns (entspr. 1m in Faser)
pulsepower=1; % Pulsenergie (0 - 255)
apdgain=1; % APD-Verstärkung (0-aus, 1-max, 255-min)
ampgain=1; % gewählte Verstärkerstufe (0,1,2,3)
% ------------------------------------------------------------------------------
but thank you anyway, i will keep trying and let you know when i success, have a nice weekend.
10-16-2013 04:42 AM
like Dennis said, it can't be used in MathScript, but see here
it might be help.