(N) Operation via communication and its settings
Parameters
5 - 646
●
Program example: To switch to the Network operation mode
Microsoft
Visual C++
(Ver.6.0) programming example
#include <stdio.h>
#include <windows.h>
void main(void){
HANDLE
hCom;
// Communication handle
DCB
hDcb;
// Structure for setting communication settings
COMMTIMEOUTS
hTim;
// Structure for setting timeouts
char
szTx[0x10];
// Send buffer
char
szRx[0x10];
// Receive buffer
char
szCommand[0x10];// Command
int
nTx,nRx;
// For storing buffer size
int
nSum;
// For calculating sum code
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 ****
GetCommState(hCom,&hDcb);
// Get current communication information
hDcb.DCBlength = sizeof(DCB);
// Structure size setting
hDcb.BaudRate = 19200;
// Communication speed = 19200 bps
hDcb.ByteSize = 8;
// Data length = 8 bits
hDcb.Parity = 2;
// Parity check at even numbers
hDcb.StopBits = 2;
// Stop bit = 2 bits
bRet = SetCommState(hCom,&hDcb);
// Setting of changed communication information
if(bRet == TRUE) {
//**** Set COM1 port timeout ****
GetCommTimeouts(hCom,&hTim);
// Get current timeout values
hTim.WriteTotalTimeoutConstant = 1000;
// Write timeout 1 second
hTim.ReadTotalTimeoutConstant = 1000;
// Read timeout 1 second
hTim.ReadTotalTimeoutConstantSetCommTimeouts(hCom,&hTim); // Setting of changed timeout values
//**** Setting of command for switching the station number 1 inverter to the Network operation mode ****
sprintf(szCommand,"01FB10000");
// Send data (NET operation write)
nTx = strlen(szCommand);
// Send data size
//**** Generate sum code ****
nSum = 0;
// Initialize sum data
for(i = 0;i < nTx;i++) {
nSum += szCommand[i];
// Calculate sum code
nSum &= (0xff );
// Mask data
}
//**** Generate send data ****
memset(szTx,0,sizeof(szTx));
// Initialize send buffer
memset(szRx,0,sizeof(szRx));
// Initialize receive buffer
sprintf(szTx,"\5%s%02X",szCommand,nSum);// ENQ code + send data + sum code
nTx = 1 + nTx + 2;
// ENQ code + number of send data + number of sum codes
nRet = WriteFile(hCom,szTx,nTx,&nTx,NULL);
//**** Send ****
if(nRet != 0) {
nRet = ReadFile(hCom,szRx,sizeof(szRx),&nRx,NULL);
//**** Receive ****
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");
}
}
}
CloseHandle(hCom);
// Close communication port
}
}
Содержание FR-A820-00046 (0.4K)
Страница 2: ......
Страница 4: ......
Страница 144: ...System configuration for Ethernet communication FR A800 E Installation and wiring 2 114 ...
Страница 202: ...Basic operation procedure JOG operation Basic operation 4 32 ...
Страница 1090: ...Check first when you have a trouble Protective functions 6 50 ...
Страница 1110: ...Measurement of main circuit voltages currents and powers Precautions for maintenance and inspection 7 20 ...
Страница 1188: ...EC Declarations of Conformity Appendix A 48 A 7 EC Declarations of Conformity A 7 1 FR A820 FR A840 FR A842 series ...
Страница 1189: ...Appendix EC Declarations of Conformity FR A800 A 49 ...
Страница 1190: ...EC Declarations of Conformity Appendix A 50 ...
Страница 1191: ...Appendix EC Declarations of Conformity FR A800 A 51 ...
Страница 1192: ...EC Declarations of Conformity Appendix A 52 ...
Страница 1193: ...Appendix EC Declarations of Conformity FR A800 A 53 ...
Страница 1194: ...EC Declarations of Conformity Appendix A 54 ...
Страница 1195: ...Appendix EC Declarations of Conformity FR A800 A 55 ...
Страница 1196: ...EC Declarations of Conformity Appendix A 56 ...
Страница 1197: ...Appendix EC Declarations of Conformity FR A800 A 57 ...
Страница 1198: ...EC Declarations of Conformity Appendix A 58 ...
Страница 1199: ...Appendix EC Declarations of Conformity FR A800 A 59 ...
Страница 1200: ...EC Declarations of Conformity Appendix A 60 ...
Страница 1201: ...Appendix EC Declarations of Conformity FR A800 A 61 ...
Страница 1202: ...EC Declarations of Conformity Appendix A 62 ...
Страница 1203: ...Appendix EC Declarations of Conformity FR A800 A 63 ...
Страница 1204: ...EC Declarations of Conformity Appendix A 64 ...
Страница 1205: ...Appendix EC Declarations of Conformity FR A800 A 65 ...
Страница 1206: ...EC Declarations of Conformity Appendix A 66 ...
Страница 1207: ...Appendix EC Declarations of Conformity FR A800 A 67 ...
Страница 1208: ...EC Declarations of Conformity Appendix A 68 ...
Страница 1209: ...Appendix EC Declarations of Conformity FR A800 A 69 ...
Страница 1210: ...EC Declarations of Conformity Appendix A 70 ...
Страница 1211: ...Appendix EC Declarations of Conformity FR A800 A 71 ...
Страница 1212: ...EC Declarations of Conformity Appendix A 72 A 7 2 FR A846 series ...
Страница 1213: ...Appendix EC Declarations of Conformity FR A800 A 73 ...
Страница 1214: ...EC Declarations of Conformity Appendix A 74 ...
Страница 1215: ...Appendix EC Declarations of Conformity FR A800 A 75 ...
Страница 1216: ...EC Declarations of Conformity Appendix A 76 A 7 3 Frequency inverters with option unit FR A8NP ...
Страница 1217: ......