Effacer les filtres
Effacer les filtres

Data Acquisition Toolbox with Simulink: Counter Input Channel

3 vues (au cours des 30 derniers jours)
Axton Isaly
Axton Isaly le 26 Oct 2019
Commenté : Rutvik Shete le 11 Août 2020
Hi,
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');
s.inputSingleScan()
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:
"daq.createSession('ni')"

Réponses (2)

Walter Roberson
Walter Roberson le 7 Août 2020
Modifié(e) : Walter Roberson le 10 Août 2020
turn off rapid acceleration. You can have normal acceleration but you will probably need to mark a number of functions as external. If you turn off acceleration completely you can call normal matlab functions from a matlab function block.
  3 commentaires
Walter Roberson
Walter Roberson le 10 Août 2020
Well, that took longer to look up than it should have!
Rutvik Shete
Rutvik Shete le 10 Août 2020
Thank u very much.

Connectez-vous pour commenter.


Rutvik Shete
Rutvik Shete le 7 Août 2020
facing same issue with NI USB 6251. Cant use commands when I code using Function block in Simulink.
Error is "Function 'daq' not supported for code generation. "
  2 commentaires
Walter Roberson
Walter Roberson le 10 Août 2020
This is correct. The Data Acquisition Toolbox is not supported for Code Generation.
It is supported by MATLAB Compiler.
I am not clear as to whether it is supported by Simulink Coder.
If you happened to be trying to use it from MATLAB Function Blocks, then you could use No Acceleration, or Normal Acceleration, and use coder.extrinsic() to have the interpreted engine invoke the functions. You might not be able to use Rapid Acceleration. There are probably a series of alternatives to use with Real Time Workshop.
Rutvik Shete
Rutvik Shete le 11 Août 2020
Well that helped me use external functions with sacrifice of simulation speed. Thanx a lot.

Connectez-vous pour commenter.

Produits


Version

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by