(Đồ án hcmute) thiết kế hệ thống iots điều khiển và giám sát vườn rau quả trong nông nghiệp giao tiếp bằng sóng rf sử dụng nrf24l01x

172 2 0
(Đồ án hcmute) thiết kế hệ thống iots điều khiển và giám sát vườn rau quả trong nông nghiệp giao tiếp bằng sóng rf sử dụng nrf24l01x

Đ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

BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT THÀNH PHỐ HỒ CHÍ MINH ĐỒ ÁN TỐT NGHIỆP NGÀNH CNKT ĐIỀU KHIỂN-TỰ ĐỘNG HOÁ THIẾT KẾ HỆ THỐNG IOTS ĐIỀU KHIỂN VÀ GIÁM SÁT VƯỜN RAU/QUẢ TRONG NƠNG NGHIỆP, GIAO TIẾP BẰNG SĨNG RF SỬ DỤNG NRF24L01X GVHD: NGUYỄN VĂN THÁI SVTH: TRẦN ĐĂNG KHÔI MSSV: 15151044 SKL 0 Tp Hồ Chí Minh, tháng 12/2019 an BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT THÀNH PHỐ HỒ CHÍ MINH ĐỒ ÁN TỐT NGHIỆP TRẦN ĐĂNG KHÔI – MSSV: 15151044 THIẾT KẾ HỆ THỐNG IOTS ĐIỀU KHIỂN VÀ GIÁM SÁT VƯỜN RAU/QUẢ TRONG NÔNG NGHIỆP, GIAO TIẾP BẰNG SÓNG RF SỬ DỤNG NRF24L01X NGÀNH: CNKT ĐIỀU KHIỂN-TỰ ĐỘNG HOÁ Giảng viên hướng dẫn: TS NGUYỄN VĂN THÁI Tp Hồ Chí Minh, tháng 12/2019 an an an LỜI CAM ĐOAN Tôi xin cam đoan đề tài tốt nghiệp thực hiện, giúp đỡ cho việc thực đề tài có đồng ý, trích dẫn liên quan đến luận văn trước có ghi rõ nguồn gốc tham khảo từ cơng trình nghiên cứu cơng bố tạp chí khoa học Các số liệu thực nghiệm, đo đạt, kết nghiên cứu nêu đề trung thực, khách quan phù hợp với thực tiễn, chưa cơng bố cơng trình nghiên cứu khác Tp Hồ Chí Minh, ngày 28 tháng 12 năm 2019 Người thực Trần Đăng Khôi an GVHD: TS NGUYỄN VĂN THÁI LỜI CẢM ƠN Để hoàn thành đề tài này, bên cạnh cố gắng thân cịn có giúp đỡ tận tình q Thầy/Cơ giảng dạy, tận tâm truyền đạt, hướng dẫn, tạo nhiều điều kiện thuận lợi sở vật chất, trang thiết bị phục vụ trình học tập nghiên cứu trường Đặc biệt, xin gửi lời cảm ơn chân thành đến Thầy TS Nguyễn Văn Thái tận tình hướng dẫn, hỗ trợ thiết bị đo đạc, chi phí phịng Lab làm việc Cuối cùng, tơi xin gửi lời cảm ơn đến gia đình, bạn học viên làm việc nghiên cứu Lab 3Dvision, Anh/Chị Thạc sĩ trước giúp đỡ cho nhiều suốt thời gian thực đề tài Xin chân thành cảm ơn! Tp Hồ Chí Minh, ngày 28 tháng 12 năm 2019 Người thực Trần Đăng Khôi SVTH: TRẦN ĐĂNG KHÔI II an GVHD: TS NGUYỄN VĂN THÁI TÓM TẮT Đề tài tập trung thiết kế hệ thống IoTs điều khiển giám sát vườn rau/quả nơng nghiệp, giao tiếp sóng RF sử dụng NRF24L01x Ngoài tất liệu giám sát – điều khiển lưu trữ Webserver Đề tài thực phần cứng tự thiết kế thi công, bao gồm mạch cảm biến lấy liệu vật lý từ môi trường, mạch công suất điều khiển thiết bị chiều, mạch trung tâm gọi Gateway có hình OLED 1.3 inch, sử dụng NRF24L01x để giao tiếp với mạch cảm biến mạch cơng suất, ngồi Gateway sử dụng Wifi GPRS để truyền nhận liệu lên Webserver Firmware tự lập trình sử dụng trình biên dịch Keil C nạp vào IC xử lý chủ đạo STM32F103x Sử dụng web API có sẵn, để giám sát liệu cảm biến điều khiển ngõ ngoại vi Việc thiết kế hệ thống phần cứng mới, tảng để xây dựng hệ Device hoàn chỉnh sử dụng tối thiểu Gateway trì sử ổn định thiết bị Webserver SVTH: TRẦN ĐĂNG KHÔI III an GVHD: TS NGUYỄN VĂN THÁI ABSTRACT The project focused on designing an IoTs control systems for monitoring and control in agriculture, RF based communication using NRF24L01x In addition, all data is monitored - controlled and stored on Webserver The project use self-designed hardware, including sensor circuits that monitor physical data from the environment (Sensors), and a power circuit that controls a DC device (Power) A central circuit called Gateway using 1.3 inch OLED, and NRF24L01x modules to communicate with sensor circuits and power circuits In addition Gateway will use Wifi to transmit data to Webserver Self-programmed firmware using Keil C compiler are loaded into main processor IC using STM32F103x Using built-in web API, to monitor sensors data and control peripheral output The design of a new hardware system will be the basis for building a complete control system using the least Gateway while maintaining stable connection between the D physical device and the Webserver SVTH: TRẦN ĐĂNG KHÔI IV an GVHD: TS NGUYỄN VĂN THÁI MỤC LỤC TRANG TỰA XÁC NHẬN CỦA GIẢNG VIÊN HƯỚNG DẪN LỊCH TRÌNH THỰC HIỆN ĐỒ ÁN LỜI CAM ĐOAN I LỜI CẢM ƠN II TÓM TẮT III ABSTRACT IV MỤC LỤC V DANH SÁCH CÁC BẢNG X DANH SÁCH CÁC HÌNH XI Chương TỔNG QUAN 1.1 Đặt vấn đề 1.2 Mục tiêu đề tài 1.3 Nhiệm vụ giới hạn đề tài 1.4 Phương pháp nghiên cứu 1.5 Nội dung đề tài Chương CƠ SỞ LÝ THUYẾT A Các vấn đề Kỹ thuật 2.1 Giới thiệu công nghệ IoT 2.1.1 Khái niệm IoT .9 2.1.2 Cấu trúc IoT .10 SVTH: TRẦN ĐĂNG KHÔI V an GVHD: TS NGUYỄN VĂN THÁI 2.1.3 Giao tiếp thiết bị IoT 12 2.2 Wifi 13 2.2.1 Giới thiệu Wifi .13 2.2.2 Nguyên tắc hoạt động Wifi .14 2.2.3 Một số chuẩn kết nối Wifi phổ biến 15 2.3 Giao thức kết nối tảng Web .16 2.3.1 Giao thức 16 2.3.2 Giao thức kết nối sử dụng .16 2.3.3 Nền tảng Web API 17 2.3.3.1 ASP.NET Web API gì? 17 2.3.3.2 Đặc điểm Web API .18 2.3.3.3 Ưu điểm Web API .18 2.4 Module kết nối Wifi ESP8266 .18 2.4.1 Giới thiệu module Wifi ESP826 .18 2.4.2 Các loại module ESP8266 thị trường 19 2.4.3 Lựa chọn module ESP8266 .19 2.5 NRF24L01x .20 2.5.1 Giới thiệu NRF24L01x 20 2.5.2 ShockBurstTM 20 2.5.3 Enhanced ShockBurstTM 21 2.5.4 Data Pipes 21 2.5.5 Gói liệu NRF24L01x 23 2.6 Vi xử lý ARM Cortex-M3 23 2.6.1 Giới thiệu 23 2.6.2 Hiệu suất cao .24 2.6.3 Dễ sử dụng, phát triển ứng dụng nhanh chóng hiệu 25 2.6.4 Giảm chi phí lượng tiêu thụ 26 2.7 Cảm biến cường độ ánh sáng TSL2561 26 2.8 Cảm biến nhiệt độ - độ ẩm SHT1x 27 SVTH: TRẦN ĐĂNG KHÔI VI an GVHD: TS NGUYỄN VĂN THÁI /* MCU Configuration */ /* Reset of all peripherals, Initializes the Flash interface and the Systick */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_SPI2_Init(); MX_TIM2_Init(); MX_TIM3_Init(); MX_TIM4_Init(); MX_RTC_Init(); MX_TIM1_Init(); /* Initialize interrupts */ MX_NVIC_Init(); /* USER CODE BEGIN */ nrf_config(); // Start TIM2 while(HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_1)!=HAL_OK){}; while(HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_2)!=HAL_OK){}; while(HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_3)!=HAL_OK){}; while(HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_4)!=HAL_OK){}; // Start TIM3 while(HAL_TIM_PWM_Start(&htim3,TIM_CHANNEL_1)!=HAL_OK){}; while(HAL_TIM_PWM_Start(&htim3,TIM_CHANNEL_2)!=HAL_OK){}; while(HAL_TIM_PWM_Start(&htim3,TIM_CHANNEL_3)!=HAL_OK){}; while(HAL_TIM_PWM_Start(&htim3,TIM_CHANNEL_4)!=HAL_OK){}; // Start TIM4 while(HAL_TIM_PWM_Start(&htim4,TIM_CHANNEL_1)!=HAL_OK){}; while(HAL_TIM_PWM_Start(&htim4,TIM_CHANNEL_2)!=HAL_OK){}; while(HAL_TIM_PWM_Start(&htim4,TIM_CHANNEL_3)!=HAL_OK){}; while(HAL_TIM_PWM_Start(&htim4,TIM_CHANNEL_4)!=HAL_OK){}; // Init PWM SVTH: TRẦN ĐĂNG KHÔI 141 an GVHD: TS NGUYỄN VĂN THÁI PWM1_Duty = duty1; PWM2_Duty = duty2; PWM3_Duty = duty3; PWM4_Duty = duty4; PWM5_Duty = duty5; PWM6_Duty = duty6; PWM7_Duty = duty7; PWM8_Duty = duty8; PWM9_Duty = duty9; PWM10_Duty = duty10; PWM11_Duty = duty11; PWM12_Duty = duty12; // Init Debug LED for(uint8_t i = 0;i < 3;i++) { DL1(1); DL2(1); DL3(1); DL4(1); HAL_Delay(100); DL1(0); DL2(0); DL3(0); DL4(0); HAL_Delay(100); } DL1(1); // Init Fan FAN1(0); FAN2(0); // Delay HAL_Delay(1000); // Start Timer1 HAL_TIM_Base_Start_IT(&htim1); /* USER CODE END */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { configFunction(); if(nrf_received) { memset(nrf_tx_buffer,0,sizeof(nrf_tx_buffer)); nrf_tx_buffer[0] = nrf_packet.functionCode; strncpy((char*)&nrf_tx_buffer[1],part_token,1); // Message nrf_tx_buffer[2] = setDuty1; nrf_tx_buffer[8] = setDuty7; nrf_tx_buffer[3] = setDuty2; nrf_tx_buffer[9] = setDuty8; nrf_tx_buffer[4] = setDuty3; nrf_tx_buffer[10] = setDuty9; nrf_tx_buffer[5] = setDuty4; nrf_tx_buffer[11] = setDuty10; nrf_tx_buffer[6] = setDuty5; nrf_tx_buffer[12] = setDuty11; SVTH: TRẦN ĐĂNG KHÔI 142 an GVHD: TS NGUYỄN VĂN THÁI nrf_tx_buffer[7] = setDuty6; nrf_tx_buffer[13] = setDuty12; if(nrf_packet.functionCode == f_post) { turnLED = 1; turnLED_PreTimer = timer1_ms; updateOutput(); } nrf_config(); nrf_send_packet(&nrf,nrf_tx_buffer); nrf_received = 0; } if(turnLED) DL4(1); else DL4(0); if(setDuty1 >= 80||setDuty2 >= 80||\ setDuty3 >= 80||setDuty4 >= 80||\ setDuty5 >= 80||setDuty6 >= 80) FAN1(1); else FAN1(0); if(setDuty7 >= 80||setDuty8 >= 80||\ setDuty9 >= 80||setDuty10>= 80||\ setDuty11>= 80||setDuty12>= 80) FAN2(1); else FAN2(0); /* USER CODE END WHILE */ /* USER CODE BEGIN */ updateTimer(); } /* USER CODE END */ } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; SVTH: TRẦN ĐĂNG KHÔI 143 an GVHD: TS NGUYỄN VĂN THÁI /** Initializes the CPU, AHB and APB busses clocks */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; RCC_OscInitStruct.LSEState = RCC_LSE_ON; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB busses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { Error_Handler(); } PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC; PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { Error_Handler(); } } /** * @brief NVIC Configuration * @retval None */ static void MX_NVIC_Init(void) { /* EXTI15_10_IRQn interrupt configuration */ HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0); SVTH: TRẦN ĐĂNG KHÔI 144 an GVHD: TS NGUYỄN VĂN THÁI HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); /* TIM1_UP_IRQn interrupt configuration */ HAL_NVIC_SetPriority(TIM1_UP_IRQn, 0, 2); HAL_NVIC_EnableIRQ(TIM1_UP_IRQn); /* EXTI0_IRQn interrupt configuration */ HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 1); HAL_NVIC_EnableIRQ(EXTI0_IRQn); } /* USER CODE BEGIN */ void delay(unsigned long _t){while(_t );} void nrf_config(void) { nrf24l01_config config; config.data_rate = NRF_DATA_RATE_250KBPS; config.tx_power = NRF_TX_PWR_0dBm; config.crc_width = NRF_CRC_WIDTH_2B; config.addr_width = NRF_ADDR_WIDTH_3; config.payload_length = 30; // maximum is 32 bytes config.retransmit_count = 10; // maximum is 15 times config.retransmit_delay = 0x0F; // 4000us, LSB:250us config.rf_channel = 0; config.rx_address = rx_address; config.tx_address = tx_address; config.rx_buffer = (uint8_t*)nrf_rx_buffer; config.spi = &hspi2; config.spi_timeout = 20; // milliseconds config.ce_port = RF_CE_GPIO_Port; config.ce_pin = RF_CE_Pin; config.irq_port = RF_IRQ_GPIO_Port; config.irq_pin = RF_IRQ_Pin; config.csn_port = RF_CSN_GPIO_Port; config.csn_pin = RF_CSN_Pin; nrf_init(&nrf, &config); } void configFunction(void) { if(button >= 1) { if(button >= 3) { DL2(1); SVTH: TRẦN ĐĂNG KHÔI 145 an GVHD: TS NGUYỄN VĂN THÁI char message[25]; strcpy(message,pass_token); strcat(message,(char*)part_token); strcat(message,auth_token); uint8_t tmp = nrf_sendSS(f_config,message,3000); if(tmp) { for(uint8_t i = 0;i < 5;i++) { DL3(1); HAL_Delay(100); DL3(0); HAL_Delay(100); } } else { for(uint8_t i = 0;i < 5;i++) { DL2(1); HAL_Delay(100); DL2(0); HAL_Delay(100); } } } } else if(button == 0) DL2(0); } uint8_t nrf_sendSS(FUNCTION_CODE _function_code, char *_message, uint16_t timeOut) { nrf_tx_buffer[0] = _function_code; strcpy((char*)&nrf_tx_buffer[1],_message); nrf_config(); nrf_send_packet(&nrf,nrf_tx_buffer); while(timeOut ) { if(nrf_received) { nrf_received = 0; return 1; } HAL_Delay(1); } SVTH: TRẦN ĐĂNG KHÔI 146 an GVHD: TS NGUYỄN VĂN THÁI nrf_received = 0; return 0; } void updateOutput(void) { // Set Duty1 if(nrf_rx_buffer[18]!=0) setDuty1 = maxDuty; else setDuty1 = 0; // Set Duty2 if(nrf_rx_buffer[19]!=0) setDuty2 = maxDuty; else setDuty2 = 0; // Set Duty3 if(nrf_rx_buffer[20]!=0) setDuty3 = maxDuty; else setDuty3 = 0; // Set Duty4 if(nrf_rx_buffer[21]!=0) setDuty4 = maxDuty; else setDuty4 = 0; // Set Duty5 if(nrf_rx_buffer[22]!=0) setDuty5 = maxDuty; else setDuty5 = 0; // Set Duty6 if(nrf_rx_buffer[23]!=0) setDuty6 = maxDuty; else setDuty6 = 0; // Set Duty7 if(nrf_rx_buffer[24]!=0) setDuty7 = maxDuty; else setDuty7 = 0; // Set Duty8 if(nrf_rx_buffer[25]!=0) setDuty8 = maxDuty; else setDuty8 = 0; // Set Duty9 SVTH: TRẦN ĐĂNG KHÔI 147 an GVHD: TS NGUYỄN VĂN THÁI if(nrf_rx_buffer[26]!=0) setDuty9 = maxDuty; else setDuty9 = 0; // Set Duty10 if(nrf_rx_buffer[27]!=0) setDuty10 = maxDuty; else setDuty10 = 0; // Set Duty11 if(nrf_rx_buffer[28]!=0) setDuty11 = maxDuty; else setDuty11 = 0; // Set Duty12 if(nrf_rx_buffer[29]!=0) setDuty12 = maxDuty; else setDuty12 = 0; } void EN1(uint8_t _state) { if(_state) AFIO_state &=~EN1_ON; else AFIO_state |= EN1_ON; shiftOut595(AFIO_state); } void EN2(uint8_t _state) { if(_state) AFIO_state &=~EN2_ON; else AFIO_state |= EN2_ON; shiftOut595(AFIO_state); } void FAN1(uint8_t _state) { if(_state) AFIO_state |= FAN1_ON; else AFIO_state &=~FAN1_ON; shiftOut595(AFIO_state); } void FAN2(uint8_t _state) { SVTH: TRẦN ĐĂNG KHÔI 148 an GVHD: TS NGUYỄN VĂN THÁI if(_state) AFIO_state |= FAN2_ON; else AFIO_state &=~FAN2_ON; shiftOut595(AFIO_state); } void DL1(uint8_t _state) { if(_state) AFIO_state |= DL1_ON; else AFIO_state &=~DL1_ON; shiftOut595(AFIO_state); } void DL2(uint8_t _state) { if(_state) AFIO_state |= DL2_ON; else AFIO_state &=~DL2_ON; shiftOut595(AFIO_state); } void DL3(uint8_t _state) { if(_state) AFIO_state |= DL3_ON; else AFIO_state &=~DL3_ON; shiftOut595(AFIO_state); } void DL4(uint8_t _state) { if(_state) AFIO_state |= DL4_ON; else AFIO_state &=~DL4_ON; shiftOut595(AFIO_state); } void shiftOut595(uint8_t _ds) { for(int i = 0; i < 8; i++) { if((_ds&0x01) == 0x01) HAL_GPIO_WritePin(DS595_GPIO_Port,DS595_Pin,GPIO_PIN_SET); else HAL_GPIO_WritePin(DS595_GPIO_Port,DS595_Pin,GPIO_PIN_RESET); SVTH: TRẦN ĐĂNG KHÔI 149 an GVHD: TS NGUYỄN VĂN THÁI HAL_GPIO_WritePin(SCK595_GPIO_Port,SCK595_Pin,GPIO_PIN_SET); HAL_GPIO_WritePin(SCK595_GPIO_Port,SCK595_Pin,GPIO_PIN_RESET); _ds >>= 1; } HAL_GPIO_WritePin(RCK595_GPIO_Port,RCK595_Pin,GPIO_PIN_SET); HAL_GPIO_WritePin(RCK595_GPIO_Port,RCK595_Pin,GPIO_PIN_RESET); } void dutyControl(void) { //duty1 control if(duty1 != setDuty1) { if(timer1_Check(&timer1_ms,&timer1_previousDuty1,30)) { if(duty1 > setDuty1) duty1 ; else duty1++; PWM1_Duty = duty1; timer1_previousDuty1 = timer1_ms; } } //duty2 control if(duty2 != setDuty2) { if(timer1_Check(&timer1_ms,&timer1_previousDuty2,30)) { if(duty2 > setDuty2) duty2 ; else duty2++; PWM2_Duty = duty2; timer1_previousDuty2 = timer1_ms; } } //duty3 control if(duty3 != setDuty3) { if(timer1_Check(&timer1_ms,&timer1_previousDuty3,30)) { if(duty3 > setDuty3) duty3 ; else duty3++; PWM3_Duty = duty3; SVTH: TRẦN ĐĂNG KHÔI 150 an GVHD: TS NGUYỄN VĂN THÁI timer1_previousDuty3 = timer1_ms; } } //duty4 control if(duty4 != setDuty4) { if(timer1_Check(&timer1_ms,&timer1_previousDuty4,30)) { if(duty4 > setDuty4) duty4 ; else duty4++; PWM4_Duty = duty4; timer1_previousDuty4 = timer1_ms; } } //duty5 control if(duty5 != setDuty5) { if(timer1_Check(&timer1_ms,&timer1_previousDuty5,30)) { if(duty5 > setDuty5) duty5 ; else duty5++; PWM5_Duty = duty5; timer1_previousDuty5 = timer1_ms; } } //duty6 control if(duty6 != setDuty6) { if(timer1_Check(&timer1_ms,&timer1_previousDuty6,30)) { if(duty6 > setDuty6) duty6 ; else duty6++; PWM6_Duty = duty6; timer1_previousDuty6 = timer1_ms; } } //duty7 control if(duty7 != setDuty7) { if(timer1_Check(&timer1_ms,&timer1_previousDuty7,30)) { SVTH: TRẦN ĐĂNG KHÔI 151 an GVHD: TS NGUYỄN VĂN THÁI if(duty7 > setDuty7) duty7 ; else duty7++; PWM7_Duty = duty7; timer1_previousDuty7 = timer1_ms; } } //duty8 control if(duty8 != setDuty8) { if(timer1_Check(&timer1_ms,&timer1_previousDuty8,30)) { if(duty8 > setDuty8) duty8 ; else duty8++; PWM8_Duty = duty8; timer1_previousDuty8 = timer1_ms; } } //duty9 control if(duty9 != setDuty9) { if(timer1_Check(&timer1_ms,&timer1_previousDuty9,30)) { if(duty9 > setDuty9) duty9 ; else duty9++; PWM9_Duty = duty9; timer1_previousDuty9 = timer1_ms; } } //duty10 control if(duty10 != setDuty10) { if(timer1_Check(&timer1_ms,&timer1_previousDuty10,30)) { if(duty10 > setDuty10) duty10 ; else duty10++; PWM10_Duty = duty10; timer1_previousDuty10 = timer1_ms; } } SVTH: TRẦN ĐĂNG KHÔI 152 an GVHD: TS NGUYỄN VĂN THÁI //duty11 control if(duty11 != setDuty11) { if(timer1_Check(&timer1_ms,&timer1_previousDuty11,30)) { if(duty11 > setDuty11) duty11 ; else duty11++; PWM11_Duty = duty11; timer1_previousDuty11 = timer1_ms; } } //duty12 control if(duty12 != setDuty12) { if(timer1_Check(&timer1_ms,&timer1_previousDuty12,30)) { if(duty12 > setDuty12) duty12 ; else duty12++; PWM12_Duty = duty12; timer1_previousDuty12 = timer1_ms; } } } /* USER CODE END */ /** * @brief This function is executed in case of error occurrence * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred * @param file: pointer to the source file name * @param line: assert_param error line source number SVTH: TRẦN ĐĂNG KHÔI 153 an GVHD: TS NGUYỄN VĂN THÁI * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN */ /* User can add his own implementation to report the file name and line number, tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END */ } #endif /* USE_FULL_ASSERT */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ SVTH: TRẦN ĐĂNG KHÔI 154 an S an K L 0 ... IoTs điều khiển giám sát vườn rau/ quả nông nghiệp, giao tiếp sóng RF sử dụng NRF24L01x để xây dựng thiết bị từ Sensors đến Gateway sử dụng IC NRF24L01x với mục tiêu, xác, sử dụng hiệu lượng (nguồn... IC thu phát sóng RF NRF24L01+ Để thiết kế hệ thống vô tuyến sử dụng IC NRF24L01x đơn giản, cần MCU điều khiển vài linh kiện thụ động vận hành được, điều giúp cho hệ thống sử dụng NRF24L01x trở... nghiên cứu, thiết kế hệ thống điều khiển, giám sát, ứng dụng công nghệ IoT phục vụ nông nghiệp, giao tiếp với thông qua chuẩn truyền liệu khơng dây dùng sóng RF tảng sử dụng IC NRF24L01x+ hãng

Ngày đăng: 02/02/2023, 09:25

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

Tài liệu liên quan