EasyManua.ls Logo

Mitsubishi MELFA CR1D - Page 199

Mitsubishi MELFA CR1D
458 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
4MELFA-BASIC IV
Detailed explanation of command words 4-186
Def IO (Define IO)
[Function]
Declares an input/output variable. Use this instruction to specify bit widths. M_In and M_Out variables are
used for normal single-bit signals, M_Inb and M_Outb are used in the case of 8-bit bytes, and M_Inw and
M_Outw are used in the case of 16-bit words.
Be aware that it is not allowed to reference output signals with variables declared using this instruction.
[Format]
[Terminology]
<Input/output variable name> Designate the variable name.
<Type designation> Designate BIT(1bit), BYTE(8bit), WORD(16bit) or INTEGER.
<Input/output bit No.> Designate the input(When referencing) or output(When assigning) bit No.
<Mask information> Designate when only a specific signal is to be validated.
[Reference Program]
(1) Assign the input variable named PORT1 to input/output signal number 6 in bit type.
1 Def IO PORT1 = BIT,6
:
10 PORT1 = 1 ' Output signal number 6 turns on.
:
20 PORT1 = 2 ' Output signal number 6 turns off.(Because the lowest bit of the numerical value 2 is
0.)
21 M1 = PORT1 ' Substitute the state of the input signal number 6 for M11.
(2) Assign the input variable named PORT2 to input/output signal number 5 in byte type, and specify the
mask information as 0F in hexadecimal.
1 Def IO PORT2 = BYTE, 5, &H0F
:
10 PORT2 = &HFF ' Output signal number 5 to 8 turns on.
:
20 M2 = PORT2 ' Substitute the value of the input signals 5 to 8 for the variable M2.
(3) Assign the input variable named PORT3 to input/output signal number 8 in word type, and specify the
mask information as 0FFF in hexadecimal.
1 Def IO PORT3 = WORD, 8, &H0FFF
:
10 PORT3 = 9 ' Output signal number 8 and 11 turns on.
:
20 M3 = PORT3 ' Substitute the value of the input signals 8 to 19 for the variable
M3.
Def[]IO[]<Input/output variable name> = <Type designation>, <Input/output bit No.>
[, <Mask information>]

Table of Contents

Related product manuals