Home > Back-end >  Delphi industrial serial code gun set case
Delphi industrial serial code gun set case

Time:03-04

1. The need to install Cport controls

2. The scanning gun serial port parameters set agreement
A: a serial port communication configuration: 115200 8 1 N
2: equipment working parameters Settings.
Data format 4 bytes
0 x20 x50 0 0 x01 0 x00
Boot code type code function code parameter
0 x20//boot code
0 x50//type judgment
0 x01 function code (trigger the maximum number of consecutive)
Continuous trigger number 0 x00//
0 x02 function code (continuous trigger minimum number)
Continuous trigger number 0 x00//
0 x03 function code (NG string output enabled)
0 x00//0: NG string output is not can make 1: NG string output can make the
0 x04 function code (continuous scanning time interval)
0 x00//continuous scanning time interval
0 x05 function code (OK signal output time)
0 x00//OK signal output time a number of 10 ms
0 x06 function code (NG) signal output time
0 x00//NG signal output time a number of 10 ms
0 x07 function code start-stop as the fill light (LED)
0 x00/open/stop 0 x01
0 x09 function code (the full string matching start-stop)
0 x00//0 x00 stop 0 x01 opening match
0 x0a function code (duplicate code filtering start-stop)
0 x00//0 x00 stop filter 0 x01 enabled
0 x0b function code (comparative data length)
0 x00//data length 1-30
0 x0c function code (comparative data length start-stop)
0 x00//0 x00 stop comparing 0 x01 enabled more
0 x0d function code (the front part of comparative data string start-stop)
0 x00//0 x00 stop comparing 0 x01 enabled more
0 x0e function code (separator)
0 x00//parameter
0 x0f//function code (network parameters read)
0 x01//this position must be 1
0 x16//function code (character trigger equipment start-stop work Settings)
0 x01 0 x00 stop 0 x01 enabled
0 x17//function code (character trigger device work overtime time)
0 x01 01 said 100 ms to 25500 ms (0 means stop timeout)
More than 0 x18//function code (code data filtering start-stop Settings)
0 x01 0 x00 stop 0 x01 enabled
0 x19//function code (PC serial port baud rate setting)
0 x01 (default is 115200)
Parameter Settings:
"600
When 200
8:38 400
4:57 600
Now the 5200 (default)
6:23 0400
At 7:46 0800
Does 21600
0 x1a//function code (module end serial port baud rate setting)
0 x01 (default is 115200)
Parameter Settings:
"600
When 200
8:38 400
4:57 600
Now the 5200 (default)
6:23 0400
At 7:46 0800
Does 21600
0 x1b device triggers the start command
0 x00//closed continuous working mode 0 x01 open continuous working mode
0 x77 read equipment all configuration parameters information
0 x01//this position must be 0 x01
3: all equipment work character match Settings.
0 x20 0 x60 0 x01 0 x01
Boot code type code length data
0 x60 full string matching set
1-0 x01 data length 30
0 x01 data
Four: front part compare characters matching equipment work Settings.
0 x20 x70 0 0 x01 0 x01
Boot code type code length data
0 x70 front part compare characters
1-0 x01 data length 30
0 x01 data
Five: equipment character trigger work parameter Settings.
0 x20 xd0 0 0 x01 0 x01
Boot code type code length data
0 xd0 character trigger
1-0 x01 data length 30
0 x00 data (0 x20 are prohibited inside, otherwise equipment will run abnormal!) Six: equipment character trigger stop parameter Settings.
0 x20 0 xe0-0xfc 0 x01 0 x01
Boot code type code length data
0 xe0-0xfc character trigger
1-0 x01 data length 30
0 x00 data (0 x20 are prohibited inside, otherwise equipment will run abnormal!) Seven: equipment more code starting operators and end parameter is set
0 x20 0 xf0 0 x01 0 x01
Boot code type code length data
Start operator type code: 0 xf0 (said)
The type code: 0 xf1 (end)
1-0 x01 data length 30
0 x00 data (0 x20 are prohibited inside, otherwise equipment will run abnormal!)
Is empty (20 F0 00 00) 8: equipment network parameters Settings.
0 x20 0 x80 0 x02 0 x10 0 x01
Boot code type code length command parameter
0 x80 network parameter Settings
1-0 x01 data length 30

0 x02 length0 x10 device mode instructions
Parameters:
0: TCP server mode (default)
1: the TCP client mode
2: the UDP server mode
3: UDP client mode
IP address 0 x11 equipment directive
Parameters:
0 xc0 192
0 xa8 168
0 x01 1
0 xc8 200
(192.168.1.200) (default)
0 x12 device subnet mask instructions
Parameters:
0 XFF 255
0 XFF 255
0 XFF 255
0 x00 0
(255.255.255.0) (default)
Gateway address 0 x13 equipment directive
Parameters:
0 xc0 192
0 xa8 168
0 x01 1
0 x01 1
(192.168.1.1) (default)
Port 0 x14 equipment instructions
Parameters:
0 x07
0 xd0
(2000) (the default)
Destination IP address 0 x15 equipment directive
Parameters:
0 xc0 192
0 xa8 168
0 x01 1
0 x64 100
(192.168.1.100) (default)
0 x16 equipment purpose port instructions
Parameters:
0 x03
0 xe8
(1000) (the default)
0 x17 random port equipment start-stop
Parameters:
0 x00 banned
0 x01 enabled

3. Interface design


Interface code
The unit Unit4.

Interface

USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Unit1, CPort;

Type
TForm4=class (TForm)
Btn1: TButton;
Grp1: TGroupBox;
Edt1: TEdit;
Rb2’s much-publicised: TRadioButton;
Rb1: TRadioButton;
Btn3: TButton;
Btn2: TButton;
Btn4: TButton;
Mmo1: TMemo;
Lbl1: TLabel;
Edt2: TEdit;
Btn5: TButton;
Btn6: TButton;
Btn7: TButton;
Procedure FormCreate (Sender: TObject);
Procedure btn1Click (Sender: TObject);
Procedure btn3Click (Sender: TObject);
Procedure FormClose (Sender: TObject; Var Action: TCloseAction);
Procedure btn2Click (Sender: TObject);
Procedure btn4Click (Sender: TObject);
Procedure btn5Click (Sender: TObject);
Procedure btn6Click (Sender: TObject);
Procedure btn7Click (Sender: TObject);
Private
{Private declarations}
Public
{Public declarations}
Comm: TComPort;
Procedure comRxChar (var of_off: Boolean; Var sReadBar_Com: string; Count: Integer; I: Integer=0);
The function HexStrTostr (s: string) : string;//hexadecimal string
The function getComStr (STR: string) : string;//enabled sweep sweep gun back yard the results
end;

Var
Form4: TForm4;

Implementation
{$R *. DFM}
//enable sweep gun
Procedure TForm4. Btn1Click (Sender: TObject);
The begin
Mmo1. Lines. The Add (getComStr (' ON '));
end;

//initialization code gun esau
Procedure TForm4. Btn2Click (Sender: TObject);
The begin
//20500100//trigger the maximum number of consecutive
//20500200//continuous trigger the minimum number of
//20500900//full stop string matching
//20500 a00:1450:8006//duplicate code stop filtering
//20500 c00//compare data length to stop a
20500 d00////the front part compare data string to stop a
//20500 e3b//code separator set;
//20600000//equipment work all characters matching set
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related