Sample multiple channels at regular intervals.

Post general discussions on using our drivers to write your own software here
Post Reply
User avatar
Posts: 4
Joined: Thu Mar 31, 2005 11:19 am

Sample multiple channels at regular intervals.

Post by simon@mira »

What I would like to do is to sample 8 channels as quickly as possible (i.e. to get a snapshot of all 8 channels at the same time) at a relatively slower interval.

For example, with the ADC11/12 I should be able to sample 8 channels at 50us per channel; that gives me 400us to complete that operation.

Now I want to do this at 200Hz (period of 5ms). This means that there is a quiet time (no sampling going on) of 4.6ms.

Ideally, I will use a clock signal on channel 1, operating at 200Hz from which I can trigger the sampling of the 8 channels.

My code so far is this (in delphi):

Code: Select all

  auto_trig_time = 1000;    { auto trigger time (ms) }
  trig_channel   = 1;
  trig_edge      = 1;       { rising edge trig }
  trig_threshold = 1000;    { trigger level in ADC counts }
  trig_delay     = 0;

  no_of_chans    = 2;

  smp_interval : longint;
  my_channels  : channel_array;
  my_values    : array[0..100] of word;
  bool_ret     : boolean;
  smp          : integer;
  loop         : integer;
  volts        : real;
  myStrList    : TStringList;
  { create string list }
  myStrList := TStringList.Create;

  { set trigger properties }
  adc11_set_trigger(1, 1, auto_trig_time, trig_channel,
                    trig_edge, trig_threshold, trig_delay);

  { set time interval per sample }
  my_channels[1] := 1;
  my_channels[2] := 2;

  smp_interval := adc11_set_interval(1,1,my_channels,no_of_chans);
  memMsgs.Lines.Add('Actual sample interval = '+IntToStr(smp_interval)+'us.');

  for loop := 1 to 20 do
    { start ADC11 unit }
    while (adc11_ready = 0) do;

    { get values }
    bool_ret := adc11_get_values(my_values, 2);

    if bool_ret then
      volts := (2.500 * my_values[0] / adc11_max_value);
      myStrList.Add('Ch1: '+FloatToStrF(volts,ffFixed,1,3)+'V');
      volts := (2.500 * my_values[1] / adc11_max_value);
      myStrList.Add('Ch2: '+FloatToStrF(volts,ffFixed,1,3)+'V');
  end; {for loop}
This code works as far as it collects 20 blocks of data (for 2 channels only) but it does this far too slowly. The operation takes roughly 3-4 seconds when it should only take 0.1 seconds (0.005 * 20).

Is there any other way of doing what I want to do or is it impossible with the ADC11/12?



Post by Sarah »

Hi Simon

Thank you for your post.

I have been looking at this with one of our software engineers and we are not sure why it should be running so slowly. There are a few things though that should be changed to make it quicker.

Firstly the maximum speed of the ADC-11 is such that is can only sample each channel at 100us and will therefore take 800us to get round all 8 - not 400 as you had calculated.

Where you have set your ideal sample time as 1us per sample, this is not achievable by the unit and it will actually slow it down slightly having it specified as faster. I would advise that you change this so that it matches the capability of the unit.

The other thing to check is that the pulse you are supplying is longer than 800us - if it is not then it might not be able to trigger from it in the program as it might occur between samples.

Let me know how you get on with this.

Best Regards

Post Reply