C Control The I Unit-M Advanced 5 Vdc Inputs / outputs 16 x digital I/Os / 8 x analogue or digital I/Os Program memory 2 198805 Hoja De Datos

Los códigos de productos
198805
Descargar
Página de 42
STANDARD DIGITAL PORTS 
After reset all ports are usually Inputs. please note that some options my change this (See Chapter CONFIG 
REGISTER). A DEACT instruction will make the port an INPUT, a write instruction will make the port an 
OUTPUT (ecept the ports which are read or write only) 
  
PORT READ/WRITE 
Prior to any operation of ports, a port has to be defined (see Chapter DECLARATIONS and DEFINITIONS) 
Reading a Bitport returns a boolean value which is ON (true) for a port that is logic high level and OFF for a 
port that is logic low level. Bitports may also accessed by read/write with the numerical value 0(false) and -
1(true) instead of ON and OFF 
MyBitPort = -1would also work to set the port to ON but is not recommended.  See Chapter DATA TYPES 
also. 
 
IF  MyBitPort1=OFF THEN GOTO X 
IF MyBitPort1=ON THEN GOTO X 
 
Example for request Bitport input status 
 
 
 
Example for request Byteport input 
status 
IF  MyBytePort1=123 THEN GOTO X 
 
 
 
MyBitPort1=OFF  
MyBitPort1=ON  
 
Example for setting a Bitport output 
 
 
 
 
 
MyBytePort1=123 
Example for setting a Byteport output 
 
 
 
TOG 
TOG (toggle) is an instruction which changes the current port status to its opposite. I.e a port becomes ON if 
it was previously OFF and reverse. Prior to use TOG, the affected port has to be switched to OUTPUT (e.g 
MyPort=OFF) otherwise TOG will not work. TOG is not working with Byteports and Extended Ports 
 
Syntax: TOG(bitport) 
TOG MyBitPort 
Example for toggle a bitport 
 
 
PULSE 
PULSE is an instruction which changes the current port status for 5us and then returns to its previous status 
I.e a port becomes ON for a very short time if it was previously OFF and reverse. Prior to use PULSE, the 
affected port has to be switched to OUTPUT (e.g MyPort=OFF) otherwise PULSE will not work. PULSE is 
not working with Byteports and Extended Ports 
 
TOG MyBitPort 
Syntax: PULSE(bitport) 
Example for pulse a bitport 
 
 
DEACT 
DEACT will cause an output port to return to operate as input 
 
Syntax: DEACT(bitport) 
DEACT MyBitPort1 
DEACT MyBytePort1  
             DEACT(byteport) 
 
Example for setting a port to input mode: 
 
 
 
15