212
D320 PLC User's Manual
void main(void)
{
unsigned int i;
/* Selection of communication port */
clrscr();
printf("PORT : COM1[1]/ COM[2]/ GPC-232[3]/GPC-485[4]/ GPC-Parallel[5] = ");
scanf("%d",&port_number);
if ((port_number < 1) || (port_number > 5)) port_number=5;
/* Selection of Baudrate for Serial communication */
sending_delay=10;
if (port_number != 5)
{
printf("GPC «å BAUD-RATE : 9600[1]/ 4800[2]/ 2400[3] = ");
scanf("%d",&i);
if ((i < 1) || (i > 3)) i=1;
if (i == 3) i=4;
if ((port_number == 1) || (port_number == 2)) DIVISOR=12 * i;
else DIVISOR=40 * i;
receiving_delay=3 * i + 1;
}
/* Initialization of GPC card */
if(port_number == 1) PORTADD=0x3F0;
if(port_number == 2) PORTADD=0x2F0;
if ((port_number >= 3) && (port_number <=5))
{
PORTADD=0x300;
outportb(0x303,0xC0);/* Mode=2 of 8255 */
outportb(0x303,0x05);/* PC2=1 of 8255 :Disable IRQ2 */
outportb(0x301,0xFF);/* PB0=1 of 8255 :sending Enable RS-485*/
outportb(0x303,0x01);/* PC0=1 of 8255 :Serial Input Enable*/
if(port_number == 3) outportb(0x303,0x02);/* PC1=0 of 8255 :Select RS-232 */
if(port_number == 4) outportb(0x303,0x03);/* PC1=1 of 8255 :Select RS-485 */
if(port_number == 5) outportb(0x303,0x00);/* PC0=0 of 8255 :Disable SerialInput*/
}
else outportb(0x09,(inportb(0x09)&0xF0));/*Disable
Interrupt*/
/* Initialization of USART-Chip : 8250 */
if (port_number != 5)
{
outportb(0x0B,0x80);/* Set of DLAB=1 */
outportb(0x09,0x00);/* Set of High Byte DIVISOR */
outportb(0x08,DIVISOR);/* Set of Low Byte DIVISOR */
outportb(0x0B,0x03); /* parity=None/Stop=1/ Length=8 */
}
/* Processing communication of Read & Write */
for( ; ; )
{
printf("----------------\nPLC-ID (CPU ID) :");
scanf("%d",&PlcID);
if(PlcID<256)
variables.
2. Using the communication function
codes, reads the data of the M field,
reads the word values of the M0 to
M127 area and stores them in the K0
to K127 word area. The K registers
are the retentive registers.
3. Uses the communication code to
read the data of the K area.
4. Compares the values of the M area
and the values of the K area, and
indicates OK when the values are the
same.
Beginning of the main program
Select the port of the peripheral
device for the communication:
Serial 9 PIN, 25PIN
Parallel GPU-300 parallel
port
Select board rate:
9600 bps (max)
4800 bps
2400 bps
Set the communication environment
(delay time) for the selected ports.
GPC-300 card Setting (8255chip
setting):
Uses the communication card that is
connected, and sets the environment
according to the PLC communication
spec., so that communication is
possible. Not currently offered by
Cutler Hammer.
CPU-ID: Input PLC ID (0 to 255)
Summary of Contents for D320 PLC
Page 1: ...D320 PLC User s Manual...
Page 18: ...6 D320 PLC User s Manual...
Page 28: ...16 D320 PLC User s Manual...
Page 34: ...22 D320 PLC User s Manual...
Page 78: ...66 D320 PLC User s Manual...
Page 176: ...164 D320 PLC User s Manual...
Page 210: ...198 D320 PLC User s Manual...
Page 258: ...246 D320 PLC User s Manual...