We are trying to use an NI USB-6009 device to conduct I/O within a Simulink model. The model is already well developed and running on Simulink Real Time with another DAQ, and so we want to change the structure as little as possible. From my understanding, there is no support for the NI device with the Real Time package. Instead, we are trying to implement the data aquisition with the Data Aquisition Toolbox. This will be acceptable as we don't need hard real time and can run the model from a computer with MATLAB/Simulink running.
I need to count pulses from an encoder using the USB-6009 counter channel. I can do this in MATLAB using the following code:
s = daq.createSession('ni');
addCounterInputChannel(s,'Dev1', 'ctr0', 'EdgeCount');
What is the equivalent to this in Simulink? The Data Acquisition Toolbox in Simulink does not include a counter input/output block. I find it strange that such a simple function would be available in MATLAB but not implemented in Simulink. When running the first line of the above code in Simulink through a MATLAB function blocks I get the following error:
Function 'createSession' not supported for code generation.
Function 'MATLAB Function' (#35.23.46), line 2, column 5: