Luận án Nghiên cứu điều khiển giảm chấn từ trường trong hệ thống treo bán tích cực trên ô tô con

Một trong những nghiên cứu sớm nhất về hệ thống treo có điều khiển điện tử là bài báo của Crosby và Karnopp, “The Active Damper”[1], được viết vào năm 1973, tuy nhiên, vào cuối năm 1995, Karnopp lưu ý rằng “Có lẽ không có gì ngạc nhiên khi nhìn lại sự tiến bộ của các hệ thống điều khiển hệ thống treo tích cực hoặc bán tích cực trong thực tế là tương đối chậm. Việc thiết kế các hệ thống như vậy đòi hỏi một khái niệm rõ ràng, không chỉ liên quan đến cơ học của hệ thống mà còn liên quan đến điều khiển tự động và động lực học của hệ thống. Các cảm biến và cơ cấu chấp hành phải có sẵn, các hạn chế của chúng cần được xem xét, cuối cùng là các thiết bị xử lý tín hiệu và điều khiển phải hiệu quả về chi phí và có sẵn. Chỉ gần đây, sự tiến bộ trong tất cả các khía cạnh này mới đạt đến mức có thể thực hiện được các thiết kế thực tế” [2].

Kể từ giữa những năm 1990, công nghệ chế tạo cảm biến, cơ cấu chấp hành trong hệ thống treo có điều khiển đã thay đổi đáng kể khiến chúng trở nên rẻ, độ nhạy cao và hoạt động đáng tin cậy hơn. Mặc dù hệ thống treo điều khiển điện tử chủ yếu được trang bị trên các loại xe cao cấp, nhưng việc áp dụng chúng trên các dòng xe phổ thông đang ngày càng được mở rộng. Trong quá trình nghiên cứu, đã có sự bùng nổ về số lượng các loại phương tiện có hệ thống treo bán tích cực sử dụng bộ giảm chấn lưu biến từ tính (MR). Trọng tâm chính của luận án này là nghiên cứu thiết kế điều khiển giảm chấn MR của hệ thống treo bán tích cực theo thời gian thực. Mục đích là để tìm ra các thuật toán điều khiển nhằm nâng cao khả năng dập tắt dao động của hệ thống treo và giảm số lượng cảm biến, từ đó giảm giá thành của hệ thống điều khiển. Để giải quyết vấn đề này cần giải quyết được mâu thuẫn: hệ thống điều khiển theo dõi càng nhiều thông số trạng thái thì chất lượng điều khiển càng tốt, nhưng việc đòi hỏi nhiều cảm biến sẽ làm cho hệ thống trở lên phức tạp và giá thành sẽ tăng cao. Trong nghiên cứu của A. Agharkakl và cộng sự đã cho thấy rằng điều khiển hệ thống treo bằng thuật toán LQR tối ưu đồng thời cả 5 trạng thái: dịch chuyển thân xe và bánh xe, vận tốc dao động thân xe và bánh xe, biên dạng mặt đường cho thấy hiệu quả rất tốt về việc giảm độ dịch chuyển của thân xe và thời gian dập tắt dao động trên các loại đường khác nhau [3]. Tuy nhiên hệ thống này sẽ đòi hỏi phải sử dụng 05 cảm biến tương ứng cho từng hệ thống treo. Điều đó đồng nghĩa với độ phức tạp và giá thành của hệ thống sẽ tăng cao, đặc biệt là cảm biến biên dạng mặt đường hiện nay vẫn còn có giá thành rất cao. 

docx 143 trang phubao 24/12/2022 2700
Bạn đang xem 20 trang mẫu của tài liệu "Luận án Nghiên cứu điều khiển giảm chấn từ trường trong hệ thống treo bán tích cực trên ô tô con", để tải tài liệu gốc về máy hãy click vào nút Download ở trên.

File đính kèm:

  • docxluan_an_nghien_cuu_dieu_khien_giam_chan_tu_truong_trong_he_t.docx
  • docx7.1 Bia ngoai luan an.docx
  • doc7.2 Bia lot luan an.doc
  • docx8.1 Bìa tóm tắt luận án.docx
  • docxBản trích yếu LA.docx
  • pdfBản trích yếu LA.pdf
  • docxThông tin LA dua len mang Tieng Anh.docx
  • pdfThông tin LA dua len mang Tieng Anh.pdf
  • docxThông tin LA dua len mang Tieng viet.docx
  • pdfThông tin LA dua len mang Tieng viet.pdf
  • pdfThuyet_minh.pdf
  • docxTóm tắt luận án.docx
  • pdfTóm tắt luận án.pdf

