Dec 13, 2014

I.               I.  Lý thuyết

1 Lệnh nhập giữ liệu
1.1 Tiếp điểm không đảo trạng thái tín hiệu (tiếp điểm thường mở NO)
   n: toán hạng kiểu bit được khai báo vùng nhớ: I, Q, M, SM, V, T, C.
Nguyên lí làm việc: n= ”1”  tiếp điểm “đóng”
                                   n= ”0” tiếp điểm “mở”
1.2 Tiếp điểm đảo trạng thái tín hiệu (tiếp điểm thường đóng NC)
   n: toán hạng kiểu bit được khai báo vùng nhớ : I, Q, M, SM, V, T, C.
Nguyên lí làm việc:   n= ”0” tiếp điểm “đóng”
                                    n= ”1” tiếp điểm “mở”
1.3
a/                                   b/
I – Immediately (Ngay lập tức)
n: toán hạng kiểu bit được khai báo vùng nhớ : I, Q, SM, M, V, T, C.
Nguyên lí làm việc: Khi n= “1” thì a “đóng” b “hở”
                                  Khi n= “0” thì a “hở” b “đóng”
2 Lệnh xuất dữ liệu
 2.1
                         
n: toán hạng kiểu bit và được khai báo vùng nhớ: I, Q, M, SM, V, T, C
VD:
Nguyên lí làm việc: Khi I0.0= “1” thì Q0.0= “1”
                                  Khi I0.0= “0” thì Q0.0= “0”
2.2



n: toán hạng kiểu bit được khai báo vùng nhớ: I, Q, M, SM, V, T, C
I-Immediately

3 Lệnh AND
n1, n2, n3,… là toán  hạng kiểu bit được khai báo 7 vùng nhớ: I, Q, M, SM, V, T, C
Nguyên lí làm việc: Khi toàn bộ đầu vào có mức logic “1” thì đầu ra có mức logic “1”
4 Lệnh OR

n1, n2, n3, … là các toán hạng kiểu bit được khai báo 7 vùng nhớ : I, Q, M, SM, V, T, C
Nguyên lí làm việc: Khi một trong số các đầu vào có mức logic “1” thì đầu ra có mức logic “1”
5 Lệnh không có toán hạng
          Lệnh nhận biết sườn lên                          Lệnh nhận biết sườn xuống
                                   
                      
6 Lệnh duy trì tiếp điểm (dạng suất set/reset)
6.1 Lệnh SET
n: toán hạng kiểu bit
S-bit: số lượng bit được set lên
6.2 Lệnh RESET
n: toán hạng kiểu bit
S-bit: số lượng bit được reset
      II. Bài tập cơ bản
Bài tập1: Viết chương trình điều khiển cho một tay máy hai bậc tự do có chu trình như trên hình vẽ:
Xuất phát từ điểm A tay máy xuống C, kẹp vật. Khi đã kẹp xong thì đi lên A sang B rồi xuống D để nhà vật. Nhả xong thì lên B rồi về A và lặp lại như chu trình ban đầu. Biết tại các vị trí A, B, C, D đều gắn cảm biến hoặc công tắc hành trình để xác định vị trí.
 Sơ đồ thuật toán như sau:



Chương trình điều khiển như sau:






Bài tập 2: Một cơ cấu dập trong máy dập nguyên liệu (ví dụ dập ra các vỏ hộp) có thể chuyển động nâng lên hạ xuống nhờ một động cơ điện M1 quay 2 chiều. Để đảm bảo an toàn cho tay người vận hành thì chỉ khi nào người vận hành dùng cả 2 tay ấn đồng thời 2 nút S1 (NO) và S2 (NO) thì bàn dập mới hạ xuống. Khi hạ xuống đụng công tắc hành trình giới hạn dưới S3 thì tự chạy nâng lên cho tới khi đụng công tắc hành trình trên S4 thì dừng lại. Chu kì lặp lại cho đến khi nào người vận hành lại nhấn nút S1 và S2





Chương trình như sau:





Sep 3, 2014

Mô tả  STEP 7 Micro / WIN thư viện chuẩn không bao gồm các hàm lượng giác sin, cos và tang trong số học dấu chấm. Tuy nhiên, chức năng nghịch đảo của họ, được gọi là chức năng cung, không có sẵn trong thư viện chuẩn.
Các chức năng cung - sin vòng cung, vòng cung cô sin, hồ quang tiếp xúc - có sẵn để tải về vào cuối cụm từ này trong hình thức của một thư viện Bước 7 Micro / WIN.
Mô tả về "chức năng Arc" thư viện

