MPC-684 Programing tutorials ACCEL Last update May 24,2005 (MPC-684F) This tutorial is an outline for MPC-684 programming. Please see the “MPC-684 User’s manual” for details about products and commands. For the newest information you should look at the web site http://www.accelmpc.co.
Index MPC-684 family ............................................................................................................................................... 5 The feature of the MPC-684 ............................................................................................................................ 6 Program development environment................................................................................................................ 7 Hardware.....................................
Memory I/O................................................................................................................................................. 23 Calculation ..................................................................................................................................................... 24 Pulse generation ............................................................................................................................................ 25 Initial settings ..........
Timer........................................................................................................................................................... 43 Task Operation ........................................................................................................................................... 43 Debug.......................................................................................................................................................... 43 Bus Access ................
MPC-684 family Outline of MPC-684 series MPC-684 main CPU board serial communication port (RS-232) 3ch 4 outputs 8 inputs MOP-096 output board 96 transistor open-collector outputs max 4 boards in a system. MOP-048 output board 48 transistor open-collector outputs max 8 boards in a system. MIP-096 input board 96 photo-coupler isolated inputs max 4 boards in a system. MIP-048 input board 48 photo-coupler isolated inputs max 8 boards in a system.
The feature of the MPC-684 Program capacity 500Kbytes( about 25000 lines) Point data 4 by 13000 points Global variable 2000 Local variable 26 ( each task ) Task from 0 to 31 RS-232 buffer 256 bytes each ports Real time clock not supported but you can use the touch panel clock I/O 8 inputs 4 outputs Loading power supply DC5V 2A (with assisted cooling modifications 3A) Others string variable, co-processor (option) 2-4M flash ROMs 2-4M static RAMs co-processor MC68882FN25 (option) MPC-684
Program development environment Hardware Personal computer OS: Microsoft Windows supported Programming cable Connect to a MPC-684 and a personal computer by RS-232. If the personal computer doesn’t have a RS-232 port, you should use a USB-RS converter Software You can install software for MPC programming by “Setup Disk”. You can down-load it from the ACCEL web site. Main software FTMW32E.
How to connect Connect a personal computer to the MPC by the programming cable, then turn the MPC on. MPC-684 FTMW32E MPC-684F CEP-104B ACCEL CORP J1 Programming Cable power DC24V 1 2 GND 3 FG 4 SG 1 1 CD TX0 2 2 RXD RX0 3 3 TXD SG 4 4 DTR MAN 5 5 SG P5 6 6 DSR Windows PC Computer COM Port (D-SUB 9) 7 RTS 8 CTS 9 CI After FTMW32E starts, set up the PC’s comm port number and comm speed in the “Settings” window after that click “MPC-684” button.
When it is able to connect normally, an opening message will display on the edit screen. Opening message Prompt (Edit screen) The meaning of the opening message Version number of MPC-684 system data MPC-684 ADVFSC(r)eREV-3.82r BASIC like + multi tasking Created by ACCEL Co.
Input commands There are 3 types of input control. Direct executed commands: Single command statements executed immediately. Program executed commands: A series of commands executed from a program after initiating the run command. Bilateral commands: Both directly executed commands and program executed commands. Most commands are bilateral.
I/O check There are 2 ways to check input and output conditions. To check by command The following are commands used to complete a basic I/O check. #ON 0 #OFF 0 #PR SW(0) 1 #PG &H400 #PRX HPT(0) 0005 /* /* /* /* turn the OUTPUT 0 on turn the OUTPUT 0 off The state of an INPUT 0 ("PR" is short for "PRINT") 0=off,1=on /* check of MPG-314 origin sensor port (connecter J4) /* SX1(J4 No.11 pin) and SY1(J4 No.
You can check about MPG-314's INPUT by "INCHK_314" command.
How to input program To write a program include a line number before the command. Press the enter key after writing each command, so it can be transmitted to the MPC. If error messages come out, please check whether there is any mistake in grammar and input again. 10 'this is sample program 20 DO 30 FOR I=0 TO 48 40 ON I : TIME 100 50 NEXT I 60 LOOP 70 pri I .....This command is not supported.
Subroutine A subroutine is a piece of code, much like any code in a program. A subroutine has an entry point and an exit point. At the entry of a subroutine, the system remembers where to resume execution when the subroutine finishes. When the subroutine finishes, the system resumes execution at this location. If you make subroutines for each job, you can access them from the main routine, it will be easier to read and customize a program.
Parameter of subroutine, return value You can set a subroutine with parameters. The parameter values are activated by the main routine using the 'VAR' command. The command 'RETURN' ends the subroutine's program and commences the main routines next step. If the value combines with a local variable, some tasks can share the subroutine.
Edit of a program Explanation of useful operations for editing a program LIST display ‘LIST’ is the command used most. LIST [n,m] n: Start line number or LABEL m: The number of lines to display You can view the program's first block of code by entering 'LIST' ( figure 16-1), if you enter 'LIST' once more it will display the next block. And so on consecutively. You can specify a line number or label to view by inputting it in the first parameter.
Insert statement 10 20 30 40 *LOOP ON 0 OFF 0 GOTO *LOOP 10 20 30 40 25 TIME *LOOP ON 0 OFF 0 GOTO *LOOP 50 Move cousor to the 30th line then press 'Ctrl+N'. Input the new string and line number that you want to insert.
Other key operations 18
How to program save to the PC, load from the PC Program save to the PC You can save the program to your PC by pushing 'F9' then selecting 'Program Save' from the menu. The program is saved under the extension 'F68'. Saved programs don't have line numbers.
Program load from the PC You can load the program from your PC by pushing 'F9' then selecting 'Program Load' from the menu. Line numbers are in intervals of ten by default. If it exceeds 6000 it will be 'RENUM' to intervals of 5 automatically. Off line editing Unless FTMW is connected with the MPC, it cannot be used, however you can create a program off-line using ‘MPCED’ or another common editor. Printing FTMW cannot print a program. Please print the file saved in the PC by MPCED or another editor.
I/O control You can control an I/O Port for every bit or byte. Bit operating is for simple device control. ex. solenoid valves, relays and switches etc. Byte operating is used for reading DSW, data exchange with external devices etc. Bit control ON 0 OFF 1 WAIT SW(192)==1 IF SW(1)==1 THEN : GOTO *LABEL : END_IF ON -1 WAIT SW(-2)==0 /* /* /* /* /* /* output #0 turn on output #1 turn off wait for input #192 to turn on conditional branch negative number = memory I/O.
Variable, Array variable, String variable, Memory I/O MPC-684 has a lot of variables, array variables, string variables and memory I/Os. These are in integers of 4 bytes. Variables and array variables are used for calculation, counting as usual. Memory I/Os are usually used for interlocking tasks. Most commands and functions can use constants, variables and array variables in their parameters. You can control memory I/Os as usual by using ON, OFF, OUT, SW commands.
Array variable A DIM command secures specific array variable partitions in the memory. 10 20 30 40 DIM ARRY(100) FOR I=0 TO 99 ARRY(I)=I NEXT I /* secure ARRY(0) ARRY(99) You can use two-dimensional arrays. 10 DIM ARRY(2,3) Point data is also a kind of array variable. You can save (load) the point data to the PC. The PLS command displays the point data list.
Calculation + * / % & | ¥ addition substruction multiplication division surplus logical multiplication (AND) logical addition (OR) exclusive-OR (XOR) A=B+C A=B-C A=B*C A=B/C A=B%C A=B&C A=B|C A=B¥C The integers are 4 bytes in value. The final value is always truncated to it’s decimal point. 10 20 30 RUN 2 A=5 B=A/2 PRINT B The calculation below is in accordance with general arithmetic operation.
Pulse generation This chapter introduces pulse generating using the MPG-314 board. It explains how to utilize the MPG-314 for an XY robot. Initial settings Initialize the setting on the MPG-314 board before using it. At first you have to assign the MPG-314 board to any Tasks by using the PG command. Next, you set the MPG-314 board using ACCEL, FEED etc. You can do this by direct command, but you have to write the commands in your program.
Setup of maximum high speed and acceleration. Maximum high speed and acceleration can be set by using the ACCEL command. Drive speed can be decided by using the FEED command.
Move to the origin (HOME) HOME is the command for programming the movement of a robot back to the staring point of its action. Format HOME n rate cond [n1 rate1 cond] n: axis constant X_A Z_A rate: pulse rate (pps) cond: input condition INx_ON INx_OFF Y CW CCW CW X CCW YS1 (Y origin) XS1 (X origin) XS1=the 11th pin of J4 connector on the MPG-314 board. YS1=the 13th pin of J4 connector on the MPG-314 board.
Absolute coordinate movement 1) MOVL is the command for linear interpolation. You can give variables or constants to define the parameters. 5000 Y 10 20 30 40 50 60 PG &H400 ACCEL 5000 /* acceleration/deceleration setting FEED ALL_A 128 /* speed setting CLRPOS MOVL 5000 5000 VOID VOID WAIT RR(ALL_A)==0 X 0 0 5000 2) Also, you can give a teaching point to the MOVE command parameter. The teaching points are set by using the 'teaching mode' or by programming.
Relative coordinate movement 1) RMVL is the command for linear interpolation of relative coordinate movement. You can give variables or constants to define the parameters. 5000 Y I=5 I=4 I=3 1000 0 I=2 I=1 0 1000 X 10 20 30 40 50 60 70 80 PG &H400 ACCEL 5000 FEED ALL_A 0 CLRPOS FOR I=1 TO 5 RMVL 1000 1000 0 0 WAIT RR(ALL_A)==0 NEXT I 5000 2) The RMVS command is similar to the RMVL command but it doesn't have linear interpolation.
Continuous interpolation The following figure is an example of continuous interpolation by using the MOVT command. It sets point data between the 10 line and the 50 line. In this case, P(100) is the base point of the coordinates. P(101)~P(104) are local points (relative coordinates to the base point). The MPC interpreter reads a MOVT command then executes it. The MPC interpreter reads the next program step while the previous step is being executed.
PALET declaration PALET is the command for moving between palettes. The PALET command calculate all working points (PLn(N)) on a palette by using 3 teaching points.
Conditional stop Pulse generation stops after sensors receive data indicating the need for the stop condition to take effect. 1) The STOP command executes after the MOVL command. You can use normal input ports (on the MIP, IOP board) for the stop parameters.
Multi-task MPC-684 has 32 tasks ( task0 : Main-task. task1~31 : sub-tasks) Main-task executes immediately after the RUN command (program mode) or MPC-684 power-on (auto mode). Sub-tasks are executed from main-task. There isn't any prioritization of sub task. A sub task can execute or cancel out other sub tasks. The commands for multi-task FORK,END,QUIT The FORK command executes a sub-task. The task is cancelled by the END command included in that task or by using the QUIT command in a different task.
RS-232 communication MPC-684 has two RS-232 communication ports for interfacing to external devices. You can control the ports by using commands. One of the ports supports interfacing with the GP touch-panel (Digital corporation). You can add more communication ports by using the MRS-402 board (max 4ch.
Debugging Basic debugging (run/stop/check) One useful basic process of debugging of the MPC is by executing the program, stopping it and then checking previous tasks program steps. For instance, if a machine that is in operation stops, you can look for the cause of stoppage. FTMW displays the stop lines of each task by using 'Ctrl+M'.
How to know the cause of machine stoppage When the machine stops while in automatic operation, please connect the MPC-684 to FTMW without turning off the power supply of the machine. << The machine stopped! Why? Connect to FTMW soon! >> VER MPC-684 ADVFSC(r)eREV-3.82v BASIC like + multi tasking Created by ACCEL Co.
Special program The prompt returns to the FTMW when task 0 is ended using the END command. Then you can execute the commands for an I/O and variable's value, checks. *The program currently being executed stops when you modify the program. *You can't use Ctrl+A for program stop. Use Ctrl+] instead.
Use touch panel The MPC-684 supports the 'Direct access protocol' on the Digital Electron Corporation’s GP series touch panel. You can select MBK-RS (by using J2 on the MPC-684) or the MBK-SH board for communication to the GP. The MPC-684 has a 1000 words data area and a 100 words I/O area of memory capacity. When you use MBK-RS You have to write 'PROTOCOL MEWNET' at top of the program. 10 PROTOCOL MEWNET You can't use the MBK-RS and the RS-232 CH0 at the same time.
When you use MBK-SH The MBK-SH connects to the touch panel at RS-422 38400bps. The MBK-SH board is an independent CPU board, therefore doesn't put strain on the main CPU board. You can use the MBK-SH for communication with another controller. MBK-SH RS-232/422 9600/19200/38400bps Personal computer Omron, Mitsubishi, Matsushita controller MBK-SH CEP-098A MPC-684 ACCEL CORP.
Command List I/O ? ALT CLR_OUTP HIN HIN HOUT HPT HSW IN IO IOR IOW OFF ON OUT P_HSW P_IN P_IN P_OFF P_ON P_OUT P_SW SENSE_SW SETIO SW WS0 WS1 Reading of Bit (HSW Alternative) Switch ON/OFF Initialize Output (specified the board) Parallel Input Parallel Input (Read 4 bytes) Pulse Board General Output Pulse Board General Input Read Bit Parallel Input I/O Monitor Read BUS Write BUS Output off Output on Parallel Output Output/Input of MPC-684 J4 Connector Output/Input of MPC-684 J4 Connector High Speed Input M
HPT INCHK_314 INSET_314 M_RMVS MOVL MOVS MOVT PG PLSC PRSET_ACCEL RANGE RMVC RMVL RMVS RMVT RR STOP STPS STPS U WARP X Y Z Read Input Port Input Monitor Set Input Port Function Asymmetric Acceleration/Deceleration Move Linear Interpolation (Absolute Coordinate Move) Axis Independent Pulse Generation (Absolute Coordinate Move) Continuous Interpolation (Absolute Coordinate Move) PG Declaration Pulse Generation at a Constant Speed Reset ACCEL Parameter Operative Restriction Infinite Pulse Generation Linear In
PALET4 PG PGSEL PL1 PL2 PL3 PL4 PULSE Q_PAUSE RANGE RM RMOV RMVZ SET SETP SETPOS SHMZ SHOM STOP TEACH U X Y Z PALET Declaration PG Declaration PG Declaration Palette Point Palette Point Palette Point Palette Point Pulse Generation at a Constant Speed Quick Pause Operative Restriction 4-axis Relative Coordinate Move XYU-axis Relative Coordinate Move Z-axis Relative Coordinate Move Setting Inching Amount Sets point data Change Current Value Setting Return to the Origin Setting Return to the Origin Stop Pulse
Floating Point Operation CALF GETF PRF SETF Arithmetics Retrieve Data Display Internal Data Delivery of Data System FCLK MPC Change Clock Speed MPC-816 COMPATIBLE Timer SYSCLK TIME TMOUT System Clock Wait Time Set Input Time Task Operation CONT FORK LIFE_TIME PAUSE QUIT RLS RSV SWAP TASKN Continue Task Task Execution Set the Life Time of Task Pause Task Stop task Release Semaphore Semaphore capture Abandonment of Execution Task Number Get Debug CNT DUMP FIND FIX LOG MON RAM ROM RUN TASK TOFF TON Co
Memory Access PEEK POKE Readout of User Memory Write User Memory Maintenance ERASE MEM MPCINIT TMON VER Clear Program of Flash ROM Memory Test Initialize RAM Area Task Monitor Version Data Display User Command ADR COMSET Obtain the address Setting of Command Name Arithmetic @ ABS AND ATAN ATAN2 CONST COS DIM DIM LET NOT OR SFTL SFTR SIN SQ SQR SWP TAN Logical Negation Absolute value Logical Sum Expression (Logical Multiplication) Trigonometric Function Trigonometric Function Conversion from variable
GOSUB GOTO IF LOOP NEXT _RET_VAL RETURN RETURN SELECT_CASE THEN UNTIL _VAR WAIT WEND WHILE Subroutine Call (Argument Pass) Unconditional Branch Conditional Branch Loop Loop Receipt of Return Value Return Return Value Passing Conditional Branch Dependent On Value Conditional Branch Conditional Statement Receipt from Arguments Wait for a condition Condition Loop Condition Loop String AR$ ASC CHR$ DIM_AR$ DIMCPY GET_VAL HEX$ LEN STR$ STRCPY VAL VER$ String Arrays Conversion from String to ASCII Conversion f