Skip to main content
Associate II
October 4, 2024
Question

RS485 non standard data word

  • October 4, 2024
  • 15 replies
  • 6765 views

Hi,

uc: stm32f446

 

I have a question regarding non standard word length over RS485.

I need to receive next frame over RS485

tasifacij_0-1728024568708.png

1 start bit, 16-bit data word, 2 stop bits, in total 19 bits.

UART implementation allows to receive 8 or 9-bit data words.

Could you please advice what can be an approcach to achieve?

 

Best regards, Taras.

 

This topic has been closed for replies.

15 replies

waclawek.jan
Super User
October 4, 2024

You can't receive this using the native UART in 'F4, so you need to resort to bit-banging, possibly using timer interrupts.

JW

Andrew Neil
Super User
October 4, 2024

As @waclawek.jan said, you're going to have to bit-bang this.

You might start by looking at AN4457, Implementing an emulated UART on STM32F4 microcontrollers:

https://www.st.com/resource/en/application_note/an4457-implementing-an-emulated-uart-on-stm32f4-microcontrollers-stmicroelectronics.pdf

and adjust its number of data bits.

 

It might be possible to synthesise something using the SPI peripheral, but it would rely on being able to accurately control the timing between 2 transfers ...

EDIT: the QSPI can do 32-bit transfers ...

 


@tasifacij wrote:

I need to receive next frame over RS485

tasifacij_0-1728024568708.png


Presumably, this is determined by some 3rd-party equipment you're having to communicate with?

Have you tried contacting the manufacturer of that equipment - do they have any suggestions?

Have you tried searching to see how others have communicated with that thing?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
tasifacijAuthor
Associate II
October 6, 2024

>>>Presumably, this is determined by some 3rd-party equipment you're having to communicate with?

>>>Have you tried contacting the manufacturer of that equipment - do they have any suggestions?

You are quite right, this is 3rd party with proprietary proto. 

 

>>>Have you tried searching to see how others have communicated with that thing?

Not much luck.

I will try your suggestion. I appreciate the answer.

Andrew Neil
Super User
October 7, 2024

@tasifacij wrote:

this is 3rd party with proprietary proto. 


Can you give us a name? Or other details?

Maybe someone here has done it, or heard of it ...

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
tasifacijAuthor
Associate II
October 10, 2024

Hi, @Andrew Neil , @waclawek.jan ,

appreciate your suggestions, they pushed me toward the solution.

Actually, I  solved the problem with IC( falling + rising edges ) + DMA. DMA catches CCR2.

ClockFreq=84Mhz

BitRate=2.73Nhz

X = ClockFreq / BitRate gives me [ticks/bit]

 

And I see the difference in clock ticks between every falling  and rising edge.

tasifacij_0-1728582516207.png

where c0 - first falling edge, stop bit started

c1 - rising edge, c2 falling edge

(c2 - c1) / X  gives me the number of bits I can set equal to 1.

And of course (c1 - c0) + ( c2 - c1 ) is length of the parcel.

Associate III
October 11, 2024

There is something wrong with your system architecture. The real product does not do this. You should add a 485 chip connected to the UATR of the CPU.

Andrew Neil
Super User
October 11, 2024

@zhaowhong wrote:

 The real product does not do this. .


So what does it do ?

Do you have a link?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
waclawek.jan
Super User
October 11, 2024

There may be some asymmetry in measured duration of "high" and "low" level due to the edges not being perfectly sharp and the decision level not being exactly at the middle of the edge.

Is that a fatal problem in decoding? Post some concrete values.

JW

tasifacijAuthor
Associate II
October 14, 2024

I had a uart with non-standard word length( 16 bits ). This is all it does.

Andrew Neil
Super User
October 14, 2024

Sorry, it was @zhaowhong who said,  "The real product does not do this"

 

But can't you give any more detail of what you do have than just, "Fanuc encoder"?

A part number? A link to a datasheet or Product Page? Anything??

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.