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:
|
---|
10 | serialOne=serial('COM10', 'BaudRate', 9600);
|
---|
11 | fopen(serialOne);
|
---|
12 | %Transactions begins by sending 2 or 8 ansii character to NP30. Both of
|
---|
13 | %them give same data, but in different order.
|
---|
14 | fprintf(serialOne,2)%
|
---|
15 | s=fscanf(serialOne);%Number of datum point
|
---|
16 | s2=fscanf(serialOne);%position; measurment unit; mode of measurment; halfing function
|
---|
17 | s3=fscanf(serialOne);
|
---|
18 | s4=fscanf(serialOne);
|
---|
19 | disp([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 | %%%%%%%%
|
---|
29 | Xstr=strsplit(s2);
|
---|
30 | Xpos=cell2mat(Xstr(4))
|
---|
31 | Ystr=strsplit(s3);
|
---|
32 | Ypos=cell2mat(Ystr(4))
|
---|
33 | Zstr=strsplit(s4);
|
---|
34 | Zpos=cell2mat(Zstr(4))
|
---|
35 | %%%%%%%%
|
---|
36 |
|
---|
37 | %Close communication
|
---|
38 | fclose(serialOne);
|
---|
39 | delete(serialOne);
|
---|
40 | clear serialOne |
---|
Note: See
TracBrowser
for help on using the repository browser.