BRAND.04 / CR750 + CR800
The BASIC-style robot language of Mitsubishi's CR-series controllers.
MELFA BASIC V runs on the CR750 and CR751 and on the older CRnD-700 and CRnQ-700 controllers; the CR800 runs MELFA BASIC V and VI. A program is plain text that runs line by line, with If…Then branches, For…Next and While…WEnd loops, *LABEL jump targets and GoSub / Return subroutines. Motion is Mov (joint), Mvs (linear) and Mvr (arc); I/O is M_Out() and M_In(); timing is Dly and Wait. The first letter of a variable sets its type: P for a pose, J for joint angles, M for a number, C with a trailing $ for a string.
A program runs from its first line to End, which hands control back to the operator. A label is a line that starts with an asterisk, such as *PICK, and it is the target of GoTo and GoSub. GoSub jumps to the label and Return comes back to the line after the GoSub, so the usual layout is the main flow first, End, and the subroutines below it.
On a real cellPut End before the first label. Without it the main flow runs straight on into the subroutine underneath and reaches a Return that no GoSub called.
Mov P1 GoSub *PICK End *PICK Mvs P2 Return
Mov is joint interpolation. All axes start and finish together, so it is the quickest move, but the TCP (tool centre point) follows a curve. Mvs is linear interpolation: the TCP travels in a straight line at the Spd speed. Mvr draws an arc from a start point through a transit point to an end point. Mov and Mvs both accept a close distance: Mov P1, -50 ends 50 mm back from P1 along the tool Z axis, which is how most approach points are written.
On a real cellUse Mov through open air and Mvs for the last 30 to 50 mm into a fixture. A joint move that ends inside a nest can swing the wrist through the fixture on the way in, because nothing keeps the path straight.
Spd 200 Mov P1, -50 Mvs P1 Mvr P2, P3, P4
Spd sets the speed in mm/s for Mvs and the arc moves. JOvrd scales joint moves in percent. Ovrd, 1 to 100 %, scales every move, and the override on the teaching pendant or operation panel scales it again, so Spd 500 with Ovrd 50 and the pendant at 50 % moves at about 125 mm/s. Cnt 1 lets the robot blend through points without stopping and Cnt 0 switches that off. Fine sets how many encoder pulses from the target count as arrived; it has no effect while Cnt 1 is on.
On a real cellCnt 1 means the robot does not stop on the point. Switch to Cnt 0 before the move that ends at a pick or place, so the arm is on the point when the gripper output changes.
Ovrd 50 Spd 300 JOvrd 80 Cnt 1 Mvs P1 Cnt 0 Mvs P2
A P variable is a Cartesian pose: X, Y, Z in mm and A, B, C in degrees, plus structure flags (FL1, FL2) that record the arm configuration, such as elbow above or below and wrist flipped. A J variable holds one angle per axis. The first letter sets the type: P1 is a pose, J1 a joint position, M1 a number and C1$ a string. Def gives a variable an explicit type and any name, for example Def Pos PSAFE, and P_Curr returns the current position.
On a real cellTwo P values with the same X, Y, Z, A, B, C but different flags put the arm in different configurations. When you copy points between programs or robots, check the flags as well as the coordinates.
Def Pos PSAFE M1 = 0 C1$ = "READY" PSAFE = P_Curr Mov PSAFE
Tool sets the tool conversion data, the offset from the flange to the TCP, as X, Y, Z, A, B, C: Tool (0, 0, 95, 0, 0, 0) puts the TCP 95 mm out from the flange. M_Tool = 2 selects tool data stored in parameter MEXTL2 instead. Base shifts or rotates the robot coordinate system, either with conversion data or with a base coordinate number such as Base 1. Every P target after the change is read in the new frame.
On a real cellWith a wrong tool length Mvs still moves in a straight line, but about the wrong point. Change only the orientation at a fixture and the tip swings through an arc instead of turning in place. Measure the TCP before you teach points.
Tool (0, 0, 95, 0, 0, 0) Base 1 Mvs P1
M_Out(n) = 1 switches output bit n on and M_In(n) reads input bit n. M_Outb and M_Inb move 8 bits at once and M_Outw and M_Inw 16 bits, which is how a part number or recipe code passes to and from the PLC. Writing Dly after an output makes a timed pulse: M_Out(17) = 1 Dly 0.5. HOpen n and HClose n drive the hand outputs configured in the controller.
On a real cellWait M_In(2) = 1 has no timeout and waits forever if the sensor never switches. On a production cell, watch the signal with Def Act or a timed loop and send the operator a fault they can see.
M_Out(1) = 1 Wait M_In(2) = 1 M_Outb(20) = &H0F M_Out(17) = 1 Dly 0.5 HClose 1
If cond Then stmt Else stmt fits on one line. The block form opens with If cond Then, closes with EndIf and may hold an Else. For M1 = 1 To 5 ... Next M1 counts, While cond ... WEnd tests before every pass, and Select / Case / Break / End Select picks a branch from a value. Def Act sets up an interrupt that calls a label with GoSub when its condition becomes true while the program runs.
On a real cellKeep GoTo for jumping to an error handler. Loops built from GoTo and labels are hard to follow on the pendant, and that is where the next person will read them.
For M1 = 1 To 5
If M_In(1) = 1 Then GoSub *PICK
Next M1| Instruction | Category | Purpose | Example |
|---|---|---|---|
| Mov | Motion | Joint interpolation from the current position to the target. Fastest move; the TCP path is not a straight line. An optional second value is a close distance along the tool axis, so Mov P1, -50 ends 50 mm back from P1 along the tool Z axis. | Mov P1 |
| Mvs | Motion | Linear interpolation: the TCP travels in a straight line at the Spd speed. Use it for the last approach into a fixture. Mvs , 100 moves 100 mm along the tool axis from where the robot is. | Mvs P2 |
| Mvr | Motion | Arc from a start point through a transit point to an end point (three taught points on the arc). | Mvr P1, P2, P3 |
| Mvr2 | Motion | Arc from a start point to an end point. The third point is a reference that sets the circle; the robot does not pass through it. | Mvr2 P1, P2, P3 |
| Mvr3 | Motion | Arc from a start point to an end point around a taught centre point. | Mvr3 P1, P2, P3 |
| Mvc | Motion | Full circle: start point, transit point 1, transit point 2, and back to the start point. | Mvc P1, P2, P3 |
| Mva | Motion | Arch motion (up, across, down) to the target, using an arch shape defined with Def Arch. Common on SCARA pick-and-place. | Mva P2, 1 |
| Spd | Motion | Speed in mm/s for linear and circular moves (Mvs, Mvr, Mvc). Spd M_NSpd selects the optimum-speed mode. | Spd 200 |
| JOvrd | Motion | Override in % that applies only to joint moves (Mov). | JOvrd 50 |
| Ovrd | System | Program speed override, 1 to 100 %. It scales every move on top of Spd and JOvrd, and the pendant override scales it again. | Ovrd 50 |
| Accel | Motion | Acceleration and deceleration as % of the maximum. Lower values protect a heavy or loose part. | Accel 50, 100 |
| Cnt | Motion | Continuous-path (blended) motion. Cnt 1 blends through points, Cnt 0 stops at each one. The optional numbers set how close to the point the blend begins and ends. | Cnt 1, 100, 200 |
| Fine | Motion | Positioning-complete condition as a number of encoder pulses, optionally for one axis. It has no effect while Cnt 1 is active. | Fine 300 |
| Dly | Wait | Wait for a time in seconds. Written after an output (M_Out(17)=1 Dly 0.5) it makes a timed pulse. | Dly 0.5 |
| M_Out() | I/O | Write or read one external output bit. | M_Out(1) = 1 |
| M_In() | I/O | Read one external input bit (1 = on). | If M_In(2) = 1 Then GoTo *PICK |
| M_Outb() | I/O | Write 8 consecutive outputs as a byte, starting at the given bit. | M_Outb(20) = &HFF |
| M_Inb() | I/O | Read 8 consecutive inputs as a byte, starting at the given bit. | M1 = M_Inb(20) And &H7 |
| M_Outw() | I/O | Write 16 consecutive outputs as a word, starting at the given bit. | M_Outw(40) = 1024 |
| HOpen | I/O | Open hand (gripper) number n, using the hand outputs set up in the controller parameters. | HOpen 1 |
| HClose | I/O | Close hand number n. | HClose 1 |
| Wait | Wait | Hold the program until a variable or signal equals the given value. | Wait M_In(1) = 1 |
| If | Flow | Branch. One line: If cond Then stmt [Else stmt]. Block form: If cond Then, lines, Else, lines, EndIf. | If M1 > 5 Then GoTo *DONE |
| EndIf | Flow | Closes a block If. | EndIf |
| Else | Flow | Alternative branch of an If. | Else |
| GoTo | Flow | Jump to a label. | GoTo *START |
| GoSub | Flow | Call the subroutine that starts at a label; Return comes back to the line after the GoSub. | GoSub *PICK |
| Return | Flow | End a GoSub subroutine. After an interrupt routine, Return 0 or Return 1 picks whether to resume at the interrupted line or the next one. | Return |
| For | Flow | Counted loop: For M1 = 1 To 10 [Step n] ... Next M1. | For M1 = 1 To 5 |
| Next | Flow | Closes a For loop. | Next M1 |
| While | Flow | Loop while a condition is true: While cond ... WEnd. | While M1 < 10 |
| WEnd | Flow | Closes a While loop. | WEnd |
| Select | Flow | Multi-way branch: Select expr, Case n ... Break, Default ... Break, End Select. | Select MCNT |
| Case | Flow | One arm of a Select block. Accepts a value, a range (Case 12 To 18) or Case Is <= 10. | Case 1 |
| End | Flow | Last line of the program. | End |
| Hlt | Flow | Stop the program and the robot motion. The operator restarts it. | Hlt |
| *LBL | Flow | Label: a jump or GoSub target written as *NAME. | *PICK |
| Def Act | Flow | Define an interrupt: watch a condition during the program and GoSub to a label when it becomes true. | Def Act 1, M_In(17) = 1 GoSub *STOP1 |
| M… | Variable | Numeric variable: any name starting with M (M1, MCNT). | M1 = M1 + 1 |
| P… | Position | Position variable: X, Y, Z in mm, A, B, C in degrees, plus structure flags (FL1, FL2) that fix the arm configuration. | Mov P1 |
| J… | Position | Joint variable: one angle per axis (J1 to J6). | Mov J1 |
| C…$ | Variable | String variable: a name starting with C and ending in $. | C1$ = "READY" |
| Def | Variable | Declare a variable with an explicit type and any name: Def Inte, Def Float, Def Double, Def Pos, Def Jnt, Def Char. | Def Pos PSAFE |
| Tool | Frames | Set the tool conversion data (TCP offset from the flange) as X, Y, Z, A, B, C. | Tool (0, 0, 95, 0, 0, 0) |
| M_Tool | Frames | Select stored tool data by number (parameters MEXTL1 to MEXTL4). | M_Tool = 2 |
| Base | Frames | Shift or rotate the robot coordinate system, either with conversion data or a base coordinate number. | Base 1 |
| Servo | System | Servo power on or off from the program. | Servo On |
| Reset Err | System | Reset the error currently raised in the controller. | If M_Err = 1 Then Reset Err |
| XLoad | System | Load a program into another task slot (multitasking). It does not start it. | XLoad 2, "10" |
| XRun | System | Start the program in another task slot so it runs alongside this one. | XRun 2 |
| XStp | System | Pause the program running in another task slot. | XStp 2 |
| ' | Misc | Comment to the end of the line. | ' Pick station setup |
| Rem | Misc | Comment line, same as the apostrophe. | Rem Cycle start |
| Open | Misc | Open a file or a communication line (for example COM1:) under a file number. | Open "COM1:" As #1 |
| Misc | Send data to a file or communication line opened with Open. | Print #1, "PARTS=", M1 |