0

I have raw hex data from MEMS accelerometer with sampling rate of 1 sample per millisecond for a measurement duration of 2.5 seconds for each trace.The data contains first 12 bits for timestamp and then continued with 2 for each axis of acceleration X,Y and Z. I want to reduce this hex data with size around 31kb to 120 bytes for wireless data transfer. I want to achieve this through python

sairam
  • 1
  • 1
  • 1
    When you say "with 2 for each" you mean two bits each? (That doesn't seem very specific for the motion.) So you can save 2/3 the size by stripping the timestamp, assuming you don't need them any more, but you're still asking for a 80-90x saving and unless there's little variation in the samples (so you could e.g. run-length-encoding) or set bits are very rare (huffman, etc.) then you're very unlikely to get that much compression I'd think. Unless you had an algorithm in mind? – Rup Oct 12 '18 at 14:09
  • It is 2 bytes each – sairam Oct 15 '18 at 15:25
  • I guess I could have worked that out from the 31K. OK, in that case you currently have frames of 1.5 bytes for the timestamp and 6 bytes for the measurements so you can only save 20% by stripping the timestamp. Your options are probably then to reduce the measurement resolutions, e.g. apply a G.711 mu-law-like process to reduce each two-byte pair down to a single byte, if that's sufficient accuracy for your purposes? or reduce the sample rate returned to reduce the volume of data that way? – Rup Oct 15 '18 at 15:39
  • Or depending on the values you get there might be other ideas you can apply e.g. delta change from each previous value and then run-length-encode and/or Huffman-encode the deltas, or if your data is periodic then maybe a CELP-like repeating period and dictionary of deltas to apply. I doubt you can use an audio-codec as-is since they will assume human voice frequencies. Are your axes independent - is there any scope for compressing them together, or perhaps converting to polar coordinates to compress? But I still don't think you're going to compress your 31K down to 120 bytes. – Rup Oct 15 '18 at 15:41

0 Answers0