Q: ext. triggered AO waveform

7 views
Skip to first unread message

Andrey

unread,
Apr 17, 2022, 11:34:48 AMApr 17
to Comedi: Linux Control and Measurement Device Interface

Hello,
  I'd like to generate AO waveform  triggered  by an external  pulse generator.

Hardware: NI PCI-6281 (8k samples output FIFO, up to 2.8 Ms/s).
Waveform is about 4k samples * 500ns sampling rate  = 2 millisecond length
External trigger is connected to PFI0 and about 10Hz (every 100 millisecond)

comedi_board_info output is:
overall info:
  version code: 0x00074c
  driver name: ni_pcimio
  board name: pci-6281
  number of subdevices: 14
subdevice 0:
  ...
subdevice 1:
  type: 2 (analog output)
  flags: 0x02127000
  number of channels: 2
  max data value: 65535
  ranges:
    all chans: [-10 V,10 V] [-5 V,5 V] [-2 V,2 V] [-1 V,1 V] [-5 V,15 V] [0 V,10 V] [3 V,7 V] [4 V,6 V]
  command:
    start: ext|int
    scan_begin: timer|ext
    convert: now
    scan_end: count
    stop: none|count
  command structure filled with probe_cmd_generic_timed for 1 channels:
    start: int 0
    scan_begin: timer 350
    convert: now 0
    scan_end: count 1
    stop: count 2
...

It seems there is no other way for the command structure
(except might be flags=CMDF_WRITE;
which I don't know what is for,
though it makes little difference)
subdev = 1;
flags = 0;
start_src = TRIG_EXT;
start_arg = CR_EDGE;
scan_begin_src = TRIG_TIMER;
scan_begin_arg = 500;
convert_src = TRIG_NOW;
convert_arg = 0;
scan_end_src = TRIG_COUNT;
scan_end_arg = 1;
stop_src = TRIG_COUNT;
stop_arg = 4096;

dump_cmd() out
subdevice:      1
start:      ext      1073741824
scan_begin: timer    500
convert:    now      0
scan_end:   count    1
stop:       count    4096

The test is writing the same waveform buffer
and waiting for SDF_RUNNING (0x08000000 -  command is running) == 0
then cancel the command (I don't know why it should be there,
but without it write() would give 'Invalid argument')

comedi_command();
write();scan_begin: timer    500
convert:    now      0
scan_end:   count    1
stop:       count    4096

The test is writing the same waveform buffer
and waiting for SDF_RUNNING (0x08000000 -  command is running) == 0
then cancel the command (I don't know why it should be there,
but without it write() would give 'Invalid argument')


comedi_command();
write();
comedi_internal_trigger();
while (1) {
  while ((flgs=comedi_get_subdevice_flags()) & 0x08000000) usleep(10000);
  comedi_cancel();
  comedi_command();
  write();
  comedi_internal_trigger();
}

flgs==0xa127003 while waiting for the trigger
then it changes to 0x2127003 after comedi_cancel() it's 0x2127000
after write() it's already 0xa127003
but without comedi_internal_trigger() it wouldn't go.

After a few minutes it stops with flgs==0xa127003
no matter how many ext. trigger pulses are there.

Having no idea what is the reason,
I've tried to add comedi_internal_trigger() when it stopping
but only got in return 'Resource temporarily unavailable'.

I'd appreciate any suggestion might help.

Is there an alternative to just polling for the flag ?

comedi_internal_trigger();
while (1) {
  while ((flgs=comedi_get_subdevice_flags()) & 0x08000000) usleep(10000);
  comedi_cancel();
  comedi_command();
  write();
  comedi_internal_trigger();
}

flgs==0xa127003 while waiting for the trigger
then it changes to 0x2127003 after comedi_cancel() it's 0x2127000
after write() it's already 0xa127003
but without comedi_internal_trigger() it wouldn't go.

After a few minutes it stops with flgs==0xa127003
no matter how many ext. trigger pulses are there.

Having no idea what is the reason,
I've tried to add comedi_internal_trigger() when it stopping
but only got in return 'Resource temporarily unavailable'.

I'd appreciate any suggestion might help.

By the way, is there an alternative to just polling for the flag ?

Thanks,
   Andrew

Reply all
Reply to author
Forward
0 new messages