๐ค FLEX_PART_HANDLER_2025
A vision-guided, sensor-driven robot program written for modern CNC automation cells. This self-contained demo simulates smart gripper logic, offset pickup, retry-safe loading, and cycle summary handling โ all abstracted for public sharing and educational use.
๐ง Program Highlights (click to expand)
- Modular label-based structure with inline subroutines
- Full inlined
TOOL_LIGHT
logic (no external calls) - Simulated
VOFFSET
via AI vision pickup - Safe retry logic for CNC chuck sequences
- Optional finishing (deburr/polish) logic
- Smart drop positioning with slot indexing
All code, naming, and diagrams are fully rewritten and anonymized for demo purposes. This program is inspired by legacy FANUC motion logic, modernized and abstracted for open learning.
Version 2025.04 โข Author: Automation Upgrade โข Runtime: 12 Labels โข Format: FANUC .LS
๐ Label Explorer
๐ Download full LS format (.txt)
๐ฆ LBL[10] Vision Pickup
102 UTOOL_NUM=1
103 UFRAME_NUM=2
104 MESSAGE[START VISION PICKUP]
105 $WAITTMOUT=R[41:VISION TIME]
106 RUN VISION: FLEX_AI_2025
107 WAIT (F[21:VISION FOUND]=ON) TIMEOUT,LBL[55]
108 PR[2:VISION OFFSET]=[X:23.0, Y:-5.2, Z:0.0, W:0, P:0, R:0]
109 PR[3:APPROACH]=PR[2:VISION OFFSET]
110 PR[3,3]=100
111 P[10:PICK]=500mm/sec CNT100 Offset,PR[3]
112 DO[10:GRIPPER CLOSE CMD]=PULSE,0.2sec
113 WAIT (DI[10:GRIPPER CLOSED]=ON) TIMEOUT,LBL[998]
114 MESSAGE[GRIPPER CONFIRMED CLOSED]
115 MESSAGE[PAYLOAD SET TO MATCH TOOL]
116 JMP LBL[20]
โ๏ธ LBL[20] CNC Load
202 UTOOL_NUM=2
203 UFRAME_NUM=3
204 MESSAGE[LOADING CNC INTERFACE]
205 R[80]=0
206LBL[21:RETRY LOAD]
207 P[20:CNC APPROACH]=750mm/sec CNT50
208 WAIT (DI[110:CHUCK READY]=ON) TIMEOUT,LBL[901]
209 DO[105:OPEN CHUCK]=PULSE,0.2sec
210 WAIT (DI[108:CHUCK OPEN CONFIRM]=ON) TIMEOUT,LBL[901]
211 P[21:CNC INSERT]=250mm/sec FINE
212 DO[11:GRIPPER OPEN CMD]=PULSE,0.2sec
213 WAIT (DI[11:GRIPPER OPEN]=ON) TIMEOUT,LBL[997]
214 MESSAGE[GRIPPER CONFIRMED OPEN]
215 WAIT .2(sec)
216 DO[106:CLOSE CHUCK]=PULSE,0.2sec
217 WAIT (DI[109:CHUCK CLOSED CONFIRM]=ON) TIMEOUT,LBL[901]
218 JMP LBL[30]
๐งฝ LBL[30] Finish (Deburr)
301 IF (R[90]=2), JMP LBL[40]
302 UTOOL_NUM=3
303 UFRAME_NUM=5
304 MESSAGE[STARTING FINISH TOOL]
305 DO[110:TOOL SPIN]=ON
306 P[30:FINISH START]=100mm/sec CNT50
307 WAIT .5(sec)
308 P[31:FINISH SWEEP]=350mm/sec CNT100
309 WAIT .5(sec)
310 DO[110]=OFF
311 JMP LBL[40]
๐ LBL[40] CNC Unload
272 UTOOL_NUM=2
273 UFRAME_NUM=3
274 MESSAGE[UNLOADING CNC]
275 DO[105:OPEN CHUCK]=PULSE,0.2sec
276 WAIT (DI[108:CHUCK OPEN CONFIRM]=ON) TIMEOUT,LBL[902]
277 P[22:UNLOAD POS]=250mm/sec FINE
278 DO[10:GRIPPER CLOSE CMD]=PULSE,0.2sec
279 WAIT (DI[10:GRIPPER CLOSED]=ON) TIMEOUT,LBL[998]
280 MESSAGE[GRIPPER CONFIRMED CLOSED]
281 JMP LBL[50]
๐ ๏ธ LBL[50] Regrip Process
291 UTOOL_NUM=4
292 UFRAME_NUM=6
293 MESSAGE[REGRIP INITIATED]
294 P[40:REGRIP DROP]=500mm/sec CNT50
295 DO[120:REGRIP OPEN]=ON
296 WAIT (DI[121:REGRIP OPEN SENSE]=ON)
297 DO[11:GRIPPER OPEN CMD]=PULSE,0.2sec
298 WAIT (DI[11:GRIPPER OPEN]=ON) TIMEOUT,LBL[997]
299 MESSAGE[GRIPPER CONFIRMED OPEN]
300 WAIT .2(sec)
301 P[41:REGRIP PICK]=250mm/sec FINE
302 DO[10:GRIPPER CLOSE CMD]=PULSE,0.2sec
303 WAIT (DI[10:GRIPPER CLOSED]=ON) TIMEOUT,LBL[998]
304 MESSAGE[GRIPPER CONFIRMED CLOSED]
305 DO[120:REGRIP OPEN]=OFF
๐ LBL[60] Dropoff Logic
311 UTOOL_NUM=2
312 UFRAME_NUM=4
313 R[6]=R[5]*(-150)
314 PR[4:OFFSET]=PR[3:NULL]
315 PR[4,2]=R[6]
316 PR[4,3]=100
317 P[50:DROPOFF]=500mm/sec CNT25 Offset,PR[4]
318 DO[11:GRIPPER OPEN CMD]=PULSE,0.2sec
319 WAIT (DI[11:GRIPPER OPEN]=ON) TIMEOUT,LBL[997]
320 MESSAGE[GRIPPER CONFIRMED OPEN]
321 WAIT .25(sec)
322 R[5]=R[5]+1
323 IF (R[5]>=R[28:MAX DROPS]), R[5]=0
๐ LBL[70] Cycle Summary
331 MESSAGE[=== CYCLE COMPLETE ===]
332 MESSAGE[PART COUNT: R[1]]
333 R[1]=R[1]+1
334 JMP LBL[10]
โ ๏ธ LBL[997โ998] Timeout Handlers
341 MESSAGE[ERROR: GRIPPER OPEN TIMEOUT]
342 UALM[7]
343 JMP LBL[999]
345LBL[998]
346 MESSAGE[ERROR: GRIPPER CLOSE TIMEOUT]
347 UALM[8]
348 JMP LBL[999]
๐ LBL[999] END
361 PR[1:HOME]=P[1:SAFE HOME]
362 PR[1:HOME]=100% FINE
363 MESSAGE[PROGRAM COMPLETE]
364 DO[100:STATUS_END]=ON
.
.
๐ Code Summary: FLEX_PART_HANDLER_2025
A breakdown of the key sections and logic of the FLEX_PART_HANDLER_2025 robot program, explaining the main functions, components, and flow of operations.
All code, naming, and diagrams are fully rewritten and anonymized for demo purposes. This program is inspired by legacy FANUC motion logic, modernized and abstracted for open learning.
๐ Label Breakdown
Below are the primary labels in FLEX_PART_HANDLER_2025, detailing their function and logic in the program. These sections represent the key steps in the robot's processing flow.
๐ฆ LBL[10] Vision Pickup
- Function: Initializes the vision pickup process to detect and position the part using AI vision system.
- Key Logic:
RUN VISION: FLEX_AI_2025
: Calls the vision system to detect the part and determine its offset.PR[2:VISION OFFSET]
: Stores the part's offset to be used later for precise pickup.WAIT (F[21:VISION FOUND]=ON)
: Waits until the vision system confirms that the part is found before proceeding.
โ๏ธ LBL[20] CNC Load
- Function: Loads the part into the CNC machine by positioning the gripper and verifying part placement.
- Key Logic:
WAIT (DI[110:CHUCK READY]=ON)
: Waits for the chuck (CNC clamping mechanism) to be ready before proceeding.DO[105:OPEN CHUCK]=PULSE,0.2sec
: Opens the CNC chuck to allow the part to be inserted.P[21:CNC INSERT]
: Positions the part correctly for CNC insertion based on pre-defined coordinates.
๐งฝ LBL[30] Finish (Deburr)
- Function: Optional deburring or polishing step for parts post-CNC processing to remove any sharp edges or imperfections.
- Key Logic:
DO[110:TOOL SPIN]=ON
: Activates the finishing tool (e.g., deburring tool) to start the operation.WAIT .5(sec)
: Waits for a brief period to allow the tool to complete its initial movement.P[31:FINISH SWEEP]=350mm/sec CNT100
: Sweeps the tool across the part at a specified speed to perform the finishing task.
๐ LBL[40] CNC Unload
- Function: Unloads the processed part from the CNC machine and moves it to a safe position.
- Key Logic:
WAIT (DI[108:CHUCK OPEN CONFIRM]=ON)
: Waits for the chuck to confirm that it has opened before attempting to remove the part.DO[10:GRIPPER CLOSE CMD]=PULSE,0.2sec
: Closes the gripper around the part to ensure it is secured before removal.
๐ ๏ธ LBL[50] Regrip Process
- Function: Regrips the part if needed to reposition or reorient the part for further processing or unloading.
- Key Logic:
DO[120:REGRIP OPEN]=ON
: Opens the regrip mechanism to reposition the part.WAIT (DI[121:REGRIP OPEN SENSE]=ON)
: Waits for confirmation that the regrip mechanism is open.DO[11:GRIPPER OPEN CMD]=PULSE,0.2sec
: Opens the gripper to ensure proper repositioning.
๐ LBL[60] Dropoff Logic
- Function: Drops off the part at the designated dropoff location (e.g., a bin or another machine).
- Key Logic:
PR[4:OFFSET]=PR[3:NULL]
: Calculates the dropoff position for the part based on the robot's current position.DO[11:GRIPPER OPEN CMD]=PULSE,0.2sec
: Opens the gripper to release the part at the dropoff location.
๐ LBL[70] Cycle Summary
- Function: Provides a summary of the entire cycle, including the number of parts processed.
- Key Logic:
MESSAGE[=== CYCLE COMPLETE ===]
: Displays a message when the cycle is completed.R[1]=R[1]+1
: Increments the part count to track the total number of parts processed.
โ ๏ธ LBL[997โ998] Timeout Handlers
- Function: Handles any timeouts that occur during the process, such as when the gripper fails to close or the CNC chuck doesn't open in time.
- Key Logic:
UALM[7]
: Activates an alarm if there is a timeout in the gripper operation.JMP LBL[999]
: Jumps to the program end if a timeout occurs, ensuring that the program fails safely.
๐ LBL[999] END
- Function: Marks the end of the program, returning the robot to a safe home position.
- Key Logic:
PR[1:HOME]=P[1:SAFE HOME]
: Moves the robot to a pre-defined "safe home" position to complete the program.MESSAGE[PROGRAM COMPLETE]
: Displays a message indicating the program has finished successfully.