Skip to main content

This is a section of commonly found in the controller user manuals.

Controller is connected to OPTO-22 via handle F. The OPTO-22’s IP address is 131.29.50.30. The Rack has the following configuration:

Digital InputsModule 1

Digital OutputsModule 2

Analog Outputs (+/-10V)Module 3

Analog Inputs (+/-10V)Module 4

Instruction

Interpretation

#CONFIG

Label

IHF=131,29,50,30<502>2

Establish connection

WT10

Wait 10 milliseconds

JP #CFGERR,_IHF2=0

Jump to subroutine

JS #CFGDOUT

Configure digital outputs

JS #CFGAOUT

Configure analog outputs

JS #CFGAIN

Configure analog inputs

MBF = 6,6,1025,1

Save configuration to OPTO-22

EN

End

#CFGDOUT

Label

MODULE=2

Set variable

CFGVALUE=$180

Set variable

NUMOFIO=4

Set variable

JP #CFGJOIN

Jump to subroutine

#CFGAOUT

Label

MODULE=3

Set variable

CFGVALUE=$A7

Set variable

NUMOFIO=2

Set variable

JP #CFGJOIN

Jump to subroutine

#CFGAIN

Label

MODULE=5

Set variable

CFGVALUE=12

Set variable

NUMOFIO=2

Set variable

JP#CFGJOIN

Jump to subroutine

#CFGJOIN

Label

DM A[8]

Dimension array

I=0

Set variable

#CFGLOOP

Loop subroutine

A[I]=0

Set array element

I=I+1

Increment

A[I]=CFGVALUE

Set array element

I=I+1

Increment

JP #CFGLOOP,I<(2*NUMOFIO)

Conditional statement

MBF=6,16,632+(MODULE*8),NUMOFIO*2,A[]

Configure I/O using Modbus function code 16 where the starting register is 632+(MODULE*8), number of registers is NUMOFIO*2 and A[] contains the data.

EN

end

#CFERR

Label

MG”UNABLE TO ESTABLISH CONNECTION”

Message

EN

End

Using the equation:

I/O number = (Handlenum*1000) + ((Module-1)*4) + (Bitnum-1)

MG @IN[6001] display level of input at handle 6, module 1, bit 2

SB 6006 set bit of output at handle 6, module 2, bit 3

or to one

OB 6006,1

AO 608,3.6 set analog output at handle 6, module 53, bit 1 to 3.6 volts

MG @AN[6017] display voltage value of analog input at handle6, module 5, bit 2