mô tả được mô hình toán học của thanh trở thiết kế bộ điều khiển pid theo zieglernichols ổn định nhiệt độ tải thanh trở xây dựng phần mềm giám sát

48 3 0
mô tả được mô hình toán học của thanh trở thiết kế bộ điều khiển pid theo zieglernichols ổn định nhiệt độ tải thanh trở xây dựng phần mềm giám sát

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

CHƯƠNG TỔNG QUAN 1.1 ĐẶT VẤN ĐỀ Nhiệt độ thành phần vật lý quan trọng Việc thay đổi nhiệt độ vật chất ảnh hưởng nhiều đến cấu tạo, tính chất đại lượng vật lý khác vật chất Ví dụ: thay đổi nhiệt độ chất khí làm thay đổi thể tích, áp suất chất khí bình Vì vậy, nghiên cứu khoa học, công nghiệp đời sống sinh hoạt, thu thập thông số điều khiển nhiệt độ điều cần thiết Trong mơ hình điều khiển nhiệt, máy điều hòa, máy lạnh hay lò viba, điều khiển nhiệt độ tính chất định cho sản phẩm Trong ngành thực phẩm, cần trì nhiệt độ, khơng gây hư hại đến thiết bị hoạt động, cịn ảnh hưởng đến q trình sản xuất, sản phẩm Có nhiều phương pháp để điều khiển mang đến kết khác thông qua phương pháp điều khiển khác Qua thực tiễn cho thấy để có thiết kế chế tạo thành cơng sản phẩm cơng nghệ địi hỏi người thực phải nắm lý thuyết vững kết hợp với kinh nghiệm thực tế Thực tế chứng minh việc điều khiển nhiệt độ vấn đề cấp thiết nên nhóm em thực lại việc nghiên cứu mơ hình nhỏ điều khiển PID nhiệt độ tải trở nhiệt 1.2 PHẠM VI ĐỀ TÀI Đề tài chúng em giới hạn mức độ mơ hình nhỏ vấn đề điều khiển nhiệt độ thơng qua mơ hình điều khiển nhiệt tỏa nhiệt Sử dụng mơ hình điều khiển nhiệt tỏa nhiệt dùng cảm biến để nhận biết nhiệt độ điều khiển (Arduino) để dùng thuật toán PID để điều khiển nhiệt độ 1.3 MỤC TIÊU – CÔNG VIỆC CẦN THỰC HIỆN 1.3.1 Mục tiêu  Mơ tả mơ hình tốn học trở  Thiết kế điều khiển PID theo Ziegler-Nichols ổn định nhiệt độ tải trở  Xây dựng phần mềm giám sát  Xây dựng mơ hình thực nghiệm kiểm định chất lượng hệ thống 1.3.2 Cơng việc cần thực  Mơ tả tốn học mơ hình điều khiển nhiệt  Thiết kế điều khiển PID cho tải trở mô  Dùng C# thực tạo phần mềm giám sát mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat  Thực mơ hình thí nghiệm mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat CHƯƠNG CƠ SỞ LÝ THUYẾT 2.1 MƠ HÌNH CỦA THANH GIA NHIỆT (TRỞ) Hình 2.1 Mơ hình gia nhiệt (trở) 2.1.1 Nguyên lý hoạt động mô hình điều khiển tải trở Thanh trở làm việc dựa sở có điện dịng điện chạy qua dây dẫn vật dẫn tỏa lượng nhiệt theo định luật Jun-Lenxo: Q  RI t Trong đó: Q : nhiệt lượng tính Jun (J) R : Điện trở tính Ơm (Ω) I : Dịng điện tính Ampe (A) t : Thời gian tính bẳng giây (s) Từ cơng thức ta thấy R đóng vài trò:  Vật nung: trường hợp gọi nung trực tiếp  Dây nung: dây nung nóng, truyền nhiệt cho vật nung xạ, dẫn nhiệt phức tạp Trường hợp gọi nung gián tiếp 2.1.2 Cấu tạo tải mơ hình điều khiển nhiệt Cấu tạo mơ hình điều khiển nhiệt có lớp: lớp vỏ bọc ngồi, lớp cách điện dẫn nhiệt, dây điện trở 2.1.2.1 Lớp vỏ bọc Vỏ bọc bên khung cứng vững, chủ yếu để chịu tải trọng trình làm việc trở Mặt khác vỏ bọc dùng để giữ lớp cách điện dẫn nhiệt rơi đảm bảo kín hồn tồn tương đối trở Là lớp kim loại thường dung kim loại nhôm, inox 2.1.2.2 Lớp cách điện dẫn nhiệt Lớp cách điện dẫn nhiệt thường dùng Styrofoam hay đồng vật liệu có có khả dẫn nhiệt mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat 2.1.2.3 Dây điện trở Dây điện trở đốt nóng sử dụng nichrome 80/20 (80% niken, 20% crom) Đây loại vật liệu lý tưởng có sức đề kháng tương đối cao tạo thành lớp dính crom oxit làm nóng nhiệt độ cao Chất liệu bên lớp ngăn ngừa oxi hóa, ngăn dây bị vỡ cháy 2.1.3 Các phươp pháp xây dựng mơ hình tốn học Ổn định tham số đối tương điều khiển nhiệt độ, tốc độ,… mối quan tâm hang đầu thiết kế hệ thống điều khiển Để thực việc cơng việc xác định mơ hình tốn học đối tượng điều khiển Trong lý thuyết điều khiển tự động xác định mơ hình đối tượng điều khiển bước quan trọng trước xác định thuật toán tham số điều khiển Để xác định mơ hình tốn học đối tượng điều khiển đến có phương pháp: Dựa phương trình tốn học mơ tả mối quan hệ đại lượng vật lý đối tượng tham số đối tượng Dựa đường cong thực nghiệm đối tượng Mơ hình điều khiển nhiệt có đầu vào điện áp cung cấp cho dây điện trở (hay công suất cấp) ngõ nhiệt độ vùng sử dụng để điều khiển Để thành lập hàm truyền cho mơ hình điều khiển nhiệt ta phải khảo sát phương trình vi phân mô tả quan hệ nhiệt độ - lượng, toán phức tạp muốn xác định Một cách gần đúng, ta xem môi trường nung đồng chất, đẳng nhiệt Từ phương trình cân lượng: điện cung cấp dùng để bù vào lượng nhiệt truyền bên ngồi tích nhiệt vào mơi trường nung, ta tính hàm truyền lị bậc nhất, có dạng sau: Mơ hình 2.1 Mơ hình điều khiển nhiệt Trong đó: P: cơng suất cung cấp θ: độ tăng nhiệt nhiệt độ đầu so với nhiệt độ môi trường K: hệ số tỉ lệ cho biết quan hệ vào chế độ xác lập T: số thời gian, thể quán tính nhiệt hệ thống mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat 2.1.4 Đồ thị đặc tính mơ hình điều khiển nhiệt Hình 2.3 Đặc tính gần Hình 2.2 Đặc tính xác 2.2 MƠ HÌNH TỐN CỦA MƠ HÌNH ĐIỀU KHIỂN NHIỆT Sơ đồ khối mơ hình có dạng sau: Hình 2.4 Sơ đồ khối tổng qt mơ hình Trong đó:  r (t ) : tín hiệu đặt – độ sáng mong muốn  u (t ) : tín hiệu điều khiển  c(t ) : tín hiệu – độ sáng đầu  cht (t ) : tín hiệu hồi tiếp từ cảm biến  GPID ( s ) : hàm truyền điều khiển PID  G ( s ) : hàm truyền bóng đèn  H ( s) : hàm truyền cảm biến 2.2.1 Hàm truyền mô hình điều khiển nhiệt Mơ hình hàm truyền lị điện cho thấy trình độ với đầu vào hàm nấc có dạng hàm mũ Thực tế cho thấy mơ hình mơ hình điều khiển nhiệt gần đúng, hệ thống có bậc cao q trình q độ đầu vào hàm nấc khơng có q điều chỉnh, có dạng hình sau cho nhiệt độ đầu Hàm truyền xác định gần theo: mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat G(s)  Y (s) U ( s) Tín hiệu vào hệ thống mơ hình điều khiển nhiệt độ dạng hàm nấc đơn vị (công suất điện trở 100%) U ( s)  s Tín hiệu hệ thống gần y (t )  f (t  T1 )  t /T2 Trong f (t )  k (1  e ) F ( s)  Từ đây: K s (T1  T2 ) Áp dụng tính chất trễ biến đổi Laplace Y ( s)  Ke sT1 s (1  sT2 ) 11Equation Section (Next) Hàm truyền: G(s)  Y ( s) Ke  sT1  U ( s)  sT2 212\* MERGEFORMAT (.) Trong đó: K : Khâu qn tính hệ số khuếch đại mơ hình điều khiển nhiệt độ Hệ số K tính sau: K nhiet xac lap % cong suat T1 : Hằng số thời gian không chạy bắt đầu cấp điện giá trị nhiệt độ tăng dần T2 : Hằng số thời gian quán trính nhiệt lò K , T1 , T2 : Các hệ số xác định phương pháp thực nghiệm Để áp dụng cho hệ tuyến tính, khai triển Taylor phương trình (1.1) ta hàm truyền mơ hình điểu khiển nhiệt sau: G ( s)  Y (s) K  U ( s ) (T1  1)(T2 s  1) MERGEFORMAT (.) mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat 313\* mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat 2.2.2 Tìm thơng số mơ hình điều khiển nhiệt thực nghiệm Trong phần này, áp dụng phương pháp Ziegler – Nichols để tìm thơng số cho mơ hình điều khiển nhiệt Khi cung cấp điện áp U cho mơ hình điều khiển nhiệt nhiệt độ y (t ) mơ hình điều khiển nhiệt tăng lên theo thời gian đạt giá trị xác lập y xl mơ tả hình 2.6 Tại thời điểm uống I đường cong y (t ) , tiếp tuyến qua I cắt đường y (0) đường y xl Giá trị K , T1 T2 (1.2) xác định mô tả Hình 2.4 K tính theo cơng thức sau: K y xk  y (0) U 414\* MERGEFORMAT (.) 2.2.3 Hàm truyền cảm biến Tín hiệu đầu vào r (t ) giá trị đặt – nhiệt độ mong muốn Nhưng thực tế có khác biệt mơ hình thực tế mơ hình tốn lý thuyết:  Mơ hình thực tế so sánh giá trị đặt giá trị thực tế xác để đưa vào PI tính tốn đầu ra, sau hiệu chuẩn dải giá trị PWM Arduino điều khiển trở (0 – 255) Vậy mơ hình thực tế, giá trị đặt giá trị nhiệt độ mong muốn  Mơ hình lý thuyết so sánh giá trị đặt giá trị thực tế sau hiệu chuẩn dạng điện áp (0 – 5V) đưa vào PI tính tốn đầu ra, sau cấp thẳng vào trở Vậy mơ hình lý thuyết, giá trị đặt nhiệt độ mong muốn dạng điện áp Vì để tìm hàm truyền cảm biến cần tìm tương quan giá trị nhiệt độ đầu giá trị điện áp hồi tiếp tỉ số K, ta có: H (s)  K 515\* MERGEFORMAT (.) 2.3 TỔNG QUAN VỀ ĐIỀU KHIỂN NHIỆT Trên thực tế có nhiều phương pháp điều khiển nhiệt Ở báo cáo đề cập đến điều khiển PID theo phương pháp Ziegler – Nichols mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat Mơ hình 2.2 Mơ hình điều khiển nhiệt dùng PID Bồ điều khiển PID (Proportional-Intergral_Derivative) hiệu chỉnh có phản hồi nhằm làm giá trị sai lệch tín hiệu điều khiển Bộ PID có thành phần:  Proportional: tỷ lệ  Intergral: tích phân Ba thành phần có vai trị đưa sai lệch 0, thành phần có tính chất riêng Tín hiệu phản hồi (feedback signal) thường tín hiệu đo cảm biến Giá trị sai lệch tín hiệu tín hiệu đặt (setpoint) trừ cho tín hiệu phản hồi Thiết kế điều khiển PID theo Ziegler – Nichols Phương pháp thường áp dụng cho đối tượng có qn tính lớn lị nhiệt mơ tả hàm truyền đạt: G (s)  Ke T1s T2 s  PID Ziegler – Nichols có dạng: D( s )  C (1  C Với:  Td s ) Ti s 1, 2T2 ; Ti  2T1 ; Td  0,5T1 KT1 Hệ số tương ứng với hệ số khuếch đại tỷ lệ: K p  C; Ki  C ; K d  CTd T1 Hiệu chỉnh PI Ziegler – Nichols là:   D(s)  C 1    Ti s  mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat 5.1.7 Kết thí nghiệm Sau kết lý thuyết thực tế chọn lựa số làm điều khiển ổn định cho hệ thống điều khiển nhiệt Hình 5.28 Kết chọn điều khiển cho mơ hình điều khiển nhiệt độ mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat 5.2 THIẾT KẾ PHẦN MỀM GIÁM SÁT 5.2.1 Phần mềm Visual Studio Hình 5.29 Giao diện phần mềm Visual Studio 2015 Visual studio là cơng cụ hỗ trợ lập trình website rất tiếng Mcrosoft chưa có phần mềm thay Visual Studio viết ngơn ngữ C# VB+ Đây ngơn ngữ lập trình giúp người dùng lập trình hệ thống dễ dàng nhanh chóng thơng qua Visual Studio Visual Studio phần mềm lập trình hệ thống sản xuất trực tiếp từ Microsoft Từ đời đến nay, Visual Studio có nhiều phiên sử dụng khác Điều đó, giúp cho người dùng lựa chọn phiên tương thích với dịng máy cấu hình sử dụng phù hợp Bên cạnh đó, Visual Studio cịn cho phép người dùng tự chọn lựa giao diện cho máy tùy thuộc vào nhu cầu sử dụng mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat 5.2.2 Lưu đồ giải thuật Sơ đồ 5.3 Lưu đồ giải thuật giao diện hệ thống Sơ đồ khối 5.2.3 Tính hệ thống  Chọn cổng COM Hình 5.30 Chọn cổng com  Chọn tốc độ Baud mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat Hình 5.31 Chọn cổng Com  Kết nối với phần cứng qua Serial Port Hình 5.32 Kết nối phần cứng qua Serial port  Chạy hệ thống Hình 5.33 Chạy kết nối  Thốt khỏi giao diện điều khiển mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat Hình 5.34 Thốt khỏi giao diện cổng kết nối  Xóa liệu Graph Hình 5.35 Xóa liệu Graph  Mở bảng chọn để thiết lập thông số PID, giá trị đặt thời gian lấy mẫu Hình 5.36 Chọn thông số hiệu chỉnh mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat  Xác nhận thơng số bảng chọn Hình 5.37 Xác nhận thông số  Hiển thị danh sách giá trị gửi từ Arduino Hình 5.38 Giao diện giá trị từ Arduino  Vẽ Graph Hình 5.39 Vẽ biểu đồ 5.2.4 Code chương trình cho tính Bảng Code tính chọn cổng COM tốc độ Baud Code tính chọn cổng COM private void PreLoad() { string[] ports = SerialPort.GetPortNames(); int[] baudrates = { 9600, 14400, 19200 }; mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat //Khởi tạo Combobox COMComboBox.DataSource = ports; baudrateComboBox.DataSource = baudrates; // Khởi tạo ZedGraph GraphPane myPane = zedGraphControl1.GraphPane; myPane.Title.Text = "Đồ thị nhiệt độ theo thời gian"; myPane.XAxis.Title.Text = "Thời gian (s)"; myPane.YAxis.Title.Text = "Nhiệt độ (*C)"; RollingPointPairList list = new RollingPointPairList(10000); LineItem curve = myPane.AddCurve("Dữ liệu", list, Color.Red, SymbolType.None); RollingPointPairList spList = new RollingPointPairList(10000); LineItem spCurve = myPane.AddCurve("Giá trị đặt", spList, Color.Black, SymbolType.None); myPane.XAxis.Scale.Min = 0; myPane.XAxis.Scale.Max = 30; myPane.XAxis.Scale.MinorStep = 1; myPane.XAxis.Scale.MajorStep = 5; myPane.YAxis.Scale.Min = lowestLimit; myPane.YAxis.Scale.Max = highestLimit; myPane.AxisChange(); } Bảng Code tính kết nối với phần cứng qua Serial Port Code tính kết nối với phần cứng qua Serial Port private void btConnect_Click (object sender, EventArgs e) { if (serialPort1.IsOpen) { if (isPause) { // Đang dừng => Ngắt kết nối Serial xóa tác vụ CreateCommand(2); // Tạo lệnh serialPort1.Write(command); // Gửi lệnh sang Arduino yêu cầu ngưng chạy serialPort1.Close(); // Ngắt kết nối Serial listView1.Items.Clear(); // Xóa listview ClearZedGraph(); // Xóa đường đồ thị ResetValue(); // Xóa liệu Form isConnected = false; btConnect.Text = "Connect"; } else mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat { // Đang chạy mà ngắt => Báo lỗi MessageBox.Show("Bạn ngắt ngắt chưa dừng", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { // Chưa kết nối => Kết nối serialPort1.PortName = COMComboBox.Text; // Lấy cổng COM từ danh sách serialPort1.BaudRate = int.Parse(baudrateComboBox.Text); // Lấy Baudrate từ danh sách try { serialPort1.Open(); // Kết nối Serial isConnected = true; isPause = true; // Vừa kết nối không chạy, phải ngưng btConnect.Text = "Disconnect"; } catch { // Cổng có kết nối khác => Báo lỗi MessageBox.Show("Không thể mở cổng" + serialPort1.PortName, "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } Bảng Code tính chạy hệ thống Code tính chạy hệ thống private void btRun_Click(object sender, EventArgs e) { if (serialPort1.IsOpen) { if (isPause) { // Chưa có setpoint sampling time => Báo lỗi if (tLabel.Text == "Sampling Time = ms" || setpointLabel.Text == "Setpoint = 0") { MessageBox.Show("Vui lịng nhập đầy đủ thơng số", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } CreateCommand(1); // Tạo lệnh serialPort1.Write(command); // Gửi lệnh sang Arduino yêu cầu chạy mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat isPause = false; btRun.Text = "Pause"; } else { CreateCommand(0); // Tạo lệnh serialPort1.Write(command); // Gửi lệnh sang Arduino yêu cầu ngưng chạy isPause = true; btRun.Text = "Run"; } } else // Chưa kết nối => Báo lỗi MessageBox.Show("Bạn thực thi chưa kết nối với thiết bị", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); } Bảng Code tính khỏi giao diện điều khiển Code tính khỏi giao diện điều khiển private void btExit_Click(object sender, EventArgs e) { DialogResult result; // Bảng chọn result = MessageBox.Show("Bạn có muốn thoát?", "Notification", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result == DialogResult.OK) { Close(); // Đóng ứng dụng } } Bảng Code tính xóa liệu Code tính xóa liệu private void btClear_Click(object sender, EventArgs e) { if (serialPort1.IsOpen) { if (isPause) { DialogResult result; // Bảng chọn result = MessageBox.Show("Bạn có muốn xóa?", "Notification", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result == DialogResult.OK) { CreateCommand(2); // Tạo lệnh mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat serialPort1.Write(command); // Gửi lệnh sang Arduino yêu cầu Reset liệu listView1.Items.Clear(); // Xóa listview ClearZedGraph(); //Xóa đường đồ thị ResetValue(); //Xóa liệu Form } } else // Chưa dừng mà xóa => Báo lỗi MessageBox.Show("Bạn khơng thể xóa chưa dừng hệ thống", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); } else // Chưa kết nối => Báo lỗi MessageBox.Show("Bạn xóa chưa kết nối với thiết bị", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); } Bảng Code tính thiết lập thông số PID, giá trị đặt thời gian lấy mẫu Code tính thiết lập thơng số PID, giá trị đặt thời gian lấy mẫu private void btSetting_Click(object sender, EventArgs e) { if (form2 == null || form2.IsDisposed) // Chưa có form tạo { form2 = new Form2(this); form2.Show(); } else form2.Show(); // Đã có form } private void Form2_Load(object sender, EventArgs e) { PreLoad(); UpdateValueTextBox(); } private void PreLoad() { //Khai báo Listview ListViewItem newItem; information[1] = "Cao"; information[0] = Form1.highestLimit.ToString(); information[2] = "STATUS: High tempertature"; newItem = new ListViewItem(information); //listView1.Items.Add(newItem); information[1] = "Thấp"; information[0] = Form1.lowestLimit.ToString(); information[2] = "STATUS: Low tempertature"; mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat newItem = new ListViewItem(information); } // Hàm kiểm tra giá trị nhập private bool CheckTheInput() { double Doublecheck; // Biến tạm int Intcheck; // Kiểm tra giá trị hợp lệ ngưỡng nhập vào if (setpointTextbox.Text.Length > 0) { if (int.TryParse(setpointTextbox.Text, out Intcheck) == false) { MessageBox.Show("Giá trị không hợp lệ", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } else { if (int.Parse(setpointTextbox.Text) >= Form1.highestLimit || int.Parse(setpointTextbox.Text) 0) { if (double.TryParse(kpTextbox.Text, out Doublecheck) == false) { MessageBox.Show("Giá trị không hợp lệ", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } else kp = double.Parse(kpTextbox.Text); } if (kiTextbox.Text.Length > 0) { if (double.TryParse(kiTextbox.Text, out Doublecheck) == false) { MessageBox.Show("Giá trị không hợp lệ", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat else ki = double.Parse(kiTextbox.Text); } if (kdTextbox.Text.Length > 0) { if (double.TryParse(kdTextbox.Text, out Doublecheck) == false) { MessageBox.Show("Giá trị không hợp lệ", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } else kd = double.Parse(kdTextbox.Text); } if (tTextbox.Text.Length > 0) { if (int.TryParse(tTextbox.Text, out Intcheck) == false) { MessageBox.Show("Giá trị không hợp lệ", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } else timeCycle = long.Parse(tTextbox.Text); } return true; } //Hàm update liệu lên hình private void UpdateValueTextBox() { setpointLabel.Text = "Setpoint = " + setpoint.ToString(); kpLabel.Text = "KP = " + kp.ToString(); kiLabel.Text = "KI = " + ki.ToString(); kdLabel.Text = "KD = " + kd.ToString(); tLabel.Text = "ST = " + timeCycle.ToString() + " ms"; } //Hàm update cảnh báo lên hình public string UpdateStatus() { string result = ""; if (result == "") { result = "STATUS: Normal tempertature"; } return result; } } mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat Bảng Code tính xác nhận thơng số bảng chọn Code tính xác nhận thơng số thoát bảng chọn private void btSubmit_Click(object sender, EventArgs e) { if (CheckTheInput()) { setpointTextbox.Text = ""; kpTextbox.Text = ""; kiTextbox.Text = ""; kdTextbox.Text = ""; tTextbox.Text = ""; // Update giá trị lên hình Form UpdateValueTextBox(); _form1.SendCommand(); // Gửi giá trị nhập lên Form gửi sang Arduino _form1.UpdateValueTextBox(); } } private void btExit_Click(object sender, EventArgs e) { Hide(); // Ẩn Form } Bảng Code hiển thị danh sách giá trị gửi từ Arduino Code tính hiển thị danh sách giá trị gửi từ Arduino private void Data_Listview() { if (isConverted) { // Tạo Item thêm vào ListView ListViewItem item = new ListViewItem(realtime.ToString()); // Gán biến realtime vào cột ListView item.SubItems.Add(datas.ToString()); // Gán biến datas vào cột ListView listView1.Items.Add(item); listView1.Items[listView1.Items.Count - 1].EnsureVisible(); // Hiện thị dòng gán gần ListView } } Bảng Code tính vẽ Graph Code tính vẽ Graph private void Draw() { mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat if (zedGraphControl1.GraphPane.CurveList.Count xScale.Max - xScale.MajorStep) { xScale.Max = realtime + xScale.MajorStep; xScale.Min = xScale.Max - 29; } // Tự động Scale theo trục y if (datas > yScale.Max - yScale.MajorStep) { yScale.Max = datas + yScale.MajorStep; } else if (datas < yScale.Min + yScale.MajorStep) { yScale.Min = datas - yScale.MajorStep; } zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); zedGraphControl1.Refresh(); } mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat mo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.satmo.ta.duoc.mo.hinh.toan.hoc.cua.thanh.tro.thiet.ke.bo.dieu.khien.pid.theo.zieglernichols.on.dinh.nhiet.do.tai.thanh.tro.xay.dung.phan.mem.giam.sat

Ngày đăng: 02/01/2024, 22:51

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan