VCD Protocol

 

VCD is the driver to communicate with automatic inserter controller.

 

1. Read settings

 

<Figure 1> is read setting example of VCD communication driver.

<Figure 1> Read setting example of VCD communication driver
 

Device part of <Figure 1> input Device type(COM1), Com Baud(9600), Parity Bit(0), Data Bit(8), Stop Bit(1).

Also, you can input memory address(0) to save the read communication data to String memory, number of storage(200) at protocol option part. Default value is 0 and 200(in defect of input).

 

Read Setting Method

Read setting needs only single line, because VCD communication drive is communicated by digital/analog output.

VCD is equipment to get operating information by communicating as ASCII type.

Therefore, VCD communication drive makes store the character(ASCII) data which communicate with device to designated address of String memory, as following order.

<Figure 2> Option dialog box of VCD communication driver

Error/Completion status bit

 

Error state of VCD communication drive and completion state such as DOWNLOAD, EXEDOWNLOAD and UPLOAD etc are saved to memory such as <Table 1>.

Also, result of contents for incurred error/state are stored at c:\error_msg000.txt file.

Contents Position Address when set digital input tag
Various error First bit of WORD memory 0000
Completion of DOWNLOAD/UPLOAD etc Second bit of WORD memory 0001
<Table 1> Meaning and contents for error/completion state by bit

Notice) In case of Error/Completion state bit, communication drive always ON so you have to OFF after reading error state at LocalMain, if you want to read Error/Completion contents to occur next.

 

Method for letting OFF the memory of communication program forcedly) If you set Extra1 of Digital/Analog output tag as #mem#, you can let OFF designated communication memory address value.

 

2. Write settings

Write to direct address of controller, regardless of SCAN File.

 

Digital Write

You can deliver command such as DOWNLOAD/UPLOAD etc to device by using digital output.

 

Digital write setting parameters are as follows :

1) PORT : Connected Port number which is set at communication program.(It isn't number such as COM1 and COM2 etc)

2) STATION : Don't care.

3) Address : In case of MT_READ command - Memory address to save read data.

CLR_DATA – Start address of String memory to clear.

Etc – Don't care.

4) Extra1 : Command. Designated unique command at VCD device and designated at command communication drive(Refer to <Table 2>).

VCD unique command – L, MT etc.

Specified command of communication drive - CMD_FILE, DOWNLOAD, UPLOAD, CLR_DATA, MT_READ.

(Designate the command as CMD_FILE such as DOWNLOAD, UPLOAD etc which have many number of letters)

5) Extra2 : UPLOAD command

0 : If the designated file exist, don't overwrite when UPLOAD.

1 : If the designated file exist, overwrite when UPLOAD.

CLR_DATA – Number of String memory to clear.

Etc command : Don't care. 

Command Unique command

Function

Remarks

CMD_FILE -

C:\cmd_file%03d.txt (%03d is Port number)

recognize as command by reading contents of first line

When length of command(designate unique and drive) is too long, can't send contents to Extra1 parameter

DOWNLOAD H

Send file contents which is input next to command to VCD

DOWNLOAD 1.TXT  (1.TXT is WorkDirectory\DATA Directory)

UPLOAD E

Input 2 file names next to command. Sets the file name of first file freely, and second file name is file name to save UPLOAD data

UPLOAD 1.TXT UP\UP123.TXT  (UP123.TXT is WorkDirectory\DATA\UP Directory)

CLR_DATA -

Delete the data upto the number of specified data(Extra2) from designated String memory(Address)

String memory is possible only

MT_READ MT

Save machine number, operating time and etc as string and number to designated address such as STRING, WORD, FLOAT, DWORD

Save to entire memory of WORD, FLOAT, DWORD, STRING by classifying the read data

(Save string to String memory, in order)

<Table 2> Functional description of designated command at communication driver

Notice) First file name of UPLOAD command is input as meaningless file name so as to use UICS communication drive and command equally.command equally.

 

Write example 1)

Port : 0  Station : 0  Address : 0000  Extra1 : cmd_file, EXTRA2 : 1

If you set as above and create UPLOAD 1.txt updata\vcd.txt to first line of C:\cmd_file000.txt by using script and output the digital value, it save as WorkDirectory\data\updata\vcd.txt by reading 1txt file of VCD equipment which is connected to Port no.0.

If vcd.txt file exist,  delete previous contents and overwrite read contents which is read at VCD.

Also, 1.txt of command contents is meaningless contents(for adjusting to UPLOAD command of UICS drive).

 

Write example 2)

