Go Down

Topic: LZ type compressor/decompressor article (Read 2 times) previous topic - next topic


Arduino coders,

I've made a simple LZ-type compression system for Arduino that compresses text and data by a fairly respectable ratio - it typically saves ~40% on text or graphics.  There's a Python command-line compression utility, and some sample code to decompress from flash.  The original thread talking about compression is here:


My writeup and code for the decompressor is at:


Let me know if you have any questions..


Good job!

If I have say 30 strings of ~15 bytes = ~500bytes in my application, could I save memory by placing them compressed in (prog)memory?
More precisely formulated what is the compression ratio for relative short strings.

Do you also have written an Arduino compressor ?
so that it can compress sensor / log data before - writing to SDCARD , EEPROM, serial, or over an ethernet socket.  40% compression means less communication time.
Question is then how much time cost it to compress a typical string and is this less that the time gained by communication?

Think I just need some more numbers, can you provide?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


The compression ratio for short strings is always quite poor - LZ compressors need to build up a dictionary of prior data before they can start using backward references.  One option is to  compress all messages as a single block and then pick out the one you want during decompression.

I looked at compression systems that have fast compression.  LZJB aims to do this, which is my it is used in filesystems, but its memory requirements of >64K are way beyond most embedded systems.

Sensor data is often best compressed using some ad-hoc scheme, e.g. only sending differential updates.


OK, you confirmed my expectations wrt compression by the arduino.

that said it still sounds interesting to use the decompressor when using the arduino as (web)server with large content blocks read from sdCard

Do you have any numbers about decompression performance #bytes per second? Or perhaps a complete test sketch?

Suppose serial communication of a 1000 bytes data
BAUD  115200 => uncompressed 104msec  => compressed - ~40% = 62 msec   savings  40 msec
BAUD    19200 => uncompressed 520msec => compressed - ~40% = 312 msec  savings  200msec

if the decompress is faster than savings it would be great.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


I'll work up a full example in the next day or two...

Right now I'm using it to decompress graphics data from flash to SPI RAM, and 14 Kbytes takes 600ms: about 23 Kbyte/s  This is very unoptimized code, there should be at least a doubling possible.

Go Up