EasyManua.ls Logo

Mitsubishi Electric CR760-D - Page 227

Mitsubishi Electric CR760-D
730 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 V
Detailed explanation of command words 4-207
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, M_Inw and
M_Outw are used in the case of 16-bit words, and M_In32, M_Out32 are used in the case of 32-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 DWord(32bit).
<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.
(4) Assign the input variable named PORT4 to input/output signal number 16 in dword type, and specify the
mask information as 3FFFFF in hexadecimal.
1 Def IO PORT4 = DWord, 16, &H3FFFFF
:
10 PORT4 = 65536 ' Output signal number 48 turns on.
Def[]IO[]<Input/output variable name> = <Type designation>, <Input/output bit No.>
[, <Mask information>]

Table of Contents

Related product manuals