Port : 0  Station : 0  Address : 0250  Extra1 : MT_READ, EXTRA2 : Blank

If you set as above and output digital, it reads data of machine number of VCD device and operation time etc which are connected to Port no.0 and save each data to no.250 ~ no. 263 by calculating data of WORD, FLOAT, DWORD memory as number and store read string to no.250 ~ no.258 String memory. 

 

Analog Write

It is same setting with Digital Write.

 

3. Method for terminal screen at LocalMain

 

VCD communication drive store most of communicated data to String memory, so you can confirm status of device by using the terminal mode, as follows.

 

A)   Create String to read input command by user from twenty String tag to show to screen and input method editor(Edit Box) by bringing communication data at String memory

B)   Create digital tag to output command together, and create module screen such as <Figure 3> by using studio program.

<Figure 3> Example of creating terminal screen at module editor(studio)

C)   To let see previous command by using button, create the Script On Module Running script such as <Table 3>.

Function

Contents

To let see previous command at terminal screen

if(pos == $scroll_pos) return;

pos = $scroll_pos;

 

for(i = 0; i < 20; i = i+1) {

   @sprintf(tag_name, "ST_%02d.address", i);

   @SetTagValue(tag_name, pos+i);

}

<Table 3> Example of creating script to enable to do see previous command

D)   Check( v ) Use Extension Options and Key Down button(Refer to <Figure 4>) by opening Extension tab of input method editor(Edit Box) such as <Figure 3>.

E)   Write Key Down script such as <Table 4> and <Figure 5>.

F)   Also, designate tag( STRING02 : Ex ) to save contents of input method editor at tag tab of input method editor(Edit Box).

G)   If you create module file as above, you can create terminal screen.

<Figure 4> Setting screen of Extension tab for input method editor (Edit Box)
   

Function

Contents

In case of pressing enter key at input method editor (Edit Box), send input contents as command of device

retn = @KeyGetCode();

if(retn != 13) return;    // In case of not enter key, return

 

handle  = @FileOpen("C:\\cmd_file000.TXT", "w");

if(handle != 0) {

   length = @strlen($STRING02);

   if(length == 0)

      @FileWrite(handle, " ", 1);

   else {

      @sprintf(buf, "%s", $STRING02);

      @FileWrite(handle, buf, length);

   }

   @FileWrite(handle, "\r\n");

   @FileClose(handle);

   $DO_EXEC = 0;

}

@EditBoxSetText("EditBox1", "");

<Table 4> Example of writing script to let see previous command

 
<Figure 5> Example of writing Key Down script of input method editor(Edit Box)
 

4. Read data for operation status

 

You can utilize data such as machine number, operation time, etc which are read by VCD communication drive by saving as analog/digital/string tag. And it can be written as follows.

Reading operation status data have to be read when other screen is opened, because in case of executing at terminal screen and DOWNLOAD/UPLOAD screen, more than 2 commands may exist.

 

A)   Create module screen which confirms operation status data.

B)   Create digital output tag for reading operation status data.

C)   Insert program to Script On Module Running such as <Table 5>.

D)   If you create as above module and script and current module file is opened by executing LocalMain, operation status data is read once per minute.

Function

Contents

Read operation status data once per minute

sec = @GetTimeSec();

if(sec == 0) {

  if(flag == TRUE) return;

   flag = TRUE;

   $VCD_EXEC1 = 0;  // MT_READ tag for reading operation status

}

else flag = FALSE;

<Table 5> Example of writing script for reading operation status data once per minute
5. Example of processing error/completion status bit

 

VCD communication drive can be utilized by using no.0000 bit of WORD memory as error status bit and no.0001 bit as completion status bit, as follows.

 

A)   Create digital input tag which reads error/completion status bit.

B)   If you write script such as <Table 6> and <Figure 6> by using At Program Running script, it reads occurred error and display the error at LocalMain as message.

C)   Also, completion message can be processed as same method.

Function

Contents

Display message at LocalMain by reading occurred error status bit

if($err_check == OFF) {

   flag = OFF;

   return;

}

if(flag == ON) return;

 

handle  = @FileOpen("C:\\error_msg000.txt", "r");

if(handle == 0) return;

 

len = @FileRead(handle, buf, 79);

@FileClose(handle);

 

buf[len] = 0;

@Message(buf);

flag = ON;

$err_flag_clear1 = OFF;

<Table 6> Example of writing script for displaying message at LocalMain by reading occurred error status bit

<Figure 6> Example of writing script for displaying message at LocalMain by reading occurred error status bit