Mitsubishi Electric FR-CS82S-025 Instruction Manual page 178

Hide thumbs Also See for FR-CS82S-025:
Table of Contents

Advertisement

Microsoft® Visual C++® (Ver.6.0) programming example
#include <stdio.h>
#include <windows.h>
void main(void){
HANDLE
hCom;
DCB
hDcb;
COMMTIMEOUTS
char
szTx[0x10];
char
szRx[0x10];
char
szCommand[0x10];// Command
int
nTx,nRx;
int
nSum;
BOOL
bRet;
int
nRet;
int
i;
// ****
Open COM1 port
****
hCom = CreateFile("COM1", (GENERIC_READ | GENERIC_WRITE), 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hCom != NULL) {
//
Set COM1 port communication
****
G
e
C t
o
m
m
S
a t
e t
h (
h
D
c
b
D .
C
B
e l
n
g
h t
h
D
c
b
B .
a
u
d
R
a
e t
h
D
c
b
B .
y
e t
S
z i
e
=
h
D
c
b
P .
r a
y t i
=
; 2
h
D
c
b
S .
o t
p
B
s t i
=
b
R
t e
=
S
e
C t
o
m
m
if(bRet == TRUE) {
//
Set COM1 port timeout
****
G
e
C t
o
m
h
i T
m
.
W
i r
h
i T
m
R .
e
hTim.ReadTotalTimeoutConstantSetCommTimeouts(hCom,&hTim);// Setting of changed timeout values
//
Setting of command for switching the station number 1 inverter to the Network operation mode
****
s
r p
n i
( f t
z s
n
T
x
=
s
r t
//
Generate sum code
****
n
S
u
m
=
for(i = 0;i < nTx;i++) {
}
//
Generate send data
****
memset(szTx,0,sizeof(szTx));
m
e
m
s
e
( t
sprintf(szTx,"\5%s%02X",szCommand,nSum);// ENQ code + send data + sum code
n
T
x
=
1
nRet = WriteFile(hCom,szTx,nTx,&nTx,NULL);
//
Send
****
if(nRet != 0) {
//
Receive
****
}
}
C
o l
s
e
H
a
n
d
e l
h (
C
o
}
}
// Communication handle
// Structure for setting communication settings
hTim;
// Structure for setting timeouts
// Send buffer
// Receive buffer
// For storing buffer size
// For calculating sum code
****
C
o
m
& ,
h
D
c
b
; )
=
s
z i
e
o
( f
D
C
B
; )
=
1
9
2
0
; 0
; 8
; 2
S
a t
e t
h (
C
o
m
& ,
h
D
c
b
; )
****
m
i T
m
e
o
u
s t
h (
C
o
m
& ,
h
i T
m
; )
e t
T
o
a t
i T l
m
e
o
u
C t
o
n
s
a t
t n
=
1
0
0
; 0
a
d
T
o
a t
i T l
m
e
o
u
C t
o
n
s
a t
t n
=
1
0
0
; 0
C
o
m
m
a
n
, d
0 "
1
F
B
1
0
0
0
0
; ) "
e l
( n
z s
C
o
m
m
a
n
d
; )
****
; 0
n
S
u
m
+
=
z s
C
o
m
m
a
n
[ d
; ] i
n
S
u
m
&
=
0 (
f x
; ) f
****
z s
R
x
0 ,
s ,
z i
e
o
( f
z s
R
x
; ) )
+
n
T
x
+
; 2
****
nRet = ReadFile(hCom,szRx,sizeof(szRx),&nRx,NULL);
****
if(nRet != 0) {
//
Display receive data
****
for(i = 0;i < nRx;i++) {
printf("%02X ",(BYTE)szRx[i]);// Output received data to console
// Display ASCII code in Hexadecimal' In case of 0', "30" is displayed.
}
printf("\n\r");
}
m
; )
/ /
G
t e
c
r u
e r
t n
c
o
m
m
/ /
t S
u r
c
u t
e r
s
z i
e
s
e
t t
/ /
C
o
m
m
u
n
c i
t a
o i
n
s
/ /
D
a
a t
e l
n
g
h t
=
8
b
/ /
P
r a
y t i
c
h
e
k c
t a
e
v
/ /
S
o t
p
b
t i
=
2
b
s t i
/ /
S
e
t t
n i
g
f o
c
h
a
n
g
e
/ /
G
t e
c
r u
e r
t n
i t
m
e
o
/ /
W
i r
e t
i t
m
e
o
t u
1
s
/ /
R
e
a
d
i t
m
e
o
t u
1
s
/ /
S
e
n
d
d
a
a t
(
N
E
T
/ /
S
e
n
d
d
a
a t
s
z i
e
/ /
n I
t i
a i
z i l
e
s
u
m
d
a
a t
/ /
C
a
c l
u
a l
e t
s
u
m
c
o
/ /
M
a
k s
d
a
a t
// Initialize send buffer
/ /
Initialize receive buffer
/ /
E
N
Q
c
o
d
e
+
n
u
m
****
/ /
C
o l
s
e
c
o
m
m
u
n
c i
t a
5.11 (N) Communication operation parameters
u
n
c i
t a
o i
n
i
f n
r o
m
t a
o i
n
n i
g
p
e
e
d
=
1
9
2
0
0
b
s p
s t i
e
n
n
u
m
b
e
s r
d
c
o
m
m
u
n
c i
t a
o i
n
i
f n
r o
m
t a
o i
n
t u
v
a
u l
e
s
e
c
o
n
d
e
c
o
n
d
****
o
p
r e
t a
o i
n
w
t i r
) e
d
e
b
r e
f o
s
e
n
d
d
a
a t
+
n
u
m
b
r e
f o
s
u
m
c
o
o i
n
p
o
t r
5. PARAMETERS
2
2
3
4
5
6
7
8
9
10
d
e
s
177

Advertisement

Table of Contents
loading

Table of Contents