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.
-- 
   ____
  /  |_| <<< IR. ARNO H.A. STIENEN >>>
|_ O  | Biomechanical Engineering | http://www.bw.ctw.utwente.nl
|_|__/  a.h.a.stienen_at_utwente.nl  | +31-(0)53-489-4778
UTwente "There are alternatives: Firefox, Thunderbird & OpenOffice!"

Received on 2006-01-11Z16:43:42