Forums

Is there such thing as a 4 bit CRC ?

Started by boB February 21, 2021


If I create a 1 byte command that only uses 4 bits for 16 different
functions, and there were NO following bytes (there might be folling
bytes for some CMDs), I was thinking that the lower 4 bits could be
used for error detection.

Could of course just truncate an 8 bit CRC I suppose and place it
there.

Just thought I would ask.  Never thought of only 4 bits before but
sometimes a single byte could be efficient, bandwidth wise.

Thanks
boB


On Sun, 21 Feb 2021 16:10:19 -0700, boB <boB@K7IQ.com> wrote:

> > > >If I create a 1 byte command that only uses 4 bits for 16 different >functions, and there were NO following bytes (there might be folling >bytes for some CMDs), I was thinking that the lower 4 bits could be >used for error detection. > >Could of course just truncate an 8 bit CRC I suppose and place it >there. > >Just thought I would ask. Never thought of only 4 bits before but >sometimes a single byte could be efficient, bandwidth wise. > >Thanks >boB >
Looks like there are some answers on the web. DuH ! Useful experience still welcomed ! boB
On Sun, 21 Feb 2021 16:10:19 -0700, boB <boB@K7IQ.com> wrote:

> > > >If I create a 1 byte command that only uses 4 bits for 16 different >functions, and there were NO following bytes (there might be folling >bytes for some CMDs), I was thinking that the lower 4 bits could be >used for error detection. > >Could of course just truncate an 8 bit CRC I suppose and place it >there. > >Just thought I would ask. Never thought of only 4 bits before but >sometimes a single byte could be efficient, bandwidth wise. > >Thanks >boB >
A simple 16 nibble array would work just fine. Of course. Getting close so I am feeling a bit dumb even asking :)

On Sun, 21 Feb 2021 16:32:58 -0700, boB <boB@K7IQ.com> wrote:

>On Sun, 21 Feb 2021 16:10:19 -0700, boB <boB@K7IQ.com> wrote: > >> >> >> >>If I create a 1 byte command that only uses 4 bits for 16 different >>functions, and there were NO following bytes (there might be folling >>bytes for some CMDs), I was thinking that the lower 4 bits could be >>used for error detection. >> >>Could of course just truncate an 8 bit CRC I suppose and place it >>there. >> >>Just thought I would ask. Never thought of only 4 bits before but >>sometimes a single byte could be efficient, bandwidth wise. >> >>Thanks >>boB >> > > >A simple 16 nibble array would work just fine. Of course. > >Getting close so I am feeling a bit dumb even asking :) >
Looks like x4 + x1 + 1 is used but that won't fit into 4 bottom bits. Maybe what I am really looking for is just a bastardization of the 4 bits I am tryng to hash ? Not sure how smart that table has to be.
On Sun, 21 Feb 2021 16:53:54 -0700, boB <boB@K7IQ.com> wrote:

