- From: Ian Abbott <abbotti_at_mev.co.uk>
- Date: Mon, 27 Nov 2006 12:06:38 +0000
On 27/11/06 08:22, Marcel Rutten wrote: > The question I have for the > comedi community is: is it possible to read a quadrature encoder with > the counters of such a board, and, if so, has anyone some example code > for this available? It should be possible using a series of calls to comedi_do_insn() to configure the counter and comedi_data_read() to read the values. You may also be able to use comedi_data_write() to set the initial value, but I'm not sure.. Setting up is the tricky part as there is no Comedi documentation for it. The code for a configuration instruction is something like this: comedi_insn insn; lsampl_t data[M]; memset(&insn, 0, sizeof(insn)); insn.insn = INSN_CONFIG; insn.n = M; /* alter this! depends on the instruction in data[0]. */ insn.data = data; insn.subdev = subdev; insn.chanspec = CR_PACK(chan,0,0); data[0] = INSN_CONFIG_FOOBAR; /* set to instruction code */ /* ... */ data[M-1] = foo; /* Set up data for instruction */ retval = comedi_do_insn(dev, &insn); Note that insn.n is the length of the instruction, which depends on the instruction code in insn.data[0]. Check the ni_gpct_insn_config() function in comedi/drivers/ni_mio_common.c for details of the instructions supported by the GPCT counter subdevice. -- -=( 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-11-27Z12:06:38