The text of a manual · part 15 of 25
Bulletin 5370 CVIM Configurable Vision Input Module Communications Manual: 5 - Using the RS-232 Ports, pages 116 to 124
Pages 116 to 124 of 202, from Bulletin 5370 CVIM Configurable Vision Input Module Communications Manual
The original document is the PDF (723 KB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Allen-Bradley 5370-CVIM
Page 116
Chapter 5 Using the RS–232 Ports
Set/Read Configurable Statistics (cont’d)
The block signature is 2 bytes long. The number of samples is a 2 byte integer. The maximum and minimum values are each 4 bytes. The format of the data depends upon the operation (e.g. pixel count is an integer and linear gaging is a 16.16 fixed point value). Refer to page C–24 for data formats. The average and standard deviation are also 4 bytes each but are always 16.16 fixed point values. Therefore, each tool statistic consists of 18 bytes with the exception of reference windows which contain 18 bytes for each feature or a total of 54 bytes. The statistics block is transmitted as two hexadecimal characters for each byte. The total number of bytes including the block signature should not exceed 128 bytes. The statistics block is read once for every number of specified samples. This means that if you read the statistics block five times with a sample number of 50, 250 triggers will have to be processed before the five reads are completed. The following shows the format of the returned data: Statistics Block Returned Data Format*
*Data is transmitted without spaces, spacing added for clarity.
Trigger Operation Command
Use the trigger operation command to initiate an inspection by a toolset. Use the following commands: 09
04
Triggers an inspection using toolset 1. 09
05
Triggers an inspection using toolset 2. This function can only be executed once per command. If the BCC is not valid, the CVIM module will respond with a DLE NAK and the command will not be executed. If the BCC is valid, the CVIM module will respond with a DLE ACK. Then the CVIM module will validate the command structure. If the command is 5–46
Page 117
Chapter 5 Using the RS-232 Ports valid, the CVIM module will execute the command and return the data. If the command structure is invalid, the CVIM module will not execute the command or respond. Note: When using this command you should make sure that the CVIM module is configured for a “hosted trigger source”.
Unlock Command
Use the unlock command to enable the user interface (monitor and keyboard) so that a user can access the SETUP. This command has the following structure:
If the BCC is not valid, the CVIM module will respond with a DLE NAK and the command will not be executed. If the BCC is valid, the CVIM module will respond with a DLE ACK. Then the CVIM module will validate the command structure. If the command is valid, the CVIM module will execute the command. If the command structure is invalid, the CVIM module will not execute the command or respond.
Write Configuration Blocks
Use the write command to write data to configuration blocks. Note: You can also write to the monitor display to select what is displayed. Refer to Select Image Displayed. This command has the following structure:
Where the flags specify the configuration blocks being written to. There are 135 configuration blocks. Refer to the following diagram.
5–47
Page 118
Chapter 5 Using the RS–232 Ports
Write Configuration Blocks (cont’d)
8
32
56
80
7
31
55
79
104 103
128 127
6
30
54
78
Write Configuration Block Command Bytes 3–29
Byte 3
Byte 4
Byte 5
Bits 7 – 0
Bits 7 – 0
Bits 7 – 0
5
4
3
2
1
16
15
13
12
11
10
9
24
23
22
21
20
19
18
17
43
42
41
67
66
65
91
90
89
116 115 114
113
Byte 6
Byte 7
Byte 8
Bits 7 – 0
Bits 7 – 0
Bits 7 – 0
29
28
27
26
25
40
39
38
37
36
35
34
33
48
47
46
45
44
Byte 9
Byte 10
Byte 11
Bits 7 – 0
Bits 7 – 0
Bits 7 – 0
53
52
51
50
49
64
63
62
61
60
59
58
57
72
71
70
69
68
Byte 12
Byte 13
Byte 14
Bits 7 – 0
Bits 7 – 0
Bits 7 – 0
77
76
75
74
73
88
87
86
85
84
83
82
81
96
95
94
93
92
Byte 15
Byte 16
Byte 17
Bits 7 – 0
Bits 7 – 0
Bits 7 – 0
102 101
100
99
98
97
112 111
110 109
108 107 106 105
Byte 18
Byte 19
Bits 7 – 0
Bits 7 – 0
126 125
124 123 122 121
136 135
Set individual bits to select blocks 1 through 136.
5–48
14
134 133
132 131 130 129
120 119
118 117
Page 119
Chapter 5 Using the RS-232 Ports
This function can only be executed once per command. Each configuration block is sent in a separate data packet (Header/Data/Trailer). Refer to Appendix D for a description of the configuration blocks. You cannot use this command when the CVIM module is in the setup mode. After writing to the CVIM module, the CVIM module will validate all of the configuration blocks (refer to Chapter 4 for a description of memory validation). Example:
This example writes the data into configuration block #3. If the BCC is not valid, the CVIM module will respond with a DLE NAK and the command will not be executed. If the BCC is valid, the CVIM module will respond with a DLE ACK. Then the CVIM module will validate the command structure. If the command is valid, the CVIM module will execute the command. If the command structure is invalid, the CVIM module will not execute the command or respond. Note: We recommend that you check the discrete bit ‘‘Configuration Fault’’ after loading a configuration. Refer to Appendix B. Since no data is returned with this command, the load operation may fail and you could detect this by checking the fault bit. You can check this bit by using the read discrete bit results command for toolset #1.
5–49
Page 120
Chapter 5 Using the RS–232 Ports
Command Summary
After you have become familiar with the DF1 commands, you can use the following command summary as a quick reference guide. Table 5.B DF1 Command Summary Command Deactivate Forces Echo Data
01 00 nn Data 14
Disable Outputs
15
Force Outputs
02 06 Flags Flags Data
Load Configuration From Credit Card to RAM*
Field Descriptions
0C
Enable Outputs
Load Configuration From EEPROM to RAM nn = times repeated Data = Hexadecimal string
Flags indicate outputs Data = 00 (on) or 01 (off)
03 00
03 01 Data
Lock
04
Unlock
0A
Data = 01 (area 1) 02 (area 2) DDD 15(area 15) 16(area 16)
Read Output Condition
05 00 nn 06 Flags Flags nn = times repeated Flags indicate outputs
Read Configuration
06 07 Flags
Flags indicate blocks
Read Discrete Bit Results
07 00 nn 04 07 00 nn 05
First discrete bit results Second discrete bit results nn = times repeated
*
5–50
Command Structure
The number of configurations that can be stored on a RAM card depends upon the card size (512K card can hold 16 configurations).
Page 121
Chapter 5 Using the RS-232 Ports
Table 5.B DF1 Command Summary (Cont’d) Command
Command Structure
Field Descriptions n= x= y=
07 00 n x y z z=
Read Results Block
Save to EEPROM from RAM times repeated 04 (Toolset 1) 05 (Toolset 5) 16(Gages) 17 (Window) 18 (Reference Line) 19 (Reference Window 1A (Light Probe) Window, Gage, Reference Line, or Reference Window No.
07 00 n 10 Data
Toolset 1 Results n = times repeated Data = Block Number(s) 1, 2, 3 or 4
07 00 n 15 Data
Toolset 2 Results n = times repeated Data = Block Number(s) 1, 2, 3 or 4
07 00 n 04
Toolset 1 discrete bit results n = times repeated
07 00 n 05
Toolset 2 discrete bit results n = times repeated
07 00 n 08
Read Status
08 00
Save to RAM Card from RAM
08 01 Data
Data = 01 (area 1) 02 (area 2) DDD 15(area 15) 16(area 16)
Set ConfigurabIe Results
OD Flags
Flags indicate specific tools
Set ConfigurabIe Statistics
16 00 n Flags
Flags indicate specific tools n = times repeated
Read ConfigurabIe Statistics
17 00 n
Trigger Inspection Write Configuration Block
09 0B 07 Flags Data n = times repeated Trigger Flags indicate blocks
5–51
Page 122
Chapter 5 Using the RS–232 Ports
Command Summary (cont‘d)
Table 5.B DF1 Command Summary (Cont’d) Command
Write Display
Command Structure
0B 02 Data
OB 13 Data
OB 14 Data
5–52
Field Descriptions Data = 0B–Image Only Toolset 1 0C–Failed Tools Toolset 1 0D–All Tools Toolset 1 0E–l/O Page Toolset 1 0F–Results Page Toolset 1 10–Stats 1 Page Toolset 1 11–Stats 2 Page Toolset 1 12–Page Up Same Display Toolset 1 13–Page Down Same Display 15–Image Only Toolset 2 16–Failed Tools 17–All Tools Toolset 2 18–l/O Page Toolset 2 19–Results Page Toolset 2 1A–Stats 1 Page Toolset 2 1B–Stats 2 Page Toolset 2 1C–Page Up Same Display Toolset 2 1D–Page Down Same Display Toolset 2 Data = 0B–Go On Reject Toolset 1 0C–Freeze On First Reject Toolset 1 0D–Freeze On All Reject Toolset 1 0E–Freeze On Next Inspection Toolset 1 0F–Halt On Reject Toolset 1 15–Go On Reject Toolset 2 16–Freeze On First Reject Toolset 2 17–Freeze On All Reject Toolset 2 18–Freeze On Next Inspection Toolset 2 19–Halt On Reject Toolset 2 Data = 0B–Resume Toolset 1 0C–Reset Statistics Toolset 1 0D–Reset Counters Toolset 1 12–Page Up Toolset 1 13–Page Down Toolset 1 15–Resume Toolset 2 16–Reset Statistics Toolset 2 17–Reset Counters Toolset 2 18–Page Up Toolset 2 19–Page Down Toolset 2
Page 123
Chapter 5 Using the RS-232 Ports
DF1 Programming Example
The following is a sample DF1 program written in C. The program configures the host computer’s serial port for 9600 Baud communications. The program then displays a menu which prompts the user to select one of the following operations: 0. Echo the word “HELLO” to test the communications port. 1. Trigger the CVIM module to perform an inspection using toolset #1. 2. Read the discrete bit results for toolset 1. 3. Read the results block #1 for toolset 1. 4. Read gage #1 statistics for toolset 1. 5. Trigger the CVIM module to perform an inspection using toolset #2. 6. Read the discrete bit results for toolset 2. 7. Read the results block #1 for toolset 2. 8. Read gage #1 statistics for toolset 2. 9. Read configuration block n. 10.. Write configuration block n. 11.. Change display to results page, toolset 1. 12. Page up, toolset 1 display. 13. Page down, toolset 1 display. 14.. Change display to results page, toolset 2. 15. Page up, toolset 2 display. 16. Page down, toolset 2 display. The program demonstrates a simple implementation of the DF1 protocol. Your actual application program may require some enhancements such as increased error checking or time–out conventions. The sample program begins on the next page.
5–53
Page 124
Chapter 5 Using the RS–232 Ports
DF1 Programming Example (cont’d) /* CVIM RS–232 Communication example program using DF1 protocol */ /* Copyright Allen–Bradley 12-5-89 jrm, aes */ This sample program was compiled using Microsoft C Version 5.1 */ #include <stdio.h> #include <stdlib.h> #include <bios.h> #define STX 0x02 #define ETX 0x03 #define ENQ 0x05 #define DLE 0x10 #define ACK 0x06 #define NAK 0x15
/* Start of Text character */ /* End of Text character */ /* Enquire */ /* Data Link Escape (Control char) */ /* Positive acknowledgement */ /* Negative acknowledgement */
#define COMMFLAGS 0x8E00
/* defines bits to check for comm error */
#define MAX BUFFER
128 /* define storage for configuration data */ unsigned char config [135] [MAX BUFFER] configlen [135] template [256] [MAX BUFFER] templen [256[ unsigned char last_response = 0; void main() { int x, op_num, portnum, err, replen, reslen, numblocks; unsigned char reply[200], results[MAX BUFFER]; /* Get Serial port number from user */ printf (”Enter port number (1 for COM1 or 2 for COM2):”); scanf (”%d”, &portnum)); /* make portnum either 0 or 1 */ portnum = (portnum – 1) & 0x01; /* Open comm channel to at 9600 baud */ _bios_serialcom (_COM_INIT, portnum–1, _COM_CHR8 | _COM_STOP1 | _COM_NOPARITY | _COM_9600);
5–54