Cov txheej txheem:
- Kauj Ruam 1: Kev Xav Tau Software thiab Kho Vajtse
- Kauj ruam 2: STM32CubeMX Configuration
- Kauj Ruam 3: Keil Kev Txhim Kho Software
- Kauj ruam 4: Python Software Development
- Kauj Ruam 5: Xaus
Video: STM32F4 Discovery Board thiab Python USART Kev Sib Txuas Lus (STM32CubeMx): 5 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:27
Nyob zoo! Hauv qhov kev qhia no peb yuav sim tsim USART kev sib txuas lus ntawm STM32F4 ARM MCU thiab Python (nws tuaj yeem hloov los ntawm lwm yam lus). Yog li, cia peb pib:)
Kauj Ruam 1: Kev Xav Tau Software thiab Kho Vajtse
Hais txog kho vajtse koj xav tau:
- STM32F4 Discovery Board (lossis lwm yam STM32 board)
- Konvertiere USB in TXL
Hais txog software:
- STM32CubeMX
- Keil uVision 5
- Nab hab sej nrog cov tsev qiv ntawv txuas
Kauj ruam 2: STM32CubeMX Configuration
Ua ntej cia peb nkag siab tias peb xav ua dab tsi. Peb xav xa cov ntaub ntawv mus rau pawg thawj coj ntawm Python hla USART thiab tshawb xyuas yog tias peb muaj cov ntaub ntawv raug thiab hloov pauv coj. Yog li, peb xav tau kev pab USART thiab Led.
-
Pab kom USART2 los ntawm Kev Sib Txuas tab.
- Hloov hom rau Asynchoronous
- Baud tus nqi mus rau 9600 Bit/s
- Lo lus ntev txog 8 Khoom yam tsis muaj qhov sib npaug
- Tsis muaj parity me ntsis
- Los ntawm DMA teeb tsa ntxiv USART2_RX hauv hom cicular
- Los ntawm NVIC Chaw pab kom USART2 cuam tshuam thoob ntiaj teb
- Pab kom LED los ntawm txhaj rau PD12
Tom qab ntawd tsim cov cai:)
Kauj Ruam 3: Keil Kev Txhim Kho Software
#suav nrog
#suav nrog
Cov tsev qiv ntawv no yuav xav tau hauv txoj haujlwm ua haujlwm thiab txhawm rau txheeb xyuas qhov sib txawv boolean.
/ *USER CODE BEGIN 2 */ HAL_UART_Receive_DMA (& huart2, (uint8_t *) data_buffer, 1); / * USER CODE KAWG 2 */
Ntawm no, UART tau txais nrog DMA pib.
/ *USER CODE BEGIN 4 */void HAL_UART_RxCpltCallback (UART_HandleTypeDef *huart) {/ *Tiv thaiv kom tsis txhob siv cov lus sib cav (s) sau ua ke ceeb toom */UNUSED (huart); / * NCO TSEG: Qhov haujlwm no yuav tsum tsis raug hloov kho, thaum xav tau kev hu rov qab, HAL_UART_RxCpltCallback tuaj yeem ua tiav hauv tus neeg siv cov ntaub ntawv */ yog (data_buffer [0]! = '\ N') {data_full [index_] = data_buffer [0]; index _ ++; } lwm {index_ = 0; tiav = 1; } // HAL_UART_Transmit (& huart2, data_buffer, 1, 10); } / * USER CODE KAWG 4 * /
Qhov no yog ISR uas tau qhib thaum peb tau txais ib byte ntawm tus ua cim. Yog li peb tau txais cov byte thiab sau nws mus rau data_full uas muaj cov ntaub ntawv tau txais tag nrho kom txog thaum peb tau txais '\ n'. Thaum peb tau txais '\ n' peb ua tiav tus chij 1 thiab thaum lub voj:
thaum (1) { / * USER CODE END WHILE * / yog (ua tiav) {yog (strcmp (data_full, cmp_) == 0) {HAL_GPIO_TogglePin (GPIOD, GPIO_PIN_12); } memset (data_full, '\ 0', strlen (data_full)); tiav = 0; } lwm {_NOP (); } / * USER CODE BEGIN 3 * /}
Yog ua tiav tus chij yog HIGH peb sib piv cov ntsiab lus ntawm cov ntaub ntawv tau txais thiab cov ntaub ntawv peb xav tau thiab yog tias lawv sib npaug peb toggle coj. Tom qab ntawd peb tshem tawm tus chij tiav thiab tos rau cov ntaub ntawv tshiab thiab tseem tshem tawm cov ntaub ntawv tagful kom tsis txhob rov sau dua rau kab lus.
Kauj ruam 4: Python Software Development
Yog li, ntawm no peb xav xa peb tus lej nrog '/n' thaum kawg, vim Keil software yuav xav pom nws txhawm rau paub qhov kawg.
ntshuam ntshuam
ser = serial. Serial ('COM17') #khij qhov chaw nres nkoj ntawm koj lub cuab yeej los ntawm Device Manager
ser.write (b'24 / n ')
Koj yuav tsum pom tias LED toggles txhua lub sijhawm koj xa '24 / n '. Yog tias koj xa lwm yam ntxiv nws yuav tsum tsis cuam tshuam rau nws.
Kauj Ruam 5: Xaus
Peb tau mus txog qhov kawg ntawm kev qhia. yog tias koj muaj teeb meem lossis lus nug thov tsis txhob ua siab deb nug. Kuv yuav sim pab ntau npaum li kuv ua tau. Ua tsaug ntau ntau:)
Pom zoo:
Yuav Ntsuas Li Cas Ntsuas Kev Siv Lub Hwj Chim ntawm Kev Sib Txuas Lus Wireless hauv Era ntawm Kev Siv Hluav Taws Xob?: 6 Cov Kauj Ruam
Yuav Ua Li Cas Ntsuas Kom Tau Txais Kev Siv Lub Hwj Huam ntawm Kev Sib Txuas Lus Wireless hauv Era ntawm Kev Siv Hluav Taws Xob? Feem ntau IoT nodes yuav tsum tau siv lub roj teeb. Tsuas yog los ntawm kev ntsuas ntsuas lub zog siv ntawm lub wireless wireless peb tuaj yeem kwv yees kwv yees ntau npaum li cas roj teeb kuv
Arduino Neeg Hlau Nrog Kev Nyob, Kev Qhia thiab Qib Kev Sib Hloov (Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) Tswj los ntawm Lub Suab Siv Bluetooth Module thiab Kev Siv Tus Neeg Siv Hluav Taws Xob: 6 Kauj Ruam
Arduino Neeg Hlau Nrog Kev Nyob, Kev Qhia thiab Qib Kev Sib Hloov (Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) Tswj los ntawm Lub Suab Siv Bluetooth Module thiab Kev Siv Tus Neeg Siv Hluav Taws Xob: Cov lus qhia no piav qhia yuav ua li cas thiaj tsim tau Arduino Robot uas tuaj yeem txav mus raws qhov xav tau (Forward, Backward) , Sab laug, Txoj Cai, Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) xav tau Kev nrug deb hauv Centimeters siv lub suab hais kom ua. Neeg hlau kuj tseem tuaj yeem txav tau tus kheej
Kev Sib Txuas Lus, Kev Ua Haujlwm Hauv Tsev Kawm Ntawv, lossis Cov Hluas Kev Ua Si: 3 Kauj Ruam
Kev Sib Txuas Lus, Kev Ua Haujlwm Hauv Tsev Kawm Ntawv, lossis Cov Hluas Kev Ua Si: Kuv tau siv qhov haujlwm no ntau zaus nrog cov tub ntxhais kawm theem siab. Nws tau ua tiav raws li kev sib tw, nrog ntau pab pawg raws li koj xav tau. Nws ua raws li kev ua si qub ntawm Xov Tooj, qhov uas kab lus tau ntxhi los ntawm ib tus neeg mus rau lwm tus, feem ntau nrog qhov xaus tau teeb
Kev Sib Txuas Txuas Txuas Txuas Siv Bluefruit: 4 Cov Kauj Ruam
Kev Sib Txuas Tsis Sib Txuas Siv Bluefruit: Nov yog cov lus qhia yooj yim los ntawm kauj ruam qhia los hloov koj cov xov hlau nrog bluetooth tsis muaj zog txuas: Nws coj kuv ib pliag los daws qhov no vim tias tsis muaj cov ntaub ntawv hais txog kev ua qhov no nrog bluetooth niaj hnub tsis muaj zog thev naus laus zis raws li Bluefrui
EZ Kev Sib Txuas Txuas Txuas Txuas Ntxiv - Tsis Muaj Tus Kheej! (CSRC-311): 7 Kauj Ruam
EZ Kev Sib Txuas Txuas Txuas Txuas Ntxiv - Tsis Muaj Tus Kheej! (CSRC-311): Tsis ntev dhau los ntawm Azamom.com (thov txim, tam sim no tau muag tawm) Kuv tau hla qhov kev pom zoo zoo ntawm Common Sense RC CSRC-311 tus qauv-siv servos.Noj zoo, Kuv xav hloov qee yam ntawm tsis tu ncua kev sib hloov. Txoj kev kuv tuaj nrog yog yooj yim heev thiab xav tau