Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

16Bit - Compress Bits

Suraj143

Active Member
LFFFLLHHFLFF = 12bit Data

I have 12bit data that needs to store in microcontroller (in EEPROM).The problem is apart from Low (L) & High (H), there is high impedance states named "F" in the incoming protocol.

Is there any possibility to save this 12bit data with two bytes (Without using three bytes)?

Thanks
 

Nigel Goodwin

Super Moderator
Most Helpful Member
If it's binary digital, then it's HIGH or LOW, there's no alternative state - if there's a 'high impedance' state then that means it will be either HIGH or LOW, so store accordingly.

Exactly what is the data, where is it from, and what is feeding in to?.
 

rjenkinsgb

Well-Known Member
Most Helpful Member
No.
With a suitable table lookup, you could pack five, three-level values in to each eight bits of storage, using 243 out of 256 bit combinations.

That means a maximum of ten, three level states in 16 bits.

Using byte-wide storage, you will have to use 24 bits, in which case you can just use two bits per three level value for the 12 bits, with no other coding.
 

Les Jones

Well-Known Member
Most Helpful Member
If you are looking at the serial data between the encoder and decoder then it can only be zeros and ones as it is just switching a radio or IR signal on or off.

Les.
 

DrDoggy2

Member
Depending on how fast you need to read/write you may get away with a winzip type compression, (not the winzip part) for example your data is 8 bit ,but it only sends 16 different instrusctions, so then you can convert that in to a 4bit value, ie 1= 111111111111, 2=101010101010...ect.... (winzip part) a winzip compression would take those values and group patterns, so data= 0,1,0,1,0,1 ,1,1,1,1 ,0,1,0,1,0,1 would create a table of A=0,1,0,1,0,1 B=1,1,1,1 and the compression data would be ABA.
 

Dick Cappels

Active Member
Not familiar with the PT2262, but can you just detect the open circuit condition, perhaps using high resistance voltage divider connected to the data line and when detected, with a comparator circuit, skip storage of that bit. It would require some care to assure that what is being sampled is during a time that the data line would have settled to the high, low, and High Z state.
 

danadak

Active Member
Since data rate seems quite low seems like an algorithm in code
would be sufficient to strip out "F"s. Or a simple state machine to
do the stripping.

1663761174948.png

If you wanted to build the state machine in HW I would consider a
PSOC or low end cpld to implement that.


Regards, Dana.
 

Latest threads

Top