How to use the 485 communication protocol (a typical circuit example of traditional opto-isolation)

The RS485 bus standard is a widely used, two-way, balanced transmission interface in industrial applications such as attendance systems, monitoring, and data acquisition. It supports multi-point connections and can create a network of up to 3 nodes. With a maximum transmission distance of 1200 meters, it operates at high speeds of up to 100kb/s. Its strong anti-interference capability and simple wiring—using only two lines—make it a popular choice. The RS485 communication network is based on a bus structure, where both the upper computer (such as a personal computer) and the lower devices are connected to the same communication bus. The physical layer protocol of RS485 follows a multi-machine communication mode commonly used with PLCs. A traditional optoelectronic isolation circuit is often used for signal isolation in RS485 systems. In this setup, VDD and +5V1 (VCC485) are separate power supplies, typically isolated using DC-DC converters. Signal isolation is achieved through an optocoupler, ensuring that the ISL3152EIBZ and the MCU system remain electrically isolated. This isolation effectively suppresses common-mode voltage and reduces the risk of damage to the 485 transceiver, improving overall system stability. However, traditional opto-isolation circuits tend to be large, complex, and require many discrete components, which can limit transmission speed and affect system reliability. To configure the serial port and 485 control pin on an STM32 microcontroller: - The RXD1 pin is set as an input because it receives external data. - The TXD1 pin is set as an output since it sends data externally. - The TRE1 pin controls the direction of the 485 transceiver, sending a high or low signal, and is also set as an output. Here's an example of initializing UART2 and the 485 control pins: ```c void UART2Init(void) { GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC, ENABLE); // Configure 485 control pin (PA1) GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); // Configure 485 TX pin (PA2) GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); // Configure 485 RX pin (PA3) GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); // Set up USART2 USART_InitStructure.USART_BaudRate = 9600; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx; USART_Init(USART2, &USART_InitStructure); USART_Cmd(USART2, ENABLE); } ``` When sending data, it's important to handle the first byte correctly. If not done properly, the first byte may not be transmitted. Two methods can be used to ensure correct transmission: 1. `USART_ClearFlag(USART3, USART_FLAG_TC);` – Clears the transmit complete flag. 2. `USART_GetITStatus(USART1, USART_FLAG_TC);` – Checks the status of the transmit complete flag. If the first byte is garbled upon power-up, it could be due to checking the wrong flag. The `USART_FLAG_TXE` checks if the transmit data register is empty, but the shift register may still be transmitting. Using `USART_FLAG_TC` ensures the data has been fully sent before writing new data. In interrupt-based transmission, the process involves setting the RS485 direction to send, enabling the transmit register empty interrupt, and then filling the data register. After each transmission, the next byte is sent until all data is transmitted. Finally, the flags are cleared, and the direction is switched back to receive. Here’s an example function to send a string via RS485: ```c #define RX_485 GPIO_SetBits(GPIOA, GPIO_Pin_1); #define TX_485 GPIO_ResetBits(GPIOA, GPIO_Pin_1); void UART2_TX485_Puts(char *str) { while (*str) { TX_485; // Switch to transmit mode DelayNmS(1); USART_SendData(USART2, *str++); while (USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET); // Wait for transmit buffer to be empty DelayNmS(1); RX_485; // Switch back to receive mode } } ``` When working with RS485 chips, it's crucial to carefully program the DE control pin. To ensure reliable operation, appropriate delays should be added when switching between transmit and receive modes. For example, after setting the DE pin to '1', wait about 1ms before sending data. After the last byte is sent, delay another 1ms before switching back to '0'. This ensures a stable transition between states and improves the overall reliability of the communication.

3000W AC Power Supply

APM SP300VAC3000W is an economically programmable DC and AC output power supply to provide reliable voltage and simulation for general applications such as testing for commercial, power electronics, avionics, military and IEC regulation test applications. The AC power source has various communication interface and can be remote controlled by computer.

The AC source is capable of delivering up to 6 times of peak current compared to its maximum rated current that makes it ideal for inrush current test.

Some features as below:


  • 5.6"large touch color screen
  • AC+DC mixed or independent output mode
  • Capable of setting output slope/phase angle
  • Built-in IEC standard test function
  • Built-in multiple protections
  • Built-in power meter
  • Support impedance function
  • Support for LIST/PULSE/STEP mode & Transient mode
  • Standard RS232/RS485/USB/LAN, Optional GPIB/multiphase card.
  • Support master and slave parallel mode to realize power extension
  • Support harmonics/inter-harmonics simulation and measuring function
  • Support for USB data import/export and scree nap from front panel
  • PWM technologies, with up to 86% efficiency
  • CE, CSA, UL, ROHS Certified


3000W AC Power Supply,Programmable AC Power Supply,Adjustable Ac Dc Power Supply,3000W Switching Power Supply

APM Technologies Ltd , https://www.apmpowersupply.com