Re: how to configure ni_6602 for quad encoding?

On 09/03/06 09:29, janne wrote:
> It seems like I can read and write from some I/O ports, so something seems
> to be working so far.
> Anyway, I want to use the ni_6602 as a quad encoder, but have no idea how to
> configure the card to work as suck.
> The ni_6602 User manual only explains which modes there is, but not how to
> set them up (I believe this is something
> that the proprietary drivers do automagically).
>    Anyway, the Comedi ni_660x driver description says that the encoders
> work.  Nice, but how to use them? :/

Something like this:

int configure_quad(comedi_t *dev,
		unsigned int subd,
		unsigned int encoding,		/* GPCT_X1, GPCT_X2 or GPCT_X4 */
		unsigned int indexphase,	/* GPCT_IndexPhaseHighHigh, 
GPCT_IndexPhaseLowHigh, GPCT_IndexPhaseLowLow or GPCT_IndexPhaseHighLow */
		unsigned int resetonindex	/* 0 or GPCT_RESET_COUNTER_ON_INDEX */
	)
{
	comedi_insn insn;
	lsampl_t data[4];

	memset(&insn, 0, sizeof insn);
	insn.insn = INSN_CONFIG;
	insn.subdev = subd;
	insn.data = data;
	insn.n = 4;

	data[0] = INSN_CONFIG_GPCT_QUADRATURE_ENCODER;
	data[1] = encoding;
	data[2] = indexphase;
	data[3] = resetonindex ? GPCT_RESET_COUNTER_ON_INDEX : 0;

	return comedi_do_insn(dev, &insn);
}

-- 
-=( Ian Abbott _at_ MEV Ltd.    E-mail: <abbotti_at_mev.co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-

Received on 2006-03-09Z10:55:43