? Program simulation examples
Program Simulation Examples

Program Simulation Example 1

Each time the nn part of the data string [SX] + "#nn" + [EX] + (BCC) as shown in the table below is sent, the number of it is incremented from "00" to "99" by 1 and sent for 100ms intervals.

SX # nn(00~99) EX (BCC)
0x02 0x23 0x30,0x30~0x39,0x39 0x03 (Calculated by LRC-Even etc.)

<[0]Configuration setting>
BCC:LRC-Even
Bigin code:01 02
End code:03 17


Program Description
SET DA 00SX # Set data SX # to data array 00.
SET DA 02EX Set data EX # in data array 02.
SET REG0 000000 Set value 000000 to register 0.
' '
L000 Label L000
SET DV 01 REG0 2 Set the contents of register 0 to data array 01 as a string of 2 characters.
SEND DA 00+REG* Send the data in data array 00.
SEND DA 01+REG* Data array 01 data is sent continuously.
SEND DA 02+REG* Data array 02 data is sent continuously.
SET REG0 INC Increment the value in register 0.
' '
WAIT TM 000100 Wait for 100ms
IF REG0<000100 L000 Compare the value of register 0 with the constant value 000100, and branch to label L000 if the value is less than the constant value.
SET REG0 000000 The value of register 0 exceeds 99, so the value 000000 is set to register 0.
GOTO L000 Jump to label L000.
' '
[ Execution display ]

 

Program Simulation Example 2

While RTS (CTS) is active, send "001" when "ABC" is received, "002" when "DEF" is received, and send "000" if neither is received within 1 second. Also, if RTS (CTS) becomes inactive, terminates the program.


<[1]Interface setting>

Pin:DTE


Program Description
L000 Label L000
WAIT MLT Execute the following consecutive WAIT instructions at the same time and wait until one of the conditions is satisfied.
WAIT CHR A B C Wait until it receives the string A B C.
WAIT CHR D E F Wait until it receives the string D E F.
WAIT LN CTS=0 Wait until the logic of the control line CTS becomes 0.
WAIT TM 001000 Wait until 100ms.
SET REG0 SPR-ST A value indicating the WAIT command that caused the wait state to be released by the WAIT MLT command is set to register 0.
IF REG0=000100 L001 Branches to label L001 when the value of register 0 is 000100 (first WAIT CHR command).
IF REG0=000101 L002 Branches to label L002 when the value of register 0 is 000101 (first WAIT CHR command).
IF REG0=000601 L003 Branches to label L003 when the value of register 0 is 000601 (first WAIT CHR command).
SEND CHR 0 0 0 Send data 0 0 0.
GOTO L000 Jump to label L000.
' '
L001 Label L001
SEND CHR 0 0 1 Send data 0 0 1.
GOTO L000 Send data L000.
' '
L002 Label L002
SEND CHR 0 0 2 Send data 0 0 2.
GOTO L000 Jump to label L000.
' '
L003 Label L003
STOP Program simulation stops.
' '
[ Execution display ]


Program Simulation Example 3

If the 3rd and 4th bytes of the received frame are "$A" it sends "a" and if they are "$B" it sends "b". Otherwise, it sends "c". By pressing [1] key, it changes the condition to "$0" instead of "$A" and "$1" instead of "$B", and returns to the original condition by pressing the [0] key. Also, the program ends when the received frame is less than 4 bytes.


Program Description
SET REGA 000065 Set decimal value 000065 (0x41) to register A.
SET REGB 000066 Set decimal value 000066(0x42) to register B.
L000 Label L000
' '
WAIT MLT Execute the following consecutive WAIT instructions at the same time and wait until one of the conditions is satisfied.
WAIT KEY Wait until a key is pressed.
WAIT FRM CLR Wait until one frame data is received.
SET REG0 SPR-ST A value indicating the WAIT command that caused the wait state to be released by the WAIT MLT command is set in register 0.
IF REG0=000500 L001 Branches to label L001 when the value of register 0 is 000500 (WAIT KEY command).
IF REG0=000200 L002 Branches to label L002 when the value of register 0 is 000200 (WAIT KEY instruction).
GOTO L000 Jump to label L000.
' '
L001 Label L001
SET REG1 SPR-KY The values corresponding to the [0] to [F] keys input during execution by the WAIT KEY command are set in register 1.
IF REG1=000000 L010 Branches to label L010 when the value of register 1 is 000000 ([0] key).
IF REG1=000001 L011 Branches to label L011 when the value of register 1 is 000001 ([0] key).
GOTO L000 Jump to label L000.
' '
L010 Label L010
SET REGA 000065 Set decimal value 000065 (0x41) to register A.
SET REGB 000066 Set decimal value 000066 (0x42) to register B.
GOTO L000 Jump to label L000.
' '
L011 Label L011
SET REGA 000048 Set decimal value 000048 (0x30) to register A.
SET REGB 000049 Set decimal value 000049 (0x31) to register B.
GOTO L000 Jump to label L000.
' '
L002 Label L002
SET REG0 SPR-DL Set the number of data read into the receive frame buffer by the WAIT FRM command to register 0.
IF REG0<000004 L999 Branches to label L999 when the value of register 0 is less than 000004 (number of data).
SET DP 0002 Set 0002 to the data pointer.
SET REG0 SPR-DT Set the data at the data pointer position (3rd byte) of the acquired data to register 0.
IF REG0≠000036 L000 Branch to label L000 when the value of register 0 is not 000036 (0x24).
SET DP INC Increments the value of the data pointer.
SET REG0 SPR-DT Set the data at the data pointer position (4th byte) of the acquired data to register 0.
IF REG0=REGA L041 Branches to label L041 when the value of register 0 is the value of register A.
IF REG0=REGB L042 Branches to label L042 when the value of register 0 is the value of register B.
SEND CHR c Send the data c.
GOTO L000 Jump to label L000.
' '
L041 Label L041
SEND CHR a Send the data a
GOTO L000 Jump to label L000.
' '
L042 Label L042
SEND CHR b Send the data b
GOTO L000 Jump to label L000.
' '
L999 Label L999
STOP Program simulation stops.
' '
[ Execution display ]