Hình. 1: Arc chức năng thư viện trong Bước 7 Micro / WIN


Hướng dẫnAnalog đầu vào và đầu ra giá trị của các mô-đun mở rộng EM 231, 232 EM và EM 235, cũng như của CPU 224XP được hiển thị kỹ thuật số ở định dạng từ dữ liệu INTEGER. Nó là cần thiết để thực hiện chuyển đổi để đảm bảo việc giải thích và xử lý chính xác. Những chuyển đổi này được giải thích bằng cách sử dụng tải kèm theo. Các tải chứa cả "Quy mô" thư viện với chức năng chuyển đổi và các chương trình mẫu "Tip038" để hiểu rõ hơn.
1. Scaling
Các biểu đồ dưới đây cho thấy làm thế nào các giá trị đầu vào và đầu ra được thu nhỏ.
Các thuật ngữ "đơn cực", "lưỡng cực" và "20% bù đắp" được giải thích ở đây. Đây là quan trọng đối với những người khác, STEP 7 Micro / Win -. Hướng dẫn Hướng dẫn PID (Tools> Hướng dẫn Hướng dẫn> PID Controller)
. rộng đơn cực chỉ được thực hiện trong phạm vi giá trị tích cực hay tiêu cực (Hình 01 là một ví dụ cho một tương tự giá trị đầu vào từ 0 và 32000).

Hình. 01
Trong trường hợp mở rộng quy mô đơn cực với 20% bù đắp, giới hạn dưới của phạm vi giá trị là 20% giới hạn trên (Hình. 02 là một ví dụ cho một giá trị đầu vào tương tự từ 6400 và 32000).

Hình. 02
Mở rộng quy mô lưỡng cực được thực hiện trong phạm vi giá trị tích cực và tiêu cực (Hình. 03 là một ví dụ cho một giá trị đầu vào tương tự từ -32.000 và 32000).

Hình. 03
Bảng dưới đây giải thích các chữ viết tắt được sử dụng:
Mô tả:
. Các S7-200 cung cấp 16-bit khối chức năng truy cập tích hợp vào Bước 7 Micro / WIN, cũng như tốc độ cao đếm 32-bit
Các "Counter_DINT" thư viện đính kèm dưới đây có thể được sử dụng để đếm các sự kiện chu kỳ phụ thuộc hơn 16 bit.
Thư viện chứa các khối tương tự như 16-bit khối chức năng truy cập tích hợp, mặc dù ở định dạng hai số nguyên với sản lượng tràn bổ sung.

Mô tả:
Bảng 01 chỉ ra các bộ đếm tốc độ cao, trong đó truy cập chế độ mà bạn có thể thiết lập lại thông qua các đầu vào có liên quan.
 
Đếm tốc độ caoChế độ truy cập
1245781011
HSC0E0.2
HSC1E1.0
HSC2E1.4
HSC4E0.5
Bảng 01
Ngoài các tùy chọn thiết lập lại bên ngoài, bạn cũng có thể thiết lập lại bộ đếm tốc độ cao trong nội bộ kích hoạt thông qua những lá cờ đặc biệt được liệt kê trong Bảng 02.
 
Đếm tốc độ caoGiá trị mới hiện nayViết giá trị mới hiện tại HSC
HSC0SMD38SM37.6
HSC1SMD48SM47.6
HSC2SMD58SM57.6
HSC3SMD138SM137.6
HSC4SMD148SM147.6
HSC5SMD158SM157.6
Bảng 02
Instructions:The two analog inputs of the S7-224 XP are factory-set for voltage measurement (0..10V). In order to be able to use the inputs as current inputs as well you must incorporate a 500 Ohm resistor between terminals A+ and M (or B+ and M).
Figure 1 shows the connection of a sensor to a voltage source as a 2-conductor connection.
DescriptionWith the block in the library, you can use a GPS receiver to read out the time stamp and date of GPS messages. You can use this data to compensate the time drift of the real-time clock (RTC) of your S7-200.
In the attached sample PLC application, the minutes and seconds of the real-time clock are synchronized with the time stamp of the GPS message. Restricting time synchronization to minutes and seconds has the following advantages:
  • It can be applied worldwide, independently of time zones.
  • It can be applied independently of summer/winter time.
