# Sending User Data from the PLC

Rung 1: copies the raw assembly input bytes into a structure (IS2800_I) which defines the tag meanings for the bits and words. The reverse is true for the output assembly byte data. Data from the defined structure (IS2800_O) is copied from the structure into the raw assembly output bytes. This rung needs to be used when using EDS generated profiles (Electronic Data Sheet, .eds file) since no tag names are created when the profile is added to the PLC project. Rung 1 is updated every scan of the PLC logic since there are no input conditions on the rung. In the following sections the vision system signal tags are described using only the tag name and not the prepended IS2800_I.Status or IS2800_O.Control portion of the tag. Internal PLC tags use the full tag name.

Rungs 3 and 4 comprise the writing of User Data to the vision system from the PLC.

Rung 3: You need to manually set the CAM_IS2800.Start_User_Data_Write (internal PLC tag) to initiate the sequence of writing User Data. The next 4 bits in the XIO's (Examine if open) on that rung is cleared to 0 allowing the output instructions of the rung to run.

The 4 bits are SetUserDataAck (cleared to 0 until SetUserData is set and acknowledged in vision system), CAM_IS2800.User_Data_Sent (interlock bit used with trigger and job change, cleared to 0 until User Data is sent), CAM_IS2800.Running_Job_Change (interlock bit used with User Data and trigger, cleared to 0 since not running job change logic) and CAM_IS2800.Trigger_Cycle. Interlock bit used with User Data and job change, cleared to 0 since not running trigger logic.

The COP instruction copies string data from an internal PLC tag to the User Data portion of the output assembly. String data was chosen since it is the most difficult to work with when sending user data, especially if the length of the string varies. The Source in the COP is the byte array portion of the string data starting at byte 0. The Dest is the first byte (0) of the output assembly User Data. The Length parameter can be a constant if the string length does not vary, but if it does vary the Source string length (.LEN) needs to be used for this.

Once the User Data is copied into the output assembly the SetUserData bit is set to 1 as well as the CAM_IS2800.Start_User_Data_Write bit. Both bits stays set until the SetUserDataAck bit is returned set to 1 from the vision system.

Rung 4: This rung only latches the CAM_IS2800.User_Data_Sent bit once the SetUserDataAck bit is received and is set to 1. When it is set to 1 that causes rung 3 to clear to 0 the SetUserData and CAM_IS2800.Start_User_Data_Write bits. Once the CAM_IS2800.Start_User_Data_Write bit is seen cleared to 0 in rung 4 and SetUserDataAck is set to 1 this causes the CAM_IS2800.User_Data_Sent bit to latch on to value of 1. This bit is set to one to allow the optional triggering operation to happen automatically or manually and visually shows that the sending of the User Data sequence is completed. It must be cleared to 0 in order to send more User Data (as seen in rung 3, the second XIO instruction). This can be done manually on the Latch bit itself, in the controller tags list or in rung 11 noted below.

Note: The User Data buffer in the vision system is not cleared in between sending of new User Data or after the Spreadsheet runs after a trigger. The data remains in the buffer and changing jobs and reading User Data still reads in stale User Data. This data must be cleared manually from the PLC or new User Data written in order to not have stale User Data. This behavior is apparent when sending strings in the User Data and the string lengths vary. If a string 8 characters long is sent (not including"Check_AB") and then a string 6 characters long is sent (not including "Square") the string read becomes "SquareAB" unless the PLC logic adjusts and knows to read only the 6 characters such that "Square" gets read in. Another solution could be to append or pad the string with nulls so if "Square$00$00" is sent and read into the Spreadsheet, the result would be "Square".