Sunday, 14 July 2013

Automotive Scope Basics - setting the time base correctly

Setting the correct sampling rate when using a scope is a decisive factor in getting a quality measurement. It enables you to get the information that you need from the measured signal, to ensure you are able to make an informed diagnostic judgement! This factor is particularly important with respect to the signal input channel and the target measurable. Let’s look closely at how you can get this right, and avoid under or over sampling.

First thing to understand is the reasoning for the appropriate sample rate, of course, you could sample every channel as fast as possible! But, you would end up with large data files, difficult to handle, with extra information (and possibly noise) on the signal that you don’t need. The opposite, if you don’t set the sample rate high enough, you will miss crucial components of the signal – this is known as aliasing! One of the first things to appreciate is the relationship between sampling time (distance between samples) and frequency, it is easy!

Frequency = 1/sample time

e.g sample time is 10 milliseconds => 1/0.01 => 100Hz

So, by measuring the cycle time, you can calculate the frequency, and vice versa – but what does this mean and how does this help? In signal processing technology, there are sampling theorems proposed (try Googling – Nyquist, Shannon) which state that the sampling frequency must be at least twice that of the highest frequency signal component of interest. This means that, if you can measure and establish the fundamantal highest frequency, then you can set the sample rate accordingly. There are some slight complications though, generally when we are using a Scope to measure automotive signals, the signals are transient in nature, normally related to engine speed. So, it is important to consider what the signal frequency will be at the highest frequency that may be achieved during a measurement – let’s look at an example. The diagram (Fig 1) shows a typical inductive CPS signal (Crank Position Sensor), in this case with 2 ‘gaps’ as reference points for the engine management system.

Fig 1 – CPS raw signal, 2 positions per revolution where there are missing teeth as reference points

In this case the cursors are measuring the time difference for 1 engine rev (about 30 milliseconds) which converts to 2000rpm (which is correct).

e.g. 1/0.03 => ~33.33Hz - then multiply by 60 to convert to min from seconds...

 =>33.33 x 60 => 1999 rpm (approx. 2000rpm)

If we look in a bit more detail at the signal, we can examine the highest frequency part (Fig 2)

Fig 2 – CPS signal, zoomed in, cursors measuring the time difference of the high frequency part

In this case, the display shows the frequency directly in the bottom right hand corner (I am using a Picoscope). So based on this (~ 4kHz), I know I have to set the sample rate at 8kHz to ensure that I don’t miss anything on the signal. As mentioned earlier, this measurement is at an engine speed of 2000rpm. So, I need to consider an upper limit, in this case, I could say it’s a gasoline engine, I am not likely to exceed 6000rpm in my measurement task, so I can set the sample rate accordingly at 3 x 8kHz or slightly greater (according to the time base setting steps you have on your measurement device). So now I know that I will sample with good digital resolution and conversion quality, without oversampling, right throughout my task. Let’s take a look at what happens when you under or over sample – This picture below (Fig 3) shows the effect of under sampling. In this screenshot it is not too extreme, the signal is sampled at ½ the correct value according to the sampling theorem. This means it is being sampled at its actual frequency – so you can see the basic shape of the wave, but you can also see the loss of details compared to the correctly sampled signal.

Fig 3 – Undersampling (brown trace at 8kHz – the minimum required, blue trace at 4 kHz)

In Fig 4 below, we can see the effect of oversampling on the signal, basically a lot of noise can be seen, which in this case, will add no value to the evaluation and could be misleading (In contradiction though - it’s worthy to note though that sometimes noise can be the root source of a problem, so, sometimes it may be necessary to sample at high frequency to capture this). 

Fig 4 – Oversampled signal (brown trace at 8kHz, blue trace at 1MHz)

What is not shown is the effect on the size of data files – large files are difficult to handle and store! Fig 5 shows the relative file size of different sample rate for the data shown in the screen shots, file size grows exponentially compared to sample rate! For measurements over extended periods, at high resolution, the files will be very large!

Fig 5 – Data file size compared to sample rate

Experimenting around a bit with this signal showed that a 100kHz sample rate was a good compromise! Generally sampling theorems suggest a minimum of twice the highest frequency component. In my experience, anything between 2 and 10 is fine, depending upon the application and the task. Fig 6 shows the signal at 100kHz. This is a sampling factor of 25 at 2000rpm and 8.33 at 6000rpm – which is fine for this CPS signal – the signal will be appropriately sampled, even at the maximum engine speed.

Fig 6 – Sampling at 100kHz, a good compromise in this case

Establishing the correct basic sampling frequency for a signal is good practice, it optimises the trade off between good quality measurement data and manageable files to work with. Of most importance though - it means the you have a good understanding of what you are doing, and that you know how to configure and use your scope effectively! It is well worth practicing this aspect of the set-up - measure some signals with deliberate over and under sampling, then compare them so you can see the difference in data quality, with a known signal type, when the scope is sampling correctly set, and when it is not!

No comments:

Post a Comment