Time synchronization is done between xx.20 and xx.40 after the synchronization command.

Fig. 01
CommunicationThe GPS receiver receives GPS messages in compliance with the NMEA standard and sends these as ASCII character strings to the S7-200 basic module. The time stamp and date are read out of them in each case. The S7-200 uses the freely programmable communication mode (Freeport) via the RS485 connection ( Port '0' or Port '1') for communication with the GPS receiver. The library uses the RMC protocol of those available in the NMEA standard.
Transfer format
The transfer format used for GPS messages in compliance with the NMEA standard requires the following interface parameters:
  • 4800 baud
  • 8 data bits
  • No parity
  • 1 stop bit
The resulting interface parameter to be entered at the "GPS_NMEA_TIME_UTC" block is 2#1101 (see description under "Library: Read out time stamp and date").
RequirementsThe library and the sample PLC application can be used
  • With a GPS receiver with serial interface that supports the NMEA standard and which is connected to the S7-200 basic module via an RS232 PC/PPI cable.
  • With an RS232 PC/PPI cable
Library: Read out time stamp and dateThe library contains the "GPS_NMEA_TIME_UTC" block for reading out the year, month, day, hour, minute and second in UTC (Universal Time Coordinated).
 

No.Remarks
1Use the GPS receiverConnect the GPS receiver to the RS485 connection of your S7-200 basic module via an RS232 PC/PPI cable. Set the DIP switches of the PC/PPI cable as in Fig. 02.
Fig. 02

Additional informationThe RS485 connection does not provide any power supply for your GPS receiver.
2Add libraryStore the attached "gps_time_read_port0.zip" or "gps_time_read_port1.zip" file on your computer. Unpack the file and add the library to your configuration software STEP 7 Micro/WIN.Additional information
Instructions for adding libraries are available in Entry ID 16689345.
3Add GPS block
From the "GPS_TIME_READ_PORT0" or GPS_TIME_READ_PORT1" library you drag-and-drop the "GPS_NMEA_TIME_UTC" block into a cyclically called network.

Fig. 03

Assign an unused memory area to the library.
Additional information
  • Approx. 950 bytes are need in the CPU's program memory.
  • The library occupies 214 bytes in the CPU's variable memory.
  • The required interrupt "GPS_NMEA_RC" and the subprogram "GPS_NMEA_INIT_PORT0" or "GPS_NMEA_INIT_PORT1" are inserted automatically in your project.
  • Information on assigning memory area for libraries is available in Entry ID 16689345.
4Connect the GPS blockAssign the contacts of the block. The variables used in Fig. 04 are examples. Via the "Freeport_Config" contact you configure the freely programmable communication. The parameter "2#1101" results for the NMEA transfer format used (see "Transfer format").
Fig. 04

Additional informationAdditional information on configuring the freely programmable communication is available in the S7-200 manual, section 7.5 "Creating user-defined protocols in the freely-programmable communication".
5Use the GPS blockYou start the GPS evaluation with a positive edge at the 'Start' input. You can tell how well the evaluation is from the contacts 'DONE', 'ABORTED' and 'GPS_status'.The table lists the contacts of the block and tips for usage.
  

Contact nameData typeContact typeRemarks
ENBOOLInputSM0.0
STARTBOOLInputPositive edge = one-off read out
Freeport-ConfigINTInput'2#1101' =  parameter for initializing the freely programmable communication
DONEBOOLOutput1 = GPS reception completed
ABORTEDBOOLOutput1 = GPS reception defective
UTC_yearBYTEOutputOutput of the year
UTC_monthBYTEOutputOutput of the month
UTC_dayBYTEOutputOutput of the day
UTC_hourBYTEOutputOutput of the hour
UTC_minuteBYTEOutputOutput of the minute
UTC_secondBYTEOutputOutput of the second
UTC_statusBYTEOutputASCII-coded;
  =  65 (A) -> Data OK
 <> 65 (A) -> Data defective
Additional informationThe time stamp of the GPS message include the UTC time.
Table 01
Sample application: Synchronize the timeThe sample application uses the functions of the "gps_time_read_port0.mwl" or "gps_time_read_port1.mwl" library. You can use the sample application without incorporating the library.
 
No.Remarks
1Use the GPS receiverConnect the GPS receiver to the RS485 connection of your S7-200 basic module via an RS232 PC/PPI cable. Set the DIP switches of the PC/PPI cable as in Fig. 05.
Fig. 05

