MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Impulsreconstruction

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22499] Impulsreconstruction
  • From: hans.steffani at e-technik.tu-chemnitz.de (Hans Friedrich Steffani)
  • Date: Sat, 4 Mar 2000 02:27:02 -0500 (EST)
  • Organization: Chemnitz University of Technology
  • Sender: owner-wri-mathgroup at wolfram.com

Physical background:
I have a machine starting with 40Hz=2400 rpm and slowing down to
about 1Hz within about 6min. There is zero-puls every revolution.

Now I am measuring with 1kHz, which produces a list, which can be
transformed to a list of 1 and -1. -1 means pulse, 1 means no pulse.

To things can happen. A pulse can be longer than one sample
intervall, which means I have a pair or tripple of -1s with no 1
between. This is not the main problem as I stop before pulses become
too long.

Pulses can be lost, because of the sampling or because of problems
with the pulsgenerator. This can be detected when the time between
the actual pulse and the next pulse is much longer than the time
between the next and the pulse after the next. This covers not the
case, if we have the situation
 <pulse> <missing pulse> <pulse> <missing puls>
but hopefully this does not happen. Maybe you have a suggestion which
also handles this  case.

Therefore I wrote a function to repair all the things. However this
function looks not very good, maybe one which is more mathematica like.

Here is the code:

In[48]:=
nullimpbau[datei_, grenze_] := Module[{nullimp, nullpos, extrapeaks = {}},
      (* Read the values *)
      
      nullimp = Sign[ReadList[verz <> "NULL" <> ext, Real] - grenze];
      
      (* Remove pairs and tripples *)
      
      Do[If[nullimp[[i]] == nullimp[[i + 1]] == -1, nullimp[[i]] := 1], {i, 
          Length[nullimp] - 1}];
      
      (* some pulses are missing, we reconstruct them *)
      
      nullpos = Flatten[Position[nullimp, -1]];
      
      nullpos = 
        Transpose[{nullpos, RotateLeft[nullpos, 1], 
              RotateLeft[nullpos, 2]}][[Range[Length[nullpos] - 3] ]];
      
      nullpos = Map[{#[[1]], #[[2]] - #[[1]], #[[3]] - #[[2]]} &, nullpos];
      
      (* as velocity decreases slowly, 
        nullpos[[i, 2]] and nullpos[[i, 3]] should be the same, 
        maybe nullpos[[i, 3]] is a little bit smaller. If nullpos[[i, 2]] > 
          2nullpos[[i, 3]], 
        we missed some pulses. Now we construct a list called extrapeaks, 
        which tells us where the peaks are missing. *)
      
      Do[
        If[nullpos[[i, 2]]/nullpos[[i, 3]] >= 2, Do[
            
            AppendTo[extrapeaks, nullpos[[i, 1]] + j*nullpos[[i, 3]]], {j, 
              Round[nullpos[[i, 2]]/nullpos[[i, 3]] - 1 ]}]]
        , {i, Length[nullpos]}];
      Print[Length[nullimp]];
      Print[extrapeaks];
      
      (* Add the extrapeaks to nullimp *)
      
      Do[nullimp[[extrapeaks[[i]] ]] = -1, {i, Length[extrapeaks]}];
      
      nullimp
      ];


Thanks
Hans Friedrich Steffani
-- 
Hans Friedrich Steffani
Institut fuer Elektrische Maschinen und Antriebe, TU Chemnitz
mailto:hans.steffani at e-technik.tu-chemnitz.de
http://www.tu-chemnitz.de/~hfst/


  • Prev by Date: Re: FindRoot vs Solve
  • Next by Date: Re: How to do a Nonlinear Complex Fit ?
  • Previous by thread: official statement on Linux and Calculus WIZ
  • Next by thread: Impulsreconstruction