122 Appendix 3 Communication Protocol
EV2000 Series Universal Variable Speed Drive User Manual
char run_inverter[20]="~010200000183\r";
/* Command of running the
drive */
char stop_inverter[20]="~01020007018A\r";
/* Command of stopping the
drive*/
void send_comd(char *sendstr,char *display_type); /* Send the command */
void checksum(char *sendstr,char result_sum[]); /*Calculate verify checksum*/
main()
{
char sum_of_cmd[5],buf[25];
/*store the string of 4-byte verify
checksum */
char set_frequency[25]="010200010BB8";
/* set the running frequency at
30.00Hz */
bioscom(SET_COMPARA,DEFAULT_BAUD,COM1); /* set COM1, 8-N-1, 9600bps */
send_comd(run_inverter,"HEX");
/* Send run command, display
in HEX format */
printf("\nPress anykey to set frequency to 30.00Hz ...");
while(!kbhit());
/* wait for pressing any key to
input */
getchar(); /* get character */
checksum(set_frequency,sum_of_cmd);
/* get the verify checksum of the
sent command */
sprintf(buf,"~%s%s\r",set_frequency,sum_of_cmd);
strcpy(set_frequency,buf); /* combine the sent frames */
send_comd(set_frequency,"HEX");
/* set to 30.00Hz, display in
HEX format */
printf("\nPress anykey to stop ...");
while(!kbhit());
/* wait for pressing any key to
input */
send_comd(stop_inverter,"ASCII");
/* Send stop command, display
in ASCII format */
}
void send_comd(char *sendstr,char *display_type)
{
unsigned int i;
char buf[5]; /* used for character display */
printf("\nSend(%s):",display_type);
for(i=0;i<strlen(sendstr);i++){ /* send the frame command */
outportb(PORT_ADDR,sendstr[i]);
delay(delaytime);
/* The delay time should ensure
the command can be sent */
if(display_type[0]=='H') /* determine the display format*/