Additional informationThe RS485 connection does not provide any power supply for your GPS receiver.
2Open the sample applicationStore the attached "gps_time_read_port0.zip" or "gps_time_read_port1.zip" file on your computer. Unpack the file and add open it using your configuration software STEP 7 Micro/WIN.
3Use the sample applicationYou start the sample application with a positive edge at the 'Start' input of the "GPS_SYNC" block. For this you set the variable V541.0 to 'high' using the variable table. The sample application remains active until synchronization has been done after the time window has been reached. You can tell the status of the evaluation from the contacts 'DONE', 'ABORTED', 'GPS_rcvd_warning' and 'sync_not_in_window'.
Fig. 06

The sample application cyclically reads the time stamp of the GPS message received. The minutes and seconds are synchronized automatically in the time window between xx.20 and xx.40. The table lists the contacts of the block and tips for usage.
 

Contact nameData typeContact typeRemarks
ENBOOLInputSM0.0
STARTBOOLInputPositive edge starts the synchronization
CANCELBOOLInputAbortion of the synchronization
DONEBOOLOutputCompletion of the synchronization
BUSYBOOLOutputSynchronization active
ABORTEDBOOLOutputSynchronization aborted
GPS_rcvd_warningBOOLOutputGPS reception defective
sync_not_in_windowBOOLOutputTime of synchronization not in time window
Additional informationChange the value of variable VW802 to '1000' to have synchronization tested at any time. At the end of each test, reset the variable to the value '100'.
Table 02
PasswordThe password for the library is "1234" (without the quotation marks).
Download
 
DescriptionDownload
Library for reading out the GPS time via Port '0' gps_time_read_port0.zip ( 3 KB )
Library for reading out the GPS time via Port '1' gps_time_read_port1.zip ( 5 KB )
Sample application for synchronizing the RTC via Port '0' gps_time_sync_port0.zip ( 9 KB )
Sample application for synchronizing the RTC via Port '1' gps_time_sync_port1.zip ( 9 KB )

Description:
The S7-200 provides the option of counting pulse trains using high-speed counters. Using the attached"Frequency" library, the frequency of the pulse train is calculated from the counter signal, from which the speed of stepper motors, for example, can be determined after relevant conversion.
1. Define a fast counter to capture the pulse train frequencyFirst, using the STEP 7 Micro/WIN Instruction Wizard you must generate a high-speed counter that counts the external pulses.
Table 01 shows which high-speed counters the S7-200 provides, which inputs these use and the maximum measurable frequency.
 
High-speed countersClock inputMax. input frequencyCPUs
HC0E0.030 kHz221, 222, 224, 224XP, 224XPsi, 226
HC1E0.630 kHz221, 222, 224, 224XP, 224XPsi, 226
HC2E1.230 kHz221, 222, 224, 224XP, 224XPsi, 226
HC3E0.130 kHz221, 222, 224, 224XP, 224XPsi, 226
HC4E0.3200 kHz224XP, 224XPsi
HC5E0.4200 kHz224XP, 224XPsi
Table 01
Procedure:
 
No.Description
1Open the Instruction Wizard via the "Tools" menu in STEP 7 Micro/WIN.

Fig. 01
2There you select the high-speed counter "HSC" from the configuration catalog.
Then click on "Next >".

Fig. 02

Aug 14, 2014

Mặc dù S7-200 không còn được Siemens phát triển nữa, nhưng hiện nay vẫn còn rất nhiều ứng dụng sử dụng loại PLC này... và theo quan điểm riêng của mình có lẽ là một trong những loại PLC tốt nhất... Để có thể hỗ trợ trong việc lập trình các bạn có thể down về tập tin "Alll tips of PLC s7-200 programming" từ đường dẫn sau... Siemens Industry Online Support - Automation Service, Automation Support, Simatic Service, Simatic Support, Technical Support, Technical Consulting. Đây là bản offline dạng web bạn có thể lưu và xem trên máy tính...cách sử dụng khá dễ...down về... giải nén... rồi căn cứ vào từng ứng dụng... bạn sẽ được hướng dẫn từ phần cứng đến phần mềm... ví dụ... các bạn quan tâm đến phần PID...

Bạn chọn tiếp phần PID bên trái ở cột bên trái... bạn sẽ thấy được kết nối phần cứng và tập tin microwin có sẵn như trong hình....


 Hoặc nếu bạn muốn xem ví dụ về kết nối với biến tần...