How to Interface RS485 Module with STM32

  Рет қаралды 44,035

ControllersTech

ControllersTech

Жыл бұрын

Purchase the Products shown in this video from :: controllerstech.store
________________________________________________________________________________________
Check out the Modbus Playlist :::: • MODBUS STM32
STM32 Playlist :::: • STM32 Tutorials
UART IDLE Line Reception :::: • STM32 UART DMA and IDL...
To download the code, goto :::: controllerstech.com/rs485-mod...
________________________________________________________________________________________
****** SUPPORT US BY DONATING*****
paypal.me/controllertech
******Join the Membership******
/ @controllerstech
Join the Discord Server / discord
Join the Telegram Group t.me/controllerstechdiscuss
Follow me on Instagram / controllerstech
For more info, visit www.controllerstech.com

Пікірлер: 43
@chrisidema
@chrisidema Жыл бұрын
I have a few tips about RS485 with STM32: 1) use a bias network in addition to the termination resistor. You can look up "RS485 bias". Even if the RS485 line drivers have a "safe mode" they can still experience glitches on the receiver with the first byte. Especially if you don't share a GND. So you may miss or corrupt the first byte! 2) STM32 UART RX doesn't have a hardware buffer. Receiving using interrupt is often too slow and you can miss data. Only DMA receiving works properly IMHO. 3) You can use circular DMA for UART if you don't want to lose any data, but for RS485 this is not really needed. In fact it is best to clear any UART buffer after sending in case data ends up in your RX buffer. 4) Note that when a glitch occurs an RX error will automatically halt DMA reception and you have to manually re-enable it. So enable the appropriate error interrupts (UART and/or DMA) and handle the errors appropriately or you may wait forever for data (though that only applies to an RS485 slave). 5) Add short delays between switching Drive Enable and data transmission (before and after transmission). This makes communication more reliable. 6) Enable Idle line detection interrupt. This is very useful in case you don't know how many bytes you are expecting. You receive an interrupt after receiving the last byte of a message. 7) If you want to use very high Baud rates check the datasheet of your line drivers. They come in different speeds/slope limits. 8) With any UART communication always verify your baudrate. With low clock frequencies you may not be able to get the exact baudrates you want due to rounding errors. Internal oscillators also have limited accuracy. It may work until it doesn't... 9) When you want to connect it to the PC use the FT232R USB serial converter. It has a TXen pin that switches while it is sending. You can connect this pin to the RS485 DE pin. The alternative is to use the DTR or RTS pin, but this can switch too slow as Windows is not real time. Cheap USB-RS485 converters often use DTR and are not always reliable. So check the schematic before buying one.
@KWang_12
@KWang_12 Жыл бұрын
My favorite MLG voice tech channel
@aflimohamed6448
@aflimohamed6448 Ай бұрын
great explaination
@abagnale7058
@abagnale7058 Жыл бұрын
The lecture was awesome. Can you make an RS-485 BUS for two stm32 microcontroller circuits?
@yudhahamdiarzi5553
@yudhahamdiarzi5553 Жыл бұрын
Great explanation. I use different module with auto logic for receive and transmit,so it's only need 2 pins. If possible i need knowledge about CAN J1939 and OBD2 :D
@avr_stm_pro2955
@avr_stm_pro2955 Жыл бұрын
Спасибо 👍
@YAKITEMiguel
@YAKITEMiguel 6 күн бұрын
Hello, i want to interface a SmartEmbedded screen with an toshiba inverter and read out the inverter frequency on the screen by using RS485 wire with Stm32cubeIde, I would like to know if it´s possible ?
@DwinTechnologyOfficial
@DwinTechnologyOfficial Жыл бұрын
We have ASIC display chip, is it possible for you to try it?
@SamSmartLabs
@SamSmartLabs 6 ай бұрын
I got random data and I’m not able to establish communication it seems , I’m using 2 stm32f103 and the rs485 transceiver is MAX485
@kinomaniak123
@kinomaniak123 Жыл бұрын
Hi, great tutorial. I have one question - what voltage are You using to power the modules? If the voltage is 5V - do You need any voltage converter for data lines Rx/Tx?
@ControllersTech
@ControllersTech Жыл бұрын
The voltage is 5V. The MAX485 chip takes care of thr conversion so we don't need any voltage converters.
@kinomaniak123
@kinomaniak123 Жыл бұрын
@@ControllersTech Thank You for reply.
@ThinhLe-ut9pr
@ThinhLe-ut9pr Жыл бұрын
hello, thanks for a great explaination, but I have a question. Could we connect the RO and DI pin of the MAX485 chip to RX and TX pin of USART2 instead of USART1 (on STM32L152RE)? because I had a project at school, we implemented the MODBUS RTU protocol, at first we used USART2 for debugging purpose, but after that we had to change to USART1 to deal with RS485 to USB converter, and I didn't know the reason why we had to change.
@ControllersTech
@ControllersTech Жыл бұрын
You are using a nucleo board i guess. You tested it using the uart2 because in nucleo boards uart2 pins are shorted to be used as the vcp (virtual com port), so you don't need to connect an external hardware for uart, just the usb cable is enough. Now you want to use the rs485. This is why you used uart1, as the uart2 pin are being used as vcp and are not avaialble seperately. You can use any uart other than uart2. But if you insist on using uart2, then you need to see the schematics of the board and modify the hardware a little so that the pins are avaialble for external connection.
@ThinhLe-ut9pr
@ThinhLe-ut9pr Жыл бұрын
@@ControllersTechThank you very much, that is very helpful!
@koteswararaopokuri2301
@koteswararaopokuri2301 Жыл бұрын
Please make a video on stm32f4 with c11101rf transceiver by spi communication
@BB-ti9bf
@BB-ti9bf Жыл бұрын
Use CMSIS without HAL for deep understanding how it works, then you no need ask anyone make something to do it for you, it is freedom of creativity ☝️
@minecetinkaya5763
@minecetinkaya5763 Жыл бұрын
how to use 2 uarts 2 modules with one stm. I tried to combine codes but It does not work properly
@vincenttsai5116
@vincenttsai5116 11 ай бұрын
I have the same question, use uart1 transits, uart 2 receive, but it can't work.
@minecetinkaya5763
@minecetinkaya5763 11 ай бұрын
​ @vincenttsai5116 It sould be. I use 4 modules now. Which one does not work. Did you try only receive and only transmit in while. If there is no data, maybe these tips help; 1) check your enable pins and their connections. Be sure that you are using enable pins correctly. 2) you should connect N to N and P to P. 2) I'm offering you to use callback functions​ in normal mode. 3) if you have logic analyzor try to observe is stm send any data.
@Rynxie
@Rynxie 7 ай бұрын
i want to make the communicate 2 stm32f103c8t6 stand-alone with no computer connection if it is possible that I give power both stms from same source and to max485s from stms 5v pn?
@ControllersTech
@ControllersTech 7 ай бұрын
Yes it's fine.
@Rynxie
@Rynxie 7 ай бұрын
@@ControllersTech thank you! I am new to electronics :p
@phanendrabeella
@phanendrabeella Жыл бұрын
i need code for reccieve interface of rs 485 in interrupt method
@ControllersTech
@ControllersTech Жыл бұрын
This video basically describes the RS485 to uart converter. If you are using this, then you can simply use the uart interrupt to receive the data.
@woldecosgrove
@woldecosgrove 9 күн бұрын
Hello great video ! i try your code on 2 H7A3 Nucleo, the TX board is working, but Rx board is not! is there any additional setting at IDE configuration that you miss out in the video? i dun understand the RxData[16] appear all 0 at Live Expression ! can you advise...
@woldecosgrove
@woldecosgrove 8 күн бұрын
Hello... can u reply ...
@ControllersTech
@ControllersTech 8 күн бұрын
Nothing extra is needed. Make sure both RS485 has common ground. If it doesn't work, first check if simple uart transmission is working fine.
@woldecosgrove
@woldecosgrove 8 күн бұрын
@@ControllersTech Hello... i use same power supply to the 2 RS485 board, the power supply for the 2 H7A3 comes from 2 USB port is the fine? Tx board is able to transmit F103 to live experssion, but Rx board does not show any (RxData all 0s) UART transmission is working...
@ControllersTech
@ControllersTech 8 күн бұрын
If the simple uart is not working, theb RS485 won't work. You should look into that first. Also the tx buffer in live expression does not signify that transmission is working. The buffer simply changes because you are updating it in the code. You should use a logic analyzer or an oscilloscope to confirm if transmission is working. If you are using a nucleo board, do not use uart2, as it is connected to the st link. You should connect each board to the computer individually and check if uart tx and rx is working.
@woldecosgrove
@woldecosgrove 8 күн бұрын
@@ControllersTech Hello... i m using UART1 for both boards, power from USB port 1 and port 2, both the RS485 powered from external power bank. How should the common ground be wired? When i scope the Tx node A and B show correct waveform BUT 0.5v amplitude whats happed?
@seimela
@seimela Жыл бұрын
What is the link to this software Q ide ,please share the link
@ControllersTech
@ControllersTech Жыл бұрын
It's cube IDE..
@seimela
@seimela Жыл бұрын
@@ControllersTech Thanks got it ,this video got me to subscribe to your channel
@ahmedrefaie8671
@ahmedrefaie8671 Жыл бұрын
Please make a video to explain how to connect my computer stm32 via RS485
@ControllersTech
@ControllersTech Жыл бұрын
Buy a RS485 to USB converter
@ahmedrefaie8671
@ahmedrefaie8671 Жыл бұрын
Please is it possible to protect the code from theft?
@ControllersTech
@ControllersTech Жыл бұрын
If you are talking about STM32, then yes it does. It have the methods to protect agains read and write operations. It depneds on the mcu you are using. It can be configured using the option bytes in the cube programmer.
@user-ox1gn4is1j
@user-ox1gn4is1j 3 ай бұрын
Speed 😂
@user-ox1gn4is1j
@user-ox1gn4is1j 3 ай бұрын
You cant teach to much speed 😂
@kaihorstmann2783
@kaihorstmann2783 Жыл бұрын
I think your explanation of voltage levels is plain wrong. This is a differential pair. Logic '1' is when A is low and B is high, and for '0' A is high, and B is low. Low and High are the same voltage levels for both lines. There is always a positive or negative difference between the two lines. A voltage difference of 0V as you showed is actually an undefined logical state and must be avoided. The absolute voltage level of the lines compared to ground is irrelevant as long as the limits are not exceeded. The signal is defined by the voltage difference between the two lines.
FDCAN in STM32 || Normal Mode || Message RAM Configuration
19:24
ControllersTech
Рет қаралды 12 М.
#Modbus 1. STM32 as Master || Read Holding and Input Registers
25:07
ControllersTech
Рет қаралды 36 М.
I CAN’T BELIEVE I LOST 😱
00:46
Topper Guild
Рет қаралды 103 МЛН
Каха и суп
00:39
К-Media
Рет қаралды 2,7 МЛН
Who has won ?? 😀 #shortvideo #lizzyisaeva
00:24
Lizzy Isaeva
Рет қаралды 25 МЛН
RS485 и микроконтроллер
10:30
Александр Писанец
Рет қаралды 115 М.
UART To RS-485 Interface  / Pro Mini / LoRa Interface
9:51
0033mer
Рет қаралды 55 М.
What is RS-485?
11:10
Texas Instruments
Рет қаралды 45 М.
SparkFun According to Pete #54 - How RS-485 Works
14:31
SparkFun Electronics
Рет қаралды 61 М.
CAN Protocol Explained | Controller Area Network
12:09
The EV Engineer
Рет қаралды 67 М.
01- What is Modbus ? And detail of Modbus RS485 RTU Communication?
23:22
CAN vs. RS-485: What's the Difference?
8:52
maxim integrated
Рет қаралды 42 М.
Hacker's Guide to UART Root Shells
17:40
Flashback Team
Рет қаралды 467 М.
Здесь упор в процессор
18:02
Рома, Просто Рома
Рет қаралды 200 М.
WATERPROOF RATED IP-69🌧️#oppo #oppof27pro#oppoindia
0:10
Fivestar Mobile
Рет қаралды 17 МЛН
ИГРОВОВЫЙ НОУТ ASUS ЗА 57 тысяч
25:33
Ремонтяш
Рет қаралды 346 М.
Опыт использования Мини ПК от TECNO
1:00
Андронет
Рет қаралды 739 М.
Hisense Official Flagship Store Hisense is the champion What is going on?
0:11
Special Effects Funny 44
Рет қаралды 2,9 МЛН