Samsung Ht As700 User Manual
Have a look at the manual Samsung Ht As700 User Manual online for free. It’s possible to download the document as PDF or print. UserManuals.tech offer 1705 Samsung manuals and user’s guides for free. Share the user manual or guide on Facebook, Twitter or Google+.
111 Structure of Communication Frames The function code is explained with the example of Query and Response frame based on the 2-step communication. Query (Q) and Response (R) frame Query Acknowledge (QA) frame Response Request (RR) frame Response (R) frame for an errorDA SA Function code Length Information CRC L CRC H Length of information area (byte) 1 to 255: 1 to 255 bytes 0: 256 bytes Function code Sender ID Receiver ID DA SA $80 01 00 CRC L CRC H DA SA $00 01 00 CRC L CRC H DA SA $8X 01 Error No CRC L CRC H CRC-16 code (2 bytes) Constant Error #1. Wrong communication function code Error #2. Out of range Error #3. Wrong frame structure Error #4. CPU did not perform Error #5. Frame is too long The frame is sent from SA to DA. After Q or RR is sent, DA and SA for the QA and R from the CPU are replaced each other, because the CPU becomes the sender and the peripheral device becomes the receiver of the message. Constant
112 Read the content of the bits (R, L, M, K, F, or TC) assigned to the absolute address. Can read n consecutive bits (On/Off). Query (Q) frame Response (R) frameDA SA $21 $03BAS L HNCRC L H DA SA $A1 NBase + 0 bit valueBase + 1 bit value-Base + N-1 bit valueCRC L H Length of information (byte) Peripheral device ID (PC ID) Bits that are On are represented by the one byte value $FF. Bits that are Off have a value of $00. Absolute bit address (address of first bit to read) Refer to 3.3 Absolute Addressing Ex) K127.12 (address K127’s 12 th bit) Absolute bit address = $1BFC BASE L=$FC, H=$1B Number of bits to be read Length of information (number of bytes): from the length to the next CRC. Response code where $80 is added to the R (Response) Q to its 2-step communication function code PLD ID (CPU ID) Peripheral device ID (PC ID) For the response, the PLC is the sender and the PLC the receiver, so the DA and SA are reversed from the Q message. PLD ID (PC ID) Read bits Function code (2-step communication)
113 Modify the contents of the bits stored in the absolute address (R, L, M, K, F, or TC). Change the bit state between On/Off. Can change multiple consecutive bytes. Query (Q) frame Response (R) frame Read the content of the words (R, L, M, K, F, or W) assigned to the absolute address. Can read n consecutive words. Query (Q) frame Response (R) frameDA SA $22 N Base L HBase+0 bit valueBase+N+1 bit value-Base+N-3bit valueCRC L H DA SA $A2 &01 &00CRC L H DA SA $23 $30Base L HNCRC L H DA SA $A3 LBase+0word L HBase+1word L H-Base+1word L HCRC L H Completion code Fixed N word values from the base words requested by the Q. Length L = Nx2 To turn On the desired bit value from the base, enter $FF. To change to Off, enter $00. Absolute bit address (starting address) Refer to Absolute Addressing on Chapter 3. Word absolute address (starting address) Refer to Absolute Addressing on Chapter 3. Ex) Absolute address of K127 word is $01BF. BASE L=$BF, H=$01 Number of words to be read Write bits Read words
114 Change the content of the words (R, L, M, K, F, or W) assigned to the absolute address. Can read n consecutive words. Query (Q) frame Response (R) frame Read the bits and/or word contents of the assigned absolute addresses. Can read bits and words regardless of their order and location in memory. Query (Q) frame Response (R) frameDA SA $24 L Base L HBase+0word L H-Base+1word L HCRC L H DA SA $A2 $01 &00CRC L H DA SA $25 LAO L HA1 L H-An L HCRC L H DA SA $A5 LxDO D1 L H-Dn L HCRC L H n word values from the base words requested by the Q. Length L = Nx2+2 Assigning absolute address for bits Absolute address for the K127 12th bit =$1BFC A x = 0 0 01 1011 1111 1010 Ax L=$FC, H=$1B Assigning addresses for word Absolute address for the K127 word =$01BF A x = 010 0 0 0 01 1011 1111 Ax L=$BF, H=$41 For the A0, A1, ..., An requested by the Q, the content D0, D1, ..., Dn of the word/bit is returned. If Ax denotes a bit address, the Dx data is 1 byte (On = $FF, Off = $00), and if Ax denotes a word address, the Dx data is 1 word (2 bytes). The size and location of the returned data depends on the combination of bit/word addresses requested. The Lx parameter should be checked to verify data size. Fixed Method of assigning bit/word absolute address 15 14 13 0 0 0 Absolute bit address 0 1 Absolute word address 1 X Not used Ax=A0, A1, .., An Dx=D0, D1, .., Dn Absolute Address(Bit/Word) Write words Read bits and words
115 Read the bits and/or word contents of the assigned absolute addresses. Can read bits and words regardless of their order and location in memory. Query (Q) frame If Ax denotes a bit address, the Dx data is 1 byte (On=$FF, Off=$00), and if Ax denotes a word address, the Dx is 1 word (2 bytes). Response (R) frameDA SA $26 L AO L HDOA1 L H-CRC L H DA SA $A2 $01 $00CRC L H Method of assigning bit/word absolute address 15 14 13 0 0 0 Absoulte bit address 0 1 Absoulte word address 1 X Not used Ax=A0, A1, .., An Dx=D0, D1, .., Dn Absolute Address(Bit/Word) Assigning absolute addresses for bits Absolute address for the K127.12 bit = $1BFC A x = 0 0 01 1011 1111 1010 Assigning absolute addresses for word The absolute address for the K127 word = $01BF A X = 010 0 0 0 01 1011 1111 When structuring the outgoing frame, be aware that the Dx of the Q changes according to the bit/word Ax type, and the L (information length) changes as well. The Dx will be either 1 or 2 bytes. Fixed Write bits and words
116 Communication Program Examples Users can write a communication program by using the following example. For more information, contact the sales or technical department. ProgramNotes #include #include #include #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_occuring(void); BOOL receiving_occuring (void); void Crc16(unsigned int); void Job(void); unsigned int communication(void); void Mword_reading(void); void Kword_writing(void); 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 card 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; }This program was written in Borland C++. It uses the peripheral devices such as PC to read M000 to M127 words, 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 sent/ received information 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. The Qs, QAs, RRs, and Rs are handled in the job function. If there is any communication delay or 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. 1. Adjusts the initial communication port and the board rate for communication. Then initializes the variables. 2. Using the communication function codes, reads the data of the M field, reads the word values of the M0 to M127 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 pins, 25 pins 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. Note: GPC-300 card port address = 0x0300
117 ProgramNotes * Initialization of GPC card */ if(port_number == 1) PORTADD=0x3F0; if(port_number == 2) PORTADD=0x2F0; if ((port_number >= 3) && (port_number 1)^0xA001; /* 0x0001 : multi-nominal expression */ else Crc=Crc>>1; } }GPC-300 card Setting (8255chip setting) Uses the communication card that is connected, and sets the environment according to the PLC communication specifications, so that communication is possible. CPU-ID: Input PLC ID (0 to 255) Reads the register value for the M area (M0 to M127) Stores the value for the M area in the K area. (K0 to K127) RR (Request Response) request function Sends data to the communication port. Reads the received data from the communication port. Outputs the data when a Send event occurs.. Inputs the data when a Receiver event occurs. CRC calculation Encodes the communication data in the byte stream. Any completed communication function will be attached to the latest frame or will be compared with the attached CRC to check for data errors. (Note: The CRC method can be implemented in several ways within the rule specified as shown in the left code.)
118 ProgramNotes void Job(void) { /* JobID=0 : Change to sending-mode for serial port */ /* JobID=1 : Transmit sending-frame */ /* JobID=2 : Change to receiving-mode for serial port */ /* JobID=3 : Address polling of ACK from CPU */ /* JobID=4 : Receive ACK from CPU */ /* JobID=5 : Change to sending-mode for serial port */ /* JobID=6 : Transmit RR-Frame */ /* JobID=7 : Change to receiving-mode for serial port */ /* JobID=8 : Address polling of RES from CPU */ /* JobID=9 : Receive RES from CPU */ /* JobID=10 : Success communication processing */ switch(JobID) { case 0: case 5:if (port_number != 5) { if (port_number == 4) outportb(0x301,0xFF); else outportb(PORTADD+0x0C,(inportb(PORTADD+0x0C) | 0x02)); delay(sending_delay); } if (JobID == 5) RR_occuring(); watchdog=0; index=0; sending_Index_max=5; Crc=0xFFFF; JobID++; break; case 1: case 6:if (receiving_occuring()) data=Recport(); if (sending_occuring()) { if (index
119 ProgramNotes break; case 4: case 9:if(receiving_occuring()) { if(indexTime_limit) { watchdog=0; retrialC--; JobID=(JobID & 0x05); } if(!(((Old^New) & 0x02)==0)) { watchdog=watchdog+1; Old=New; } }while((retrialC!=0) && (Success==FALSE)); if(retrialC==0) ret=1; else ret=0; return(ret); } void Mword_reading(void) { /* Example of Read-Register */ int i; receiving_frame[2]=3;/* EXAMPLE READ WORD(M000-M0127) */ receiving_frame[3]=3;/* Number Of Byte For Information = 3 */ receiving_frame[4]=0xC0;/* BASE(M000=$00c0) */ receiving_frame[5]=0;/* BASE HIGH */ receiving_frame[6]=128;/* Number Of Byte M000-M127 */ if(communication() == 0) { printf(READ M0000-M0127 OK ); for(i=0;i
120 ProgramNotes if(communication() == 0) printf(WRITE K0000-K0063 OK\n); else printf(communication error\n); receiving_frame[2]=4; /* EXAMPLE write WORD(K064-K0127) */ receiving_frame[3]=130; /* Number Of Byte For Information */ receiving_frame[4]=0x80; /* BASE(K000=$0180) LOW */ receiving_frame[5]=1; /* BASE HIGH */ for(i=0;i