K
K
Kalombyr2020-10-17 21:04:01
Algorithms
Kalombyr, 2020-10-17 21:04:01

Is there an encoding algorithm that does not allow 3-6 identical values ​​in a row?

Hello!
The two devices communicate through the com port. Let there be Arduino, because. I test for them.
It is necessary to somehow separate the packet from the packet, provided that distortions are possible in the stream. Of course, checksums, parity, etc.
But now the question arose, how best to separate the "packets" (sequence of bytes)?
So far I put 3 zeros in a row. Ideally, I'm looking for some simple and fast algorithm for encoding / decoding bytes, which would allow me to avoid several consecutive (let's say from 3 to 6) identical fixed values ​​\u200b\u200b(that is, I need to know in advance what to put it as a separator)
I thought just to add one to every third byte, but then the problem is: if the distortion is in it during transmission and it becomes equal to 0.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
dollar, 2020-10-17
@Kalombyr

Checksum (hash) .
If there is distortion, then the chance of not detecting it is one in a million (in fact, even less, although it depends on the bit depth).

A
Alexander Skusnov, 2020-10-18
@AlexSku

1) Manchester coding
2) CAN bus (service bits automatically track errors)

M
mayton2019, 2020-10-18
@mayton2019

Yes, you are doing the right thing. In telegraphy and data transmission, this is the only way to synchronize the transmitter and receiver. Agree with yourself that 3 zeros in a row + 3 ones will be a sync pulse and then the data will go. If there is a failure, then there was a false sync pulse and you have to wait for the next one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question