EasyManua.ls Logo

Cutler-Hammer D50 - Configurable Input Response Delay

Cutler-Hammer D50
228 pages
Print Icon
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...
Appendix A: D50 PLC Communication Protocol 167
Communication Program Example
The following program is an example program written in C code to demonstrate the D50 PLC open
communications protocol. This program consists of a header, the main program, and various
subroutines. The buffers and a few variables needed to store the communication data are set as global
variables, so that the main function and the various functions may have access. Notes are provided
alongside the main program to help explain the exact purpose and function of the individual parts of
the program. This particular program was written for the Cutler-Hammer D320 PLC, and so uses
register addresses beyond the D50 limits. For use with a D50, adjust the register addresses used in this
program (M000 to M127 and K000 to K127) to within the D50 range.
Note: This program is provided for illustrative purposes only. It is left to the responsibility of the
user/programmer to ensure that any programs written based on, and using the information
contained in this program, satisfy the requirements of their particular application.
Program Notes
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <conio.h>
#define PC_ID 0xE2
#define Time_limit 28
#define retrial_limit 2
#define TRUE 1
#define FALSE 0
#define lower_byte(x) (unsigned int) ((x)& 0x00FF)
#define upper_byte(x) (unsigned int) (((x)& 0xFF00)>>8)
typedef int BOOL;
unsigned int PORTADD,DIVISOR,sending_delay, receiving_delay;
unsigned int sending_frame[262],receiving_frame[262];
unsigned int Crc;
unsigned int card,i,ix,iy,smode;
unsigned int port_number;
unsigned int PlcID,OldID;
BOOL Success;
unsigned int data,JobID,retrialC;
unsigned int Old,New,receiving_Index_max,sending_Index_max,index,watchdog;
unsigned int M[128],K[128]; /* Example Register */
void RR_occurring(void);
void Trsport(unsigned int);
unsigned int Recport(void);
BOOL sending_occurring(void);
BOOL receiving_occurring(void);
void Crc16(unsigned int);
void Job(void);
unsigned int communication(void);
void Mword_reading(void);
void Kword_writing(void);
This program was written in Borland
C++. It uses the peripheral device
(PC) to read the M000 to M127
words, and stores them in the K000 to
K127, and then compares the two
registry values and indicates the
results on the screen using the OK or
the FAIL notation. The user may read
or manipulate the various
communication function codes and
the information sent to control the
PLC in various ways.
This program consists of a header, the
main program and various functions.
The buffers and variables needed to
store the communication data are set
as global variables, so that the main
and various other functions may
reference them.
By using the COM1 and COM2 ports
of the computer, serial
communication is possible. By using
the GPU-300 card, parallel
communication is also enabled
(NOTE: The GPU-300 card is not
currently offered by Cutler-Hammer).
The Qs, QAs, RRs, Rs are handled in
the job functions. If there are
communication errors or a frame
breakdown, retry 3 times, then issue a
communication error.
The procedure of the communication,
according to the JobID is:
1. Q sending
2. QA receiving
3. RR sending
4. R receiving
When an error occurs in a frame, a
retransmission should be made.
Major operations of the program
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com

Table of Contents