Robotic lawnmower - Using cross correlation to find perimeter wire

Hi all,

I have a problem that I need some guidance/example to understand.

The Case:
I have build a robotic lawnmower that is based on Ardumower project (I had problems of undestranding the source code so, I re-wroted the parts I needed).

At this point the robot uses coil and amplifier to find the perimeter wire. The perimeter wire sends pulses at given intervals. If the time between pulses (red by the robot / coil) equals to the senders interval, robot has encountered wire and it needs to reverse.

Everything works beatyfully and with no delay..... Untill the blade motor is turned on.
Blade motor crates so much noise that the robot does not recognize the perimeter wire. I tried to use some "hot glue" solutions i.e. if coil reads certain value X amounts in Y time it must be the wire. This helped little bit (success rate ~70%), but not nearly enough.

In the orginal Ardumower code cross correlation is used to find given signal from high noise. I have red wikipedia etc. but still can't understand the code.

Good source that explains it:
http://grauonline.de/wordpress/?page_id=364

This is an example of cross correlation code, which I do not understand. Ardumowers code is too compled and in too many files to post here.

// digital filter (cross correlation)
// http://en.wikipedia.org/wiki/Cross-correlation
// H[] holds the signal to look for (also called filter coeffs)
// ip[] holds ADC sampling buffer (length > nPts + M )
// op[] is filter output buffer
// nPts is the length of the required filter output data
void Perimeter::convFilter(int8_t *H, int16_t M, int8_t *ip, int16_t *op, int16_t nPts){  
  int16_t sum = 0;
  for (int16_t j=0; j<nPts; j++)
  {
      sum = 0;
      for (int16_t i=0; i<M; i++)
      {
        //sum += H[i]*ip[subSmp*j+i];
        sum += ((int16_t)H[i]) * ((int16_t)ip[j+i]);
      }
      op[j] = sum;      
  }
}

What I want:
Let's say the perimeter wire singal is 6-bit [1 1 -1 -1 1 -1] with interval of 100 ms.
How do I apply cross correlation to this?
-Do I record datapoints from coil at 100ms interval, and use those to determine correlation.

I did took some signal prosessing at Uni (it was last straw before changin major :slight_smile: ) and have forgotten even the little that I understood from it.

Thanks in advance.

The code simply multiplies together the elements of two arrays, and sums the products, for a given delay time j.

The H array contains the ideal signal (what you expect to see), while the ip array contains the sampled signal.

A large value in the op array, at some time delay j, means that the input signal strongly resembles the ideal signal.

What type of motor is the "blade motor"? Electrical, sparking…? Would it be possible to denoice that motor? Ferrit cores, shielded wires etc.?
Or is it the fysical vibrations that causes the trouble? Is it possible to increase the signal strength in the fence?
Could You attach a picture showing the real installation of cables? Take hoods and covers off if possible.

veikkae:
What I want:
Let's say the perimeter wire singal is 6-bit [1 1 -1 -1 1 -1] with interval of 100 ms.
How do I apply cross correlation to this?
-Do I record datapoints from coil at 100ms interval, and use those to determine correlation.

Generally one would sample the signal at a sample rate higher than the symbol rate if there is no guarantee that the samples are somehow synchronized to the transmitted symbols.

Using your example, we're looking for the symbols sequence S = [1, 1,-1,-1, 1,-1] at 100 ms interval.

If we used a sample rate 4 times the signal rate (25 ms), then nominally each symbol would be sampled 4 times. So the signal we'd be looking for is "S" except with each symbol repeated 4 times, hence the "H" array is [1, 1, 1, 1, 1, 1, 1, 1,-1,-1,-1,-1,-1,-1,-1,-1, 1, 1, 1, 1,-1,-1,-1,-1].

Railroader:
What type of motor is the "blade motor"? Electrical, sparking…? Would it be possible to denoice that motor? Ferrit cores, shielded wires etc.?
Or is it the fysical vibrations that causes the trouble? Is it possible to increase the signal strength in the fence?
Could You attach a picture showing the real installation of cables? Take hoods and covers off if possible.

Blade motor is a beefy 12V fanmotor from a old car. It might help to shield the motor more, but I bet the spinnig balde (1mm steel disc with blades) causes part of the problem. Wheel motors affect little, but not as heavily.

I see, if I can dismantel the thing that much, inner parts are in two "stories" electrical motors at bottom, plywood deck, and board and wirings at the top. (I know, not the best in terms of maintanance :D)

MrMark:
Generally one would sample the signal at a sample rate higher than the symbol rate if there is no guarantee that the samples are somehow synchronized to the transmitted symbols.

Using your example, we're looking for the symbols sequence S = [1, 1,-1,-1, 1,-1] at 100 ms interval.

If we used a sample rate 4 times the signal rate (25 ms), then nominally each symbol would be sampled 4 times. So the signal we'd be looking for is "S" except with each symbol repeated 4 times, hence the "H" array is [1, 1, 1, 1, 1, 1, 1, 1,-1,-1,-1,-1,-1,-1,-1,-1, 1, 1, 1, 1,-1,-1,-1,-1].

The synchronization is someting I wondered last night. I have to think about this, and maybe try to do some testing in noisy enviroment.