Basically, the Cognex In sight is a Telnet server. The Labview program makes a TPC connection to the camera's IP address on port 21. The username admin followed by carriage return and line feed is transmitted from Labview. Then the password, which is blank, so just a carriage return and line feed are sent. That initialization of the connection is made every time. While the connection is maintained (open) any of the Native Mode commands can be sent. See in sight explorer help for a full list of Native Mode commands. The camera can be triggered by sending SE8\r\n [note: the \r\n is the escape or slash character representation of Carriage return and line feed respectively.] The camera will return a number and \r\n that encodes any error in reading or executing the command. If you get a 1\r\n everything was OK. After the inspection has completed you need to read out the result. The native mode command to get a value is GV. For example, GVc013\r\n will return the value in spreadsheet cell c013. If you are using easybuilder you need to create a format string in the "Communication" section. Get the content of the format string using the command GVJob.Robot.FormatString\r\n
The video shows how the Labview portion of the code works. There is a .VI in the form of a functional global variable that encapsulates the communication as a state machine. It handles the connection, login, command, and closing. If you want the code let me know in the comments of the video.
This link is a LabVIEW example. It is written in LabVIEW 2018
Cognex Native Mode Communication Example https://drive.google.com/file/d/1G3T7LsJA6gZIcHpWeMIAGt_enxl1vMb5/view?usp=sharing
From In-sight explorer help (Links don't work, you need to have in sight explorer):
Basic Native Mode Commands
File & Job Commands
- Load File: (LF) Loads the specified job from flash memory on the In-Sight vision system, making it the active job.
- Store File: (TF) Saves the current job in flash memory on the vision system.
- Read File: (RF) Reads a job from the flash memory on the vision system.
- Write File: (WF) Sends a job to the flash memory on the vision system.
- Delete File: (DF) Deletes the specified job or cell data file (.cxd) from flash memory on the vision system.
- Get File: (GF) Returns the filename of the active job on the vision system.
- Set Job: (SJ) Loads a job from one of the job slots in flash memory on the vision system, making it the active job.
- Store Job: (TJ) Saves the current job into the specified slot in flash memory on the vision system.
- Read Job: (RJ) Reads a job from the specified In-Sight job slot.
- Write Job: (WJ) Sends a job to the specified job slot in flash memory on the vision system.
- Delete Job: (DJ) Deletes the job from the specified slot in flash memory on the vision system.
- Get Job: (GJ) Gets the currently loaded job's ID number.
Image Commands
- Read BMP: (RB) Sends the current image, in ASCII hexadecimal format, from a vision system to an external device.
- Read Image: (RI) Sends the current image, in ASCII hexadecimal format, from a vision system to an external device.
- Write BMP: (WB) Sends image data from an external device to the vision system.
- Write Image: (WI) Sends image data from an external device to the vision system.
Settings & Cell Value Commands
- Get Value: (GV) Returns the value in a specified cell or symbolic tag.
- Set Integer: (SI) Sets an integer value in a specified cell or symbolic tag.
- Set Float: (SF) Sets a floating point value in a specified cell or symbolic tag.
- Set Region: (SR) Sets the values of an EditRegion cell or symbolic tag.
- Set String: (SS) Sets a string value in a specified cell or symbolic tag.
- Get Info: (GI) Returns system information about the In-Sight vision system.
- Read Settings: (RS) Reads the system settings data from a vision system.
- Write Settings: (WS) Sends the system settings data from an external device to the vision system.
- Store Settings: (TS) Stores the vision system settings to the proc.set file.
- Set IP Address Lock: (SL) Prevents unauthorized changes to a vision system's IP address.
- Get IP Address Lock: (GL) Returns the security status of the IP address on a vision system.
Execution & Online Commands
- Set Online: (SO) Sets the vision system into Online or Offline mode.
- Get Online: (GO) Returns the Online state of the vision system.
- Set Event: (SE) Triggers a specified event.
- Set Event and Wait: (SW) Triggers a specified event and waits until the command is completed to return a response.
- Reset System: (RT) Resets the vision system (similar to physically power cycling the vision system).
- Send Message: (SM) Sends a string to the spreadsheet over a Native Mode connection, and optionally, triggers a spreadsheet Event.
Thanks Lowell. Works great!
ReplyDelete