2024-04-19 02:40 PM - edited 2024-04-19 02:40 PM
Hi,
I am unable to interface with a sensor over RS485. I have a uart->RS485 converter hooked up to pins for USART1 (Tx on PD8, Rx on PD9) on a Nucleo-F439ZI.
I also have a USBtoRS485 converter with which i'm able to communicate to the sensor fine. I have a scope connected onto the B- line and can compare the data.
The sensor prescribes the following UART settings:
and I have set USART1 t initialize with the following settings:
huart1.Instance = USART1;
huart1.Init.BaudRate = 57600;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_EVEN;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
An image looks as can be seen in the attached scope3.jpg picture where RefA (grey) is the recorded (working) signal from the USBtoRS485 converter and CH1 (yellow) is the signal from the Nucleo board.
I think from thevery beginning of the traces one can see that the bit timing appears to align but weird enough, the second falling edge from the left appears to have a one bit offset. I am sending 5 Bytes, 3 payload Bytes and aCRC16 checksum (per Modbus RTU).
Byte 1 should be the slave address(1)
Byte 2 should be the function ID (4 = read from input register)
Byte 3 should be the register number to read from which in this case ought to be 200.
But to me it appears like something with the stop bit or the parity might be off :-1:
Solved! Go to Solution.
2024-04-26 09:54 PM
The problem was resolved by setting the word length to 9 bit (because ST apparently counts the parity bit to the actual word size, the sensor I worked with didn't & indicated data bits 8)
2024-04-20 06:19 AM
Hello,
An image looks as can be seen in the attached scope3.jpg picture where RefA (grey) is the recorded (working) signal from the USBtoRS485 converter and CH1 (yellow) is the signal from the Nucleo board.
No image is attached.
Also you tagged FreeRTOS in the thread. You need also to confirm if you're using RTOS.
2024-04-26 09:54 PM
The problem was resolved by setting the word length to 9 bit (because ST apparently counts the parity bit to the actual word size, the sensor I worked with didn't & indicated data bits 8)