source: ETALON/SPARC/NP30Iskra.m @ 143

Last change on this file since 143 was 143, checked in by hodnevuc, 9 years ago

MATLAB script for RS232 communication with NP30 Iskra

File size: 1.0 KB
Line 
1%This script help to communicate with NP30 Iskra and read data from it
2%remotely. Typical settings are:
3%       baudrate 9600 %Is setted by P7 parameter
4%       1 stop bit
5%       no parity
6%       8 data bits
7%       harware control none
8
9%Open serial port:
10serialOne=serial('COM10', 'BaudRate', 9600);
11fopen(serialOne);
12%Transactions begins by sending 2 or 8 ansii character to NP30. Both of
13%them give same data, but in different order.
14fprintf(serialOne,2)%
15s=fscanf(serialOne);%Number of datum point
16s2=fscanf(serialOne);%position; measurment unit; mode of measurment; halfing function
17s3=fscanf(serialOne);
18s4=fscanf(serialOne);
19disp([s  s2  s3 s4])
20
21%8 request give save data, but in other way
22% fprintf(serialOne,8)
23% fscanf(serialOne);
24% s5=fscanf(serialOne);%
25% disp(s5)
26
27%Convert XYZ position to numbers
28%%%%%%%%
29Xstr=strsplit(s2);
30Xpos=cell2mat(Xstr(4))
31Ystr=strsplit(s3);
32Ypos=cell2mat(Ystr(4))
33Zstr=strsplit(s4);
34Zpos=cell2mat(Zstr(4))
35%%%%%%%%
36
37%Close communication
38fclose(serialOne);
39delete(serialOne);
40clear serialOne
Note: See TracBrowser for help on using the repository browser.