Parameter
Communication operation and settings
FR-D700 SC EC
6 - 213
Instructions for the program
When data from the computer has any error, the inverter does not accept that data. Hence, in
the user program, always insert a retry program for data error.
All data communication, e.g. run command or monitoring, are started when the computer gives
a communication request. The inverter does not return any data without the computer's request.
Hence, design the program so that the computer gives a data read request for monitoring, etc.
as required.
Program example
To change the operation mode to computer link operation
Programming example of Microsoft
®
Visual C++
®
(Ver.6.0)
Fig. 6-113:
Programming example
#include <stdio.h>
#include <windows.h>
void main(void){
HANDLE hCom;
//Communication
handle
DCB hDcb;
//Structure
for communication setting
COMMTIMEOUTS hTim;
//Structure for time out setting
char szTx[0x10];
//Send
buffer
char szRx[0x10];
//Receive
buffer
char szCommand[0x10]; //Command
int
nTx,nRx;
//For buffer size storing
int
nSum;
//For sum code calculation
BOOL bRet;
int nRet;
int i;
//**** Opens COM1 Port****
hCom = CreateFile ("COM1", (GENERIC_READ | GENERIC_WRITE), 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hCom != NULL) {
//**** Makes a communication setting of COM1 port****
GetCommState(hCom,&hDcb); //Retrieves current communication information
hDcb.DCBlength = sizeof(DCB); //Structure
size
setting
hDcb.BaudRate = 19200;
//Communication speed=19200bps
hDcb.ByteSize = 8;
//Data length=8bit
hDcb.Parity = 2;
//Even parity
hDcb.StopBits = 2; //Stop
bit=2bit
bRet = SetCommState(hCom,&hDcb);
//Sets the changed communication data
if (bRet == TRUE) {
//**** Makes a time out setting of COM1 port****
Get CommTimeouts(hCom,&hTim);
/Obtains the current time out value
hTim.WriteTotalTimeoutConstant = 1000;
//Write time out 1s
hTim.ReadTotalTimeoutConstant = 1000;
//Read time out 1s
SetCommTimeouts(hCom,&hTim); //Changed time out value setting
//**** Sets the command to switch the operation mode of the station 1 inverter to the network operation mode ****
sprintf(szCommand,"01FB10000"); //Send data (NET operation write)
nTx = strlen(szCommand);
//Send data size
//**** Generates sum code****
nSum = 0;
//Initialization of sum data
for (i = 0;i < nTx;i++) {
nSum += szCommand[i];
//Calculates sum code
nSum &= (0xff);
//Masks data
}
//**** Generates send data****
memset(szTx,0,sizeof(szTx));
//Initialization of send buffer
memset(szRx,0,sizeof(szRx)); //Initialization of receive buffer
sprintf(szTx,"\5%s%02X",szCommand,nSum);
//ENQ code+send data+sum code
nTx = 1 + nTx + 2;
//Number of ENQ code+number of send data+number of sum code
nRet = WriteFile(hCom,szTx,nTx,&nTx,NULL);
//**** Sending ****
if(nRet != 0) {
nRet = ReadFile(hCom,szRx,sizeof(szRx),&nRx,NULL);
//**** Receiving ****
if(nRet != 0) {
//**** Displays the receive data ****
for(i = 0;i < nRx;i++) {
printf("%02X ",(BYTE)szRx[i]); //Consol output of receive data
//Displays ASCII coder in hexadecimal. Displays 30 when "0"
}
printf("\n\r");
}
}
}
CloseHandle(hCom); //Close communication port
}
}
Содержание FR-D720S SC EC
Страница 2: ......
Страница 4: ......
Страница 24: ...Description of the case Product checking and part identification 1 4 ...
Страница 108: ...Operation panel Operation 4 20 ...
Страница 436: ...Setting for the parameter unit and operation panel Parameter 6 286 ...
Страница 484: ...Measurements on the main circuit Maintenance and inspection 8 14 ...
Страница 504: ...Specification change Appendix A 20 ...
Страница 505: ......
Страница 506: ......
Страница 510: ...Index Appendix A 24 ...
Страница 511: ......