BRAND.04 / CRnQ-700 + CR800
The BASIC-derived robot language that drives every Mitsubishi CR-series controller.
MELFA BASIC was introduced with the CRn-500 controller in the late 1990s and is still the language of today's CR750, CR751, and CR800 systems. It looks and feels like classic BASIC: line-by-line execution, If…Then branches, For…Next loops, label jumps via *LBL, and sub-routines via GoSub / Return. Motion is expressed with Mov / Mvs / Mvr, I/O through M_Out() / M_In(), and timing through Dly and Wait.
A MELFA BASIC program is plain text that runs top-to-bottom. Labels are written *NAME and become jump / GoSub targets. End marks the program end; control returns to the operator.
Mov P1 GoSub *PICK End *PICK Mvs P2 Return
Mov is joint motion (point-to-point, fastest). Mvs is linear (Cartesian) at the active speed. Mvr is a 3-point arc through an auxiliary position. Spd / JOvrd / Ovrd set speeds.
Spd 500 Mov P1 Mvs P2 Mvr P2, P3, P4
P1..Pn are Cartesian positions (XYZABC + structure). J1..Jn are joint positions. M1..Mn are numeric variables. C1$..Cn$ are strings. All are scoped to the program by default.
Def Pos P_TARGET M1 = 0 C1$ = "READY" Mov P_TARGET
Tool n selects the active TCP frame. Base n selects the active work-object (base) frame. Switching frames mid-program reinterprets all subsequent motion targets.
Tool 1 Base 0 Mvs P1
M_Out(n) writes a digital output bit (0/1). M_In(n) reads a digital input. M_Outb / M_Inb work on 8-bit groups, M_Outw / M_Inw on 16-bit words. HOpen/HClose drive the gripper.
M_Out(1) = 1 Wait M_In(2) = 1 HClose 1
If cond Then stmt [Else stmt] / EndIf for blocks. For M1=1 To 5 / Next M1. While cond / WEnd. GoSub *NAME calls a sub-routine; Return goes back to the caller.
For M1=1 To 5
If M_In(1) = 1 Then GoSub *PICK
Next M1| Instruction | Category | Purpose | Example |
|---|---|---|---|
| Mov | Motion | Joint move (point-to-point, fastest, path not constrained) | Mov P1 |
| Mvs | Motion | Linear (Cartesian) move at the active TCP speed | Mvs P2 |
| Mvr | Motion | Circular move through an auxiliary point (3-point arc) | Mvr P1, P2, P3 |
| Mvr2 | Motion | Circular move with reference point (radius-defined arc) | Mvr2 P1, P2, P3 |
| Mvc | Motion | Full-circle move via two auxiliary points | Mvc P1, P2, P3 |
| Mva | Motion | Arc-spline continuous motion (welding option) | Mva P1, 1 |
| Spd | Motion | Set the linear (Cartesian) speed in mm/s | Spd 200 |
| JOvrd | Motion | Set joint-motion override (% of max) | JOvrd 80 |
| Ovrd | System | Set the global program override (%) | Ovrd 100 |
| Accel | Motion | Set acceleration / deceleration ramp (%) | Accel 100, 100 |
| Cnt | Motion | Enable continuous-path blending (Cnt 1) or stop at point (Cnt 0) | Cnt 1, 100, 100 |
| Fine | Motion | Fine-positioning tolerance — wait until inside window | Fine 0.1 |
| Dly | Wait | Delay program execution for N seconds | Dly 0.5 |
| M_Out() | I/O | Set or read a digital output bit | M_Out(1) = 1 |
| M_In() | I/O | Read a digital input bit | If M_In(2)=1 Then GoTo *PICK |
| M_Outb() | I/O | Write an 8-bit byte to a group of outputs | M_Outb(20) = 5 |
| M_Inb() | I/O | Read an 8-bit byte from a group of inputs | M1 = M_Inb(20) |
| M_Outw() | I/O | Write a 16-bit word to a group of outputs | M_Outw(40) = 1024 |
| HOpen | I/O | Open the gripper (hand) on the given channel | HOpen 1 |
| HClose | I/O | Close the gripper on the given channel | HClose 1 |
| Wait | Wait | Block until a condition becomes true | Wait M_In(1) = 1 |
| WaitM | Wait | Block until a numeric variable matches a value | WaitM M1 = 5 |
| If | Flow | Conditional branch — If cond Then stmt [Else stmt] | If M1>5 Then GoTo *DONE |
| EndIf | Flow | Closes a multi-line If/Then block | EndIf |
| Else | Flow | Optional alternate branch in a multi-line If block | Else |
| GoTo | Flow | Unconditional jump to a label (*LBL) | GoTo *START |
| GoSub | Flow | Call a sub-routine starting at a label, returns via Return | GoSub *PICK |
| Return | Flow | Return from a GoSub sub-routine | Return |
| For | Flow | Counted loop — For M1=1 To 5 Step 1 | For M1=1 To 5 |
| Next | Flow | Closes a For loop | Next M1 |
| While | Flow | Pre-test loop — While cond ... WEnd | While M1<10 |
| WEnd | Flow | Closes a While loop | WEnd |
| Select | Flow | Multi-way branch — Select expr / Case n / End Select | Select M1 |
| Case | Flow | Branch arm inside a Select block | Case 1 |
| End | Flow | End of program execution | End |
| Hlt | Flow | Halt program execution (operator must restart) | Hlt |
| *LBL | Flow | Label definition (jump / GoSub target) | *PICK |
| M1..M99 | Variable | Numeric (real) variables — local by default | M1 = M1 + 1 |
| P1..P99 | Position | Position (Cartesian XYZABC + structure flags) | Mov P1 |
| J1..J9 | Position | Joint position (joint angles J1..J6) | Mov J1 |
| C1$..C9$ | Variable | String variables (terminated with $) | C1$ = "READY" |
| Def | Variable | Declare an explicit variable (Def Inte M1, Def Pos P1) | Def Pos P_TARGET |
| Tool | Frames | Select the active tool (TCP) frame | Tool 1 |
| Base | Frames | Select the active base (work) frame | Base 1 |
| Servo | System | Turn the servo motors on (1) or off (0) | Servo On |
| Reset Err | System | Reset the controller error state | Reset Err |
| XLoad | System | Load and start another program (multitasking) | XLoad 2, "MONITOR" |
| XRun | System | Run a program on a free task slot | XRun 2, "MON" |
| XStp | System | Stop a program running on another task | XStp 2 |
| ' | Misc | Comment to end of line (apostrophe convention) | ' Pick station setup |
| Rem | Misc | Comment line (BASIC convention — same as apostrophe) | Rem Cycle start |
| Misc | Output text to the teaching pendant | Print "Cycle complete" |