- From: Arno Stienen <arnoreg_at_gmail.com>
- Date: Thu, 28 Jun 2007 09:11:49 +0200
Hi Anders, Klaas and Frank,
Great to see another encoder (card) supported!
A long time ago I adapted a couple of RTAI-Lab Simulink blocks to make
use of the NI 660x encoder card. Looking at your source code, it seems
it work slightly different to the way Klaas Gadeyne implemented his
code. Below I copied the summary of the 660x config code from a message
of mine a long time ago. The reading and writing to the device is
different too.
Would it be wise to change either code to match each other?
Bye,
Arno.
Stienen, A.H.A. (CTW) wrote:
Re: Standard Config INSN for Quadrature Encoder?
Hello,
I've build a Simulink S-Function block for encoder devices, based on the
NI_660x and RTAI-Lab AI driver and as an addition to the AI, AO, DI and
DO devices blocks already available for RTAI-Lab. I'm wondering whether
this block can be useful for other quadrature encoder devices in RTAI-Lab.
Most of the code in the S-Function is pretty Comedi basic
(comedi_data_read, etc), I think, but I'm not sure whether the
configuration process of the NI_660x is similar to other quadrature
encoders.
The configuration code I'm currently using is based on the NI_660x test
example of Klaas Gadeyne. It comes down to:
comedi_insn insn;
lsampl_t config_data[4];
insn.insn = INSN_CONFIG;
insn.n = 1; // Is relevant to config! :)
config_data[0] = INSN_CONFIG_GPCT_QUADRATURE_ENCODER;
config_data[1] = quadraturemode; // {GPCT_X1, GPCT_X2, or GPCT_X4}
config_data[2] = indexphase; // {GPCT_IndexPhaseHighHigh,LH,LL,HL}
config_data[3] = indexreset; // {0,GPCT_RESET_COUNTER_ON_INDEX}
insn.data = config_data;
insn.subdev = subdev;
insn.chanspec = CR_PACK(channel,0,0);
comedi_do_insn(dev,&(insn));
Where 'dev' points to a /dev/comediX, 'subdev' is the result of a
comedi_find_subdevice_by_type(dev,COMEDI_SUBD_COUNTER,0), and 'dev'
'quadraturemode', 'indexphase', 'indexreset' and 'channel' are given by
the user via the Simulink S-Function mask. After configuration, I can
read the encoder signal with a comedi_data_read.
Is this configuration process usable for other encoders too? I only have
the NI_660x card. Does anybody know of other quadrature encoders
supported by Comedi?
Kind regards,
Arno Stienen.
Received on 2007-06-28Z06:11:49