Nội dung text: Luận án Nghiên cứu điều khiển giảm chấn từ trường trong hệ thống treo bán tích cực trên ô tô con

  1. dụng, dễ lắp ráp và được lợi về mặt kinh tế, luận án đã tìm được bộ thông số trong điều khiển lực hợp lý, lựa chọn được các ma trận và giá trị trong bộ lọc Kalman từ đó đưa ra được phương án lựa chọn 02 cảm biến lắp trên thân xe và bánh xe. Từ các mô phỏng cho thấy tính hợp lý trong lựa chọn 02 cảm biến thông qua đánh giá về mặt hiệu quả dập tắt dao động và lực giảm chấn cần thiết phải tạo ra. 3. Thiết kế và chế tạo thiết bị kiểm tra đặc tính giảm chấn MR phù hợp với điều kiện tại Việt Nam. Thiết bị cho phép xác định đặc tính của giảm chấn MR trên xe Acurra 2011 dưới tác dụng của các điện áp điều khiển khác nhau, từ đó so sánh tính chính xác của mô hình mô phỏng với thực nghiệm. Kết quả cho thấy tính tương quan giữa mô phỏng và thực nghiệm tương đối cao (chỉ số tương quan xấp xỉ 1). Các kết quả phục vụ cho việc xác định các thông số của mô hình mô phỏng trong mô hình giảm chấn MR theo Dahl trên cơ sở giảm chấn MR Acurra 2011. Các hạn chế của đề tài: - Thiết bị kiểm tra đặc tính giảm chấn chưa thay đổi các vị trí và vận tốc của piston, chưa xác định được ảnh hưởng của các dạng xung cấp đến giảm chấn thực nên chưa đánh giá được hiệu quả giảm chấn khi hoạt động ở các chế độ điều khiển khác nhau. - Chưa thực nghiệm đánh giá hiệu quả điều khiển trên hệ thống treo thật. Hướng nghiên cứu và giải quyết tiếp: - Thiết kế phần cứng bộ chuyển đổi lực sang điện áp để cấp vào giảm chấn MR, đảm bảo đúng thực tế - Thay đổi được dịch chuyển vận tốc của piston để đánh giá ảnh hưởng của lực giảm chấn theo dịch chuyển và vận tốc - Thực nghiệm xác định hiệu quả dập tắt dao động trên mô hình hệ thống treo ¼ thật, từ đó tạo ra được ngân hàng dữ liệu về giảm chấn, đặc biệt là giảm chấn MR, đồng thời đánh giá đúng hiệu quả của nghiên cứu. 106
  2. [13]. Rideout, D. G. (1998), “Dynamic Testing and Modelling of the Interconnected Moulton Hydragas Suspension System”, Department of Mechanical Engineering Queen's University, Kingston, Ontaxio, Canada. [14]. Isermann, R. (2001), “Diagnosis Methods for Electronic Controlled Vehicles”, Vehicle System Dynamics, 36(2-3), pp.77-117. [15]. Williams, R. A., Burnham, K. J. and Webb, A. C.(1996), “Developments for an Oleo-Pneumatic Active Suspension”, in Proceedings of the 1996 IEEE International Symposium on Computer-Aided Control System Design. Dearborn, Mich. Institute of Electrical and Electronics Engineers. [16]. Guglielmino, E., Sireteanu, T., Stammers, C. W., Ghita, G. and Giuclea, M. (2008) “Semiactive Suspension Control”, Springer-Verlag, London. [17]. Stembridge, N., Levesley, M., Crolla, D., Sims, N. and Burnett, M. (2006), “Real Time Control of a Magnetorheological Damper for Vehicle Suspension Systems”, in Fisita 2006, Yokohama, Japan [18]. Goncalves, F. D. and Ahmadian, M. (2002), “In Search of a Suitable Control Policy for Intelligent Vehicle Suspensions”, in ASME IMECE 2002: Intelligent Systems - III. New Orleans, Louisiana. [19]. Hyvärinen, J.-P. (2004), “The Improvement of Full Vehicle Semi-Active Suspension Through Kinematical Mode lFaculty of Technology”, Department of Mechanical Engineering, University of Oulu, Oulu, Finland, p.159. [20]. Li, R., Chen, W. M., Yu, M. and Liu, D. K.(2004), “Fuzzy intelligent control of automotive vibration via magneto-rheological damper”, in Cybernetics and Intelligent Systems, 2004 IEEE Conference on. [21]. Song, X., Ahmadian, M. and Southward, S.(2003), “An Adaptive Semiactive Control Algorithm for Vehicle Suspension Systems”, in ASME IMECE 2003: 2003 International Mechanical Engineers Conference. Washington, D.C. [22]. Chang, Shih-Lang, Wu, C.-l. and Lee, D. T (1999), “A Muscular-Like Compliance Control for Active Vehicle Suspension”, in 1999 EEE International Conference on Robotics & Automation, Detroit, Michigan. [23]. Ahmadian, M. and Simon, D. E.(2002, “Improving Roll Stability of Vehicles with High Center of Gravity by using Magneto-Rheological Dampers”, in 2002 108
  3. suspension”, in Control, 1994. Control '94. Volume 1., International Conference on. [36]. Gehm, R. (2001), “Delphi Improves Cadillac's Ride”, Automotive Engineering International, 109(10), pp.32-3. [37]. Voelcker, J. (2008), “The Soul of a New Mercedes”, IEEE Spectrum. [38]. Dixit, R. K. and Buckner, G. D. (2005), “Sliding Mode Observation and Control for Semiactive Vehicle Suspensions, Vehicle System Dynamics, 43(2), pp.83-105. [39]. Goncalves, F. D. and Ahmadian, M.(2002), “In Search of a Suitable Control Policy for Intelligent Vehicle Suspensions”, in ASME IMECE 2002: Intelligent Systems - III. New Orleans, Louisiana. [40]. Cole, D. J. (2001), “Fundamental Issues in Suspension Design for Heavy Road Vehicles, Vehicle System Dynamics, 35(4-5), pp.319-60. [41]. Lauwerys, C., Swevers, J. and Sas, P.(2004), “Design and Experimental Validation of a Linear Robust Controller For An Active Suspension of a Quarter Car”, in American Control Conference. Boston Massachusetts. [42]. Koo, J.-H., Ahmadian, M., Setareh, M. and Murray, T. M.(2003), “Experimental Dynamic Analysis of Magneto-Rheological Tuned Vibration Absorbers”, in ASME 2003 Design Engineering Technical Conferences and Computers and Information in Engineering Conference. Chicago, Illinois USA [43]. Lu, J. and DePoyster, M. (2002), “Multiobjective Optimal Suspension Control to Achieve Integrated Ride and Handling Performance”, IEEE Transactions on Control Systems Technology, 10(6), pp.807-21. [44]. Vaughan, J. E. (2004), “Active and Semi-Active Control to Counter Vehicle Payload”. [45]. Wang, F.-C. (2001), “Design and Synthesis of Active and Passive Vehicle Suspensions”, Queens' College Control Group Department of Engineering University of Cambridge, Cambridge UK. [46]. Yagiz, N., Yuksek, I. and Sivrioglu, S. (2000), “Robust Control of Active Suspensions for a Full Vehicle Model Using Sliding Mode Control”, JSME international journal. Series C, Mechanical systems, machine elements and manufacturing, 43(2), pp.253-8. [47]. Yu, M., Liao, C. R., Chen, W. M. and Huang, S. L. (2006), “Study on MR 110
  4. Vehicle Seat Suspensions”, Mechanical Engineering Virginia Polytechnic Institute and State University, Blacksburg, Virginia. [60]. Wagner, J. and Liu, X.(2000), “Nonlinear Modeling and Control of Automotive Vibration Isolation Systems, in American Control Conference”. Chicago, Illinois. [61]. Ahmadian, M., Song, X. and Southward, S. C. (2004), “No-Jerk Skyhook Control Methods for Semiactive Suspensions”, Journal of Vibration and Acoustics, 126(4), pp.580-4. [62]. Song, X. and Ahmadian, M. (2004), “Study of Semiactive Adaptive Control Algorithms with Magneto Rheological Seat Suspension”, in 2004 SAE World Congress. Detroit, Michigan. [63]. Caponetto, R., Diamante, O., Fargione, G., Ristano, A. and Tringali, D. (2003), “A Soft Computing Approach to Fuzzy Sky-Hook Control of SemiActive Suspension”, IEEE Transactions on Control Systems Technology, 11(No. 6). [64]. Stubberud, A., DiStefano, J. and Williams, I. (1994), “Schaum's Outline of Feedback and Control Systems”, McGraw-Hill, Inc., New York, NY, USA. [65]. Karnopp, D. C. and Crosby, M. J. (1974), “System for Controlling the Transmission of Energy between Spaced Members Lord Corporation”, U.S. [66]. Hashiyama, T., Furuhashi, T. and Uchikawa, Y.(1995), “Design of fuzzy controllers for semi-active suspension generated through the genetic algorithm”, in Artificial Neural Networks and Expert Systems, 1995. Proceedings., Second New Zealand International Two Stream Conference on. [67]. Simon, D. and Ahmadian, M. (2001), “Vehicle Evaluation of the Performance of Magneto Rheological Dampers for Heavy Truck Suspensions”, Journal of Vibration and Acoustics, 123, pp.365-75. [68]. Strang, G. (1980), “Linear Algebra and Its Applications”, Academic Press, Inc., New York [69]. Kirk, D. E. (1970), “Optimal Control Theory: An Introduction”, Prentice-Hall, Inc., Englewood Cliffs, New Jersey. [70]. MacCluer, C. R. (2005), “Calculus of Variations: mechanics, control, and other applications”, Prentice Hall, Upper Saddle River, NJ. 112
  5. [82]. Simon, D. (2006), “Optimal State Estimation: Kalman, H-Infinity, and Nonlinear Approaches”, Wiley, Hoboken, New Jersey. [83]. Lee, H. J., Jung, H. J., Cho, S. W. and Lee, I. W.(2008), “An Experimental Study of Semiactive Modal Neuro-Control Scheme using Mr Damper for Building Structure”,Journal of Intelligent Material Systems and Structures, 19(9), pp.1005- 15 [84]. Yu, F., Zhang, J. W. and Crolla, D. A.(2000), “Proceedings of the Institution of Mechanical Engineers”. [85]. Yoshimura, T., Ananthanarayana, N. and Deepak, D.(1987), “An Active Lateral Suspension to a Track/Vehicle System using Stochastic Optimal Control”, Journal of Sound and Vibration, 115(3), pp.473-82. [86]. Best, M. C., Newton, A. P. and Tuplin, S. (2007), “Parametric Identification of Vehicle Handling using an Extended Kalman Filter”, International Journal of Vehicle Autonomous Systems, 5(3-4), pp.256 – 73. [87]. Sadati, S. H., Malekzadeh, S. and Ghasemi, M. (2008), “Optimal control of an 8-DOF vehicle active suspension system using Kalman observer”, Shock and Vibration, 15(5), pp.493-503. [88]. Shital M. Pawar, A.A. Panchwadkar (2017), “Estimation of State Variables of Active Suspension System using Kalman Filter”, Mechanical Engineering Department, Pimpri-Chinchwad College of Engineering, Pune, Maharashtra, India [89]. Olof Lindg¨arde,(2002), “Kalman Filtering in Semi-Active Suspension Control”, 15th Triennial World Congress. [90]. Zuohai Yan Shuqi Zhao, (2012), “Road Condition Predicting with Kalman Filter for Magneto-Rheological Damper in Suspension System”, Blekinge Institute of Technology. [91]. Labane Chrif a, Zemalache Meguenni Kaddac,a, (2014), “Aircraft Control System Using LQG and LQR Controller with Optimal Estimation-Kalman Filter Design”, Procedia Engineering, pp. 254-257. [92]. Redfield, R. C. and Karnopp, D. C. (1988), “Optimal performance of Variable Component Suspensions”, Vehicle System Dynamics, 29, pp.231-53. [93]. Smith, C., McGehee, D. and Healey, A. (1978), “The Prediction of Passenger 114
  6. [104]. Carlson JD, Spencer BF (1996), “Magneto-rheological fluid dampers for semi- active seismic control”. Proc 3rd Int Conf on 9Motion and Vibration Control, III, pp 35– 40 [105]. Rabinow J (1948), “The magnetic fluid clutch”. AIEE Trans 67, 1308 [106]. Ashwani Kumar and Mangal S K (2010a), “Comparative Study of Vibration- Control Systems”, On-CD, in the International Conference on Engineering Innovations: A Fillip to Economic Developments, Held at Continental Group of Institutes, Jalvehra, Fathegarh Sahib, Punjab Held on February 18 to 20. [107]. Gavin H, Hoagg J and Dobossy M (2001), “Optimal design of MR dampers. In: Proceedings of U.S.–Japan workshop on smart structures for improved seismic performance in urban regions, Seattle WA, 14 August 2001, pp.225–236 [108]. Wang X and Gordaninejad F (2009), “A new magnetorheologi-cal fluid- elastomer mount phenomenological modeling and experimental study”. Smart Materials and Structures 18: 095045 (9pp.). [109]. Lord Corporation Engineering note (1999), "Designing with MR Fluids", Lord Corporation Engineering note, Thomas Lord Research Center, Cary, NC, December 1999. [110]. Sulaymon Eshkabilov (2011), “Modeling and simulation of non-linear and hysteresis behavior of magneto-rheological dampers in the example of quarter-car model”, Tashkent Automotive Road Institute Amir Temur Str. 20, Tashkent -100060, Uzbekistan. [111]. Ashwani Kumar and S K Mangal (2013), “Modeling, testing and evaluation of magneto-rheological shock absorber” ISSN 2278 – 0149 www.ijmerr.com Vol. 2, No. 1, January 2013 116
  7. PHỤ LỤC PHỤ LỤC 1. Bảng so sánh lực giảm chấn giữa mô phỏng và thực nghiệm ở cùng vị trí dịch chuyển, dưới tác dụng điện áp 0.1V Lực giảm chấn (N) Vị trí dịch chuyển Thực nghiệm Mô phỏng -4.75 116 123.1 -4.75 104 123.1 -2.11 184 191.6 -2.05 180 191.6 1.66 205 199.8 1.87 208 197.5 4.65 132 133 4.66 148 130.5 -4.89 -68 -112.4 -4.86 -140 -115.2 -2.92 -196 -183.6 0.71 -200 -204 1.09 -188 -201 4.19 -100 -145.2 4.32 -88 -139.8 PHỤ LỤC 2. Bảng so sánh lực giảm chấn giữa mô phỏng và thực nghiệm ở cùng vị trí vận tốc, dưới tác dụng điện áp 0.1V Lực giảm chấn Vị trí vận tốc Thực nghiệm Mô phỏng -30.54 -196 -202 -29.81 -200 -200 -25.93 -188 -183.6 -13.96 -100 -135 -12.33 -88 -126.1 -8.282 -68 -84.99 118
  8. } void loop() { // Điều khiển Arduino qua giá trị của biến state if (Serial.available()) { char temp = Serial.read(); if (temp == '0') state = 0; if (temp == '1') state = 1; if (temp == '2') state = 2; } // Thực thi các trường hợp với các giá trị của biến state switch (state) { // state = 0: dừng Arduino case 0: break; // state = 1: thực thi hàm đọc giá trị biến trở, xuất dữ liệu và thời gian thực qua Serial, phân tách nhau bởi ký tự gạch đứng “|” case 1: // if(check()== 2) { bien_tro(); data1(); Serial.print(time_now); Serial.print("|"); Serial.print(data2); Serial.print("|"); Serial.println(goc_quay); } break; // state = 2: Reset dữ liệu và thời gian về 0 case 2 data = 0; goc_quay = 0; time_now = 0; state = 0; pulse_counter=0; pulse_counter1=0; test=0; break; } } 120
  9. { string SDatas = String.Empty; string SDatas1 = String.Empty; string SRealTime = string.Empty; int status = 0; double realtime = 0; double datas = 0; double datas1 = 0; const float pi = 3.14F; double goc_quay; double chuyen_vi_x; double van_toc; int min = 0; double temp; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { comboBox1.DataSource = SerialPort.GetPortNames(); comboBox1.Text = Properties.Settings.Default.ComName; //1 GraphPane myPane1 = zedGraphControl1.GraphPane; myPane1.Title.Text = "Đồ thị lực theo thời gian"; myPane1.XAxis.Title.Text = "Thời gian (s)"; myPane1.YAxis.Title.Text = "Lực (N)"; RollingPointPairList list1 = new RollingPointPairList(60000); LineItem curve1 = myPane1.AddCurve("F", list1, Color.Black, SymbolType.None); myPane1.XAxis.MajorGrid.IsVisible = true;// tạo lưới cho biểu đồ myPane1.YAxis.MajorGrid.IsVisible = true; myPane1.XAxis.MajorGrid.Color = Color.Black; myPane1.YAxis.MajorGrid.Color = Color.Black; myPane1.Chart.Fill = new Fill(Color.Red,Color.FromArgb(255, 255, 255), 90F); myPane1.Title.FontSpec.FontColor = Color.Red; curve1.Line.Width = 1.0F; myPane1.XAxis.Scale.Min = 0; myPane1.XAxis.Scale.Max = 30; myPane1.XAxis.Scale.MinorStep = 1; myPane1.XAxis.Scale.MajorStep = 5; myPane1.YAxis.Scale.Min = -250; myPane1.YAxis.Scale.Max = 25; myPane1.AxisChange(); //2 GraphPane myPane2 = zedGraphControl2.GraphPane; myPane2.Title.Text = "Đồ thị lực theo chuyển vị"; myPane2.XAxis.Title.Text = "Chuyển vị (cm)"; 122
  10. Draw(); Data_Listview(); status = 0; } } // Hàm này lưu lại cổng COM đã chọn cho lần kết nối private void SaveSetting() { Properties.Settings.Default.ComName = comboBox1.Text; Properties.Settings.Default.Save(); } // Nhận và xử lý string gửi từ Serial private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e) { try { string[] arrList = serialPort1.ReadLine().Split('|'); // Đọc một dòng của Serial, cắt chuỗi khi gặp ký tự gạch đứng SRealTime = arrList[0]; // Chuỗi đầu tiên lưu vào SRealTime SDatas = arrList[1]; // Chuỗi thứ hai lưu vào SDatas if (Int32.Parse(SDatas) -0.08 && chuyen_vi_x < -0.071) { MessageBox.Show(goc_quay + ""); } van_toc = 5 * ((goc_quay) / realtime) * (Math.Sin(goc_quay) + 0.1 * Math.Sin(2 * goc_quay)); van_toc = Math.Round(van_toc, 2); status = 1; // Bắt sự kiện xử lý xong chuỗi, đổi starus về 1 để hiển thị dữ liệu trong ListView và vẽ đồ thị } catch { return; } } // Hiển thị dữ liệu trong ListView 124
  11. xScale1.Min = xScale1.Max - 30; } // Tự động Scale theo trục y if (datas > yScale1.Max - yScale1.MajorStep) { yScale1.Max = datas + yScale1.MajorStep; } else if (datas xScale2.Max - xScale2.MajorStep) { xScale2.Max = chuyen_vi_x + xScale2.MajorStep; xScale2.Min = xScale2.Max - 30; } // Tự động Scale theo trục y if (datas > yScale2.Max - yScale2.MajorStep) { yScale2.Max = datas + yScale2.MajorStep; } else if (datas < yScale2.Min + yScale2.MajorStep) { yScale2.Min = datas - yScale2.MajorStep; } zedGraphControl2.AxisChange(); zedGraphControl2.Invalidate(); zedGraphControl2.Refresh(); //3 if (zedGraphControl3.GraphPane.CurveList.Count <= 0) return; 126
  12. myPane1.Chart.Fill = new Fill(Color.Red, Color.FromArgb(255, 255, 255), 90F); myPane1.Title.FontSpec.FontColor = Color.Red; myPane1.XAxis.Scale.Min = 0; myPane1.XAxis.Scale.Max = 30; myPane1.XAxis.Scale.MinorStep = 1; myPane1.XAxis.Scale.MajorStep = 5; myPane1.YAxis.Scale.Min = -250; myPane1.YAxis.Scale.Max = 250; zedGraphControl1.AxisChange(); //2 zedGraphControl2.GraphPane.CurveList.Clear(); // Xóa đường zedGraphControl2.GraphPane.GraphObjList.Clear(); // Xóa đối tượng zedGraphControl2.AxisChange(); zedGraphControl2.Invalidate(); GraphPane myPane2= zedGraphControl2.GraphPane; myPane2.Title.Text = "Đồ thị lực theo chuyển vị "; myPane2.XAxis.Title.Text = "Chuyển vị (cm)"; myPane2.YAxis.Title.Text = "Lực (N)"; RollingPointPairList list2 = new RollingPointPairList(60000); LineItem curve2 = myPane2.AddCurve("F-S", list2, Color.Black, SymbolType.None); myPane2.XAxis.MajorGrid.IsVisible = true; myPane2.YAxis.MajorGrid.IsVisible = true; myPane2.XAxis.MajorGrid.Color = Color.Black; myPane2.YAxis.MajorGrid.Color = Color.Black; myPane2.Chart.Fill = new Fill(Color.Green, Color.FromArgb(255, 255, 255), 90F); myPane2.Title.FontSpec.FontColor = Color.Green; myPane2.XAxis.Scale.Min = -7; myPane2.XAxis.Scale.Max = 7; myPane2.XAxis.Scale.MinorStep = 1; myPane2.XAxis.Scale.MajorStep = 5; myPane2.YAxis.Scale.Min = -250; myPane2.YAxis.Scale.Max = 250; zedGraphControl2.AxisChange(); //3 zedGraphControl3.GraphPane.CurveList.Clear(); // Xóa đường zedGraphControl3.GraphPane.GraphObjList.Clear(); // Xóa đối tượng zedGraphControl3.AxisChange(); zedGraphControl3.Invalidate(); GraphPane myPane3 = zedGraphControl3.GraphPane; myPane3.Title.Text = "Đồ thị lực theo vận tốc "; myPane3.XAxis.Title.Text = "Vận tốc (cm/s)"; myPane3.YAxis.Title.Text = "Lực (N)"; RollingPointPairList list3 = new RollingPointPairList(60000); LineItem curve3 = myPane3.AddCurve("F-V", list3, Color.Black, SymbolType.None); myPane3.XAxis.MajorGrid.IsVisible = true; myPane3.YAxis.MajorGrid.IsVisible = true; myPane3.XAxis.MajorGrid.Color = Color.Black; 128
  13. int i = 2; int j = 1; foreach (ListViewItem comp in listView1.Items) { ws.Cells[i, j] = comp.Text.ToString(); foreach (ListViewItem.ListViewSubItem drv in comp.SubItems) { ws.Cells[i, j] = drv.Text.ToString(); j++; } j = 1; i++; } } // Sự kiện nhấn nút btConnect private void btConnect_Click(object sender, EventArgs e) { if (serialPort1.IsOpen) { serialPort1.Write("2"); //Gửi ký tự "2" qua Serial, tương ứng với state = 2 serialPort1.Close(); btConnect.Text = "Kết nối"; btExit.Enabled = true; SaveSetting(); // Lưu cổng COM vào ComName } else { serialPort1.PortName = comboBox1.Text; // Lấy cổng COM serialPort1.BaudRate = 9600; // Baudrate là 9600, trùng với baudrate của Arduino try { serialPort1.Open(); btConnect.Text = "Ngắt kết nối"; btExit.Enabled = false; } catch { MessageBox.Show("Không thể mở cổng" + serialPort1.PortName, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } // Sự kiện nhấn nút btExit private void btExit_Click(object sender, EventArgs e) 130
  14. } else MessageBox.Show("Bạn không thể dừng khi chưa kết nối với thiết bị", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } // Sự kiện nhấn nút Clear private void btClear_Click(object sender, EventArgs e) { if (serialPort1.IsOpen) { DialogResult traloi; traloi = MessageBox.Show("Bạn có chắc muốn xóa?", "Xóa dữ liệu", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (traloi == DialogResult.OK) { if (serialPort1.IsOpen) { serialPort1.Write("2"); //Gửi ký tự "2" qua Serial listView1.Items.Clear(); // Xóa listview //Xóa đường trong đồ thị ClearZedGraph(); //Xóa dữ liệu trong Form ResetValue(); } else MessageBox.Show("Bạn không thể dừng khi chưa kết nối với thiết bị", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else MessageBox.Show("Bạn không thể xóa khi chưa kết nối với thiết bị", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } 132