Re: counter, pulse generator API, ni_660x.o

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


I finally commited a modified version of the ni_660x patch to cvs, if 
anyone cares to look at it.  It seems to me it would be nice to have more 
flexible support for adding extensions to comedi, than using configuration 
instructions.  I'm thinking an ioctl that takes a data structure like:

struct comedi_extension
{
	int subdev;
	int extension_id;
	void *extension_data;
};

and a comedilib wrapper function with the prototype

int comedi_extension(comedi_t dev, int subdevice, int extension_id, void
	*extension_data);

so everything doesn't have to be mashed into an array of 32 bit integers 
as with configuration instructions, rather the extension can define its 
own data structure (which would perhaps help make this counter support 
feel less kludgy).

Here is a description of the configuration
instruction, copied from comedi/drivers/comedi_counter_unstable.h:

ID=INSN_CONFIG_COUNTER_ALPHA: counter configuration

  The subdevice has an accumulator which changes based on
  triggers.

  [0] - ID
  [1] - trigger0 (comedi_counter_trigger_bits() is helpful)
  [2] - action0 (action associated with trigger0, see
	comedi_counter_actions for possibilities)
  [3] - trigger1
  [4] - action 1
  ....

  You can specify as many trigger/action pairs as you like.

  Example Modes:
    Up counter, counting falling edges on input 0

	data[0] = INSN_CONFIG_COUNTER_ALPHA;
	data[1] = comedi_counter_trigger_bits(0, CR_EDGE | CR_INVERT);
	data[2] = COMEDI_INC_ACCUMULATOR;

    Down counter, counting rising edges on input 0, and using input 1 as 
	a gate (input 1 must be high to count):

	data[0] = INSN_CONFIG_COUNTER_ALPHA;
	data[1] = comedi_counter_trigger_bits(0, CR_EDGE) |
		comedi_counter_trigger_bits(1, 0);
	data[2] = COMEDI_DEC_ACCUMULATOR;

    Quadrature x1 encoding:
	data[0] = INSN_CONFIG_COUNTER_ALPHA;
	data[1] = comedi_counter_trigger_bits(0, CR_EDGE) |
		comedi_counter_trigger_bits(1, CR_INVERT);
	data[2] = COMEDI_INC_ACCUMULATOR;
	data[3] = comedi_counter_trigger_bits(0, CR_EDGE | CR_INVERT) |
		comedi_counter_trigger_bits(1, CR_INVERT);
	data[4] = COMEDI_DEC_ACCUMULATOR;

  Notes:
	Could add fields for specifying what inputs are connected to (input 0
	connected to external input pin, or internal oscillator?).

	Could make triggers/actions more involved, for example "trigger on 
	accumulator reaches 0", or specify a value to reload the counter with 
	for the COMEDI_RESET_ACCUMULATOR action.  Could add an action that 
	sets the counter's output, like "pulse output when accumulator reaches 0".

	Using this instruction is a bit of a pain.  On the user-end, the user has
	to figure out exactly how to describe what her counter is doing in order
	to program it, even if the counter only supports a few different modes of
	operation.  This could be eased by providing helper functions that fill
	out an insn with the appropriate values for particular pieces of 
	hardware.  On the driver end, it might make things easier if we provided
	some functions for operations on sets of trigger/action pairs.  For
	example, queries like "is A a subset of B" where A and B are sets 
	of trigger/action pairs.

- -- 
Frank

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE/wSM15vihyNWuA4URAjIYAKCqyFoOKE++wsH25K8lGujw7s1B2ACgwbzf
qkrUmY3e5nqxMVAERPkh1L4=
=hMVs
-----END PGP SIGNATURE-----

Received on 2003-11-23Z21:14:29