> > >On Sun, 21 Feb 2021 16:32:58 -0700, boB <boB@K7IQ.com> wrote: > >>On Sun, 21 Feb 2021 16:10:19 -0700, boB <boB@K7IQ.com> wrote: >> >>> >>> >>> >>>If I create a 1 byte command that only uses 4 bits for 16 different >>>functions, and there were NO following bytes (there might be folling >>>bytes for some CMDs), I was thinking that the lower 4 bits could be >>>used for error detection. >>> >>>Could of course just truncate an 8 bit CRC I suppose and place it >>>there. >>> >>>Just thought I would ask. Never thought of only 4 bits before but >>>sometimes a single byte could be efficient, bandwidth wise. >>> >>>Thanks >>>boB >>> >> >> >>A simple 16 nibble array would work just fine. Of course. >> >>Getting close so I am feeling a bit dumb even asking :) >> > > >Looks like x4 + x1 + 1 is used but that won't fit into 4 bottom >bits. Maybe what I am really looking for is just a bastardization of >the 4 bits I am tryng to hash ? Not sure how smart that table has to >be. > >
Nevermind... I'm just stoopid. Created an array of 15 randome numbers... That should work.
On 2/21/21 6:10 PM, boB wrote:
> > > > If I create a 1 byte command that only uses 4 bits for 16 different > functions, and there were NO following bytes (there might be folling > bytes for some CMDs), I was thinking that the lower 4 bits could be > used for error detection. > > Could of course just truncate an 8 bit CRC I suppose and place it > there. > > Just thought I would ask. Never thought of only 4 bits before but > sometimes a single byte could be efficient, bandwidth wise. > > Thanks > boB > >
IF I am doing my math right 8 bits is good enough for 4 data bits, 3 syndrome bits, and a parity bit to give you 1 bit error correction, 2 bit error detection. That might be better than a 4 bit CRC.
On 2/21/2021 5:14 PM, boB wrote:
> On Sun, 21 Feb 2021 16:53:54 -0700, boB <boB@K7IQ.com> wrote: > >> >> >> On Sun, 21 Feb 2021 16:32:58 -0700, boB <boB@K7IQ.com> wrote: >> >>> On Sun, 21 Feb 2021 16:10:19 -0700, boB <boB@K7IQ.com> wrote: >>> >>>> >>>> >>>> >>>> If I create a 1 byte command that only uses 4 bits for 16 different >>>> functions, and there were NO following bytes (there might be folling >>>> bytes for some CMDs), I was thinking that the lower 4 bits could be >>>> used for error detection. >>>> >>>> Could of course just truncate an 8 bit CRC I suppose and place it >>>> there. >>>> >>>> Just thought I would ask. Never thought of only 4 bits before but >>>> sometimes a single byte could be efficient, bandwidth wise. >>>> >>>> Thanks >>>> boB >>>> >>> >>> >>> A simple 16 nibble array would work just fine. Of course. >>> >>> Getting close so I am feeling a bit dumb even asking :) >>> >> >> >> Looks like x4 + x1 + 1 is used but that won't fit into 4 bottom >> bits. Maybe what I am really looking for is just a bastardization of >> the 4 bits I am tryng to hash ? Not sure how smart that table has to >> be. >> >> > > > Nevermind... I'm just stoopid. > > Created an array of 15 randome numbers... > That should work.
You want the "distance" (i.e., number of bits that must change in order to convert one valid code into another valid -- but, now, INCORRECT -- code to be as long as possible. FOR EVERY POSSIBLE VALID CODE. Once can *detect* N errors in codes if the distance between valid codes is N+1. So, if you have to flip a minimum of 2 bits to be able to convert one code word into another valid (but incorrect) code word, then you can obviously detect any code that has *only* ONE flipped bit. You can *correct* M errors in a code word if the minimum distance between code words is 2M+1. Note that you need to understand the nature of your error sources in order to understand the protection any code will present. If each bit stands an equal chance of flipping -- but, the chance of multiple bits flipping is lessened due to the independence of those events -- then you want a different sort of code than if, for example, one flip *tends* to result in other flips. E.g., if you are sending data down a communication channel and noise can blot out large chunks of the data stream, then your code needs to address the likeliness of multiple bits being affected in the same corruption event. [Google "Hamming Distance"]
On Sun, 21 Feb 2021 16:10:19 -0700, boB <boB@K7IQ.com> wrote:

> > > >If I create a 1 byte command that only uses 4 bits for 16 different >functions, and there were NO following bytes (there might be folling >bytes for some CMDs), I was thinking that the lower 4 bits could be >used for error detection. > >Could of course just truncate an 8 bit CRC I suppose and place it >there. > >Just thought I would ask. Never thought of only 4 bits before but >sometimes a single byte could be efficient, bandwidth wise.
Use some Hamming code, which can correct one bit error and additionally detect odd number of bit errors. Used e.g. in Teletext page numbers, 4 bits of data (actually BCD) in an 8 bit octet (byte).
On Sun, 21 Feb 2021 17:43:23 -0700, Don Y
<blockedofcourse@foo.invalid> wrote:

>On 2/21/2021 5:14 PM, boB wrote: >> On Sun, 21 Feb 2021 16:53:54 -0700, boB <boB@K7IQ.com> wrote: >> >>> >>> >>> On Sun, 21 Feb 2021 16:32:58 -0700, boB <boB@K7IQ.com> wrote: >>> >>>> On Sun, 21 Feb 2021 16:10:19 -0700, boB <boB@K7IQ.com> wrote: >>>> >>>>> >>>>> >>>>> >>>>> If I create a 1 byte command that only uses 4 bits for 16 different >>>>> functions, and there were NO following bytes (there might be folling >>>>> bytes for some CMDs), I was thinking that the lower 4 bits could be >>>>> used for error detection. >>>>> >>>>> Could of course just truncate an 8 bit CRC I suppose and place it >>>>> there. >>>>> >>>>> Just thought I would ask. Never thought of only 4 bits before but >>>>> sometimes a single byte could be efficient, bandwidth wise. >>>>> >>>>> Thanks >>>>> boB >>>>> >>>> >>>> >>>> A simple 16 nibble array would work just fine. Of course. >>>> >>>> Getting close so I am feeling a bit dumb even asking :) >>>> >>> >>> >>> Looks like x4 + x1 + 1 is used but that won't fit into 4 bottom >>> bits. Maybe what I am really looking for is just a bastardization of >>> the 4 bits I am tryng to hash ? Not sure how smart that table has to >>> be. >>> >>> >> >> >> Nevermind... I'm just stoopid. >> >> Created an array of 15 randome numbers... >> That should work. > >You want the "distance" (i.e., number of bits that must change in order >to convert one valid code into another valid -- but, now, INCORRECT -- code >to be as long as possible. FOR EVERY POSSIBLE VALID CODE. > >Once can *detect* N errors in codes if the distance between valid codes is N+1. > >So, if you have to flip a minimum of 2 bits to be able to convert one code >word into another valid (but incorrect) code word, then you can obviously >detect any code that has *only* ONE flipped bit. > >You can *correct* M errors in a code word if the minimum distance between code >words is 2M+1. > >Note that you need to understand the nature of your error sources in order >to understand the protection any code will present. If each bit stands an >equal chance of flipping -- but, the chance of multiple bits flipping is >lessened due to the independence of those events -- then you want a >different sort of code than if, for example, one flip *tends* to result in >other flips. > >E.g., if you are sending data down a communication channel and noise >can blot out large chunks of the data stream, then your code needs >to address the likeliness of multiple bits being affected in the >same corruption event. > >[Google "Hamming Distance"]
I will Google Hamming Distance. I think I understand that but possibly not. This system does have the possibility of having quite a bit of noise actually. I probably should not have too small of error detection at least. I hadn't thought of using error correction but sending multiple times instead for this one. I think I have more time to resend rather than processor time for decoding. Thank all of you for making me think more about this.
On Sun, 21 Feb 2021 19:17:02 -0500, Richard Damon
<Richard@Damon-Family.org> wrote:

>On 2/21/21 6:10 PM, boB wrote: >> >> >> >> If I create a 1 byte command that only uses 4 bits for 16 different >> functions, and there were NO following bytes (there might be folling >> bytes for some CMDs), I was thinking that the lower 4 bits could be >> used for error detection. >> >> Could of course just truncate an 8 bit CRC I suppose and place it >> there. >> >> Just thought I would ask. Never thought of only 4 bits before but >> sometimes a single byte could be efficient, bandwidth wise. >> >> Thanks >> boB >> >> > > >IF I am doing my math right 8 bits is good enough for 4 data bits, 3 >syndrome bits, and a parity bit to give you 1 bit error correction, 2 >bit error detection. That might be better than a 4 bit CRC.
Thanks. I think I may just do 8 bit CRC for the short command. I will be re-transmitting often enough I think for the messages to get through.