Measure signals from Matlab Simulink Model
Hi,
I modeled a six bus power system network on Matlab/Simulink and I would like to measure the voltage and current signals using a DAQ card. The DAQ card im having is a
NI PCI-6132 S Series Multifunction DAQ. How do I go about acquiring this signals?
Regards,
Louwrence
Hey Louwrence,
Are you going to be using the 6132 card with LabVIEW to acquire the signals? If so, you should look in the NI Example Finder that is installed with LabVIEW. Go to Help>> Example Finder. Then go to Hardware Input and Output>> DAQmx>> Analog Measurement and choose the example you would like to look at.
If you are trying to use the card through MATLAB, you will need the DAQ Toolbox. You can check for official compatibility here. I do not know what is installed with this toolbox as it is not National Instruments. There may be some examples in there however.
Hope this helps.
MATLAB®, Real-Time Workshop®, and Simulink® are registered trademarks of The MathWorks, Inc.
Joe S
Applications Engineer
National Instruments
Similar Messages
-
ABS from MATLAB (simulink) to Labview (.vi file)
Hello
My Antiskid Control System project requires me to plot the graphs of wheel speed and vehicle speed. The original model is from Matlab simulink file-absbrake(this is an example of control)
I tried to convert the whole system into labview representation. I donot want to use SIT or RT or any other Labview tools. I wanted to convert from Simulink model into Labview element-by-element. Can anyone help me...plss
my due date for submission is 15march...so please help meabs.vi is the file that i attempted to 'convert' from matlab into labview
Attachments:
abs.vi 97 KB
absbrake.vi 32 KB
absdata.vi 1 KB -
How can I put C files gave me from Matlab Simulink Real Time Workshop in a CIN?
I'm doing a turbine simulation, and I've already done it in Matlab Simulink Real Time Workshop. It gave me files .c, and I want to use them to run the same simulation on a PCI 7030/6040 using LabView RT 5.1. I'm using the CINs. My problem is that I'm able to have .lsb files, but them don't work....I mean I have as output the same result 0(zero). What can I do for solving my problem?
Thanks in advance!!Somehow, this question was posted twice on the same day. See the other posting of this same question for the answer.
Chad H.
Applications Engineering
National Instruments
http://www.ni.com/ask -
I need to control a VI from Matlab (Simulink).
The VI controls the operation of digital cameras, which I would like to trigger from Simulink.
I just need to send a signal to trigger the cameras, but this should be relatively fast.
What's the best way to accomplish this?
The VI and the Simulink model are on different computers on the same network.
Thank you for your help.Hello
I propose to use the ActiveX automation server. From Matlab is is very easy to call executable vi and make it do what you want. It is stable, fast and easy.
useful commands are (just coppied from my code - hope you can follow):
If you test it through the development environment you use:
LVapp = actxserver('Labview.Application');
if it is executable you use:
LVapp = actxserver('Your_App.Application');
%call your vi in to memory
viPath = 'Your_top_vi.vi';
vi = LVapp.GetVIReference(viPath) ; % 'Load the vi into memory
% 0 - invisible, 1 - visible
%vi.FPWinOpen = 0;
vi.FPWinOpen = 1;
%if you want to set control values you use:
invoke(vi,'SetControlValue','Your_Control_Label','Your_value');
% if you want to execute the vi you use:
vi.Run;
Hope it helps
Pawel -
Converting matlab .mdl model to .dll in veristand
Hi,
I'm new to veristand, i have 2 questions
1)how to get started with veristand basics? i saw some demos but i really need a document explaining procedure of some model. If anything pls tell me.
2) I have created a model in simulink and i'm using 2010b version and 2011 veristand evaluation version. I'm not able to convert .mdl to .dll using real time worshop.Hi,
I finally created a .dll file from .mdl simulink model. I configured in veristand and tried to deploy in veristand but i'm getting the following errors. So how do i get rid of this error.
Attachments:
error.jpg 53 KB -
Measure Frequency of Digital Signal from DAQ-Board
I'm using a National Instruments DAQ board and I need to measure the
frequency of a digital signal from my data acquisition board.
I know the measure frequency.vi (In diagram - data acquisition -
counter), but i don´t understand yours implementation mainly in input
"counter". Because i don't understand the relationship of board channel (for
signal acquiring ) and the measure frequency.vi.
Thanks in advance,
[email protected]Hi,
Attached is a vi which models your signal, and provides a way to measure the average frequency over a window of time. It converts the signal to a sequence of periods. I usually start with this approach because you can save the data in a much more compact form if your sampling rate is high. Obviously over a specified period of time, if there are no zero crossings the frequency is zero, so I was a little incoherent before. The real issue is the latency caused by averaging. Your frequency measurement is most accurate half your window size before the current time, so smaller windows give you more up to date measurements, but also more noisy. If you need the most up to date measurement, then you have to use the time since the last crossing which is the case where the frequency never goes to zero. That's probably not a realistic situation. If you needed less latency, you could use a prediction algorithm.
Also, there are a number of signal measuring and processing vi's that LV gives you, for instance pulse measurements that could be used to partially implement this or other approaches, but I normally steer clear of them unless they fit exactly due to having to convert back and forth to the waveform data type.
Have fun!
Attachments:
DigRandFreq.png 62 KB
DigitalRandomFreq.vi 34 KB -
Does creating a labview dll from simulink model require visual studio
I've asked the same question at the Simulink forums, but maybe someone here has the answer:
I'm trying to perform this process here:
http://zone.ni.com/devzone/cda/tut/p/id/3447
However, I get the following errors from the Simulink Real Time Workshop:
Error building Real-Time Workshop target for block diagram 'SensorCAN_sfcn'. MATLAB error message:
Error using ==> setup_for_visual>LocIssueMSDevError at 324
Invalid setting for environment variable MSDevDir or DevEnvDir.
The setting is: ''
You can verify the setting by checking for the existence of:
%DevEnvDir%\..\tools\vsvars32.bat (for Visual C/C++ 7.1)
%MSDevDir%\..\..\vc98\bin\vcvars32.bat (for Visual C/C++ 6.0)
%DevEnvDir%\..\tools\vsvars32.bat (for Visual C/C++ 8.0)
I do not use Visual C, what little programming I do has been done in Borland Builder or with command line gcc. Is there any way to make simulink look for a different dev environment? Or does this process require Visual C?
Solved!
Go to Solution.Thanks, I've got SIT 5.0 installled, but it turns out we have a site license for VS 2008, so I now have that as well. I've got a new problem though, and although I think it's related to Simulink, these forums seems a little more responsive than that Matlab forums. So....
I’m working with someone else's s-code, and I haven't used Simulink in the past. As I said in my original post, I am attempting to use SIT to turn the s-code into a dll for use in a LabView RT application. I opened the mdl file in Simulink, and I’m now trying to build the LabView dll in the Simulink Real Time Workshop. The target file is nidll.tlc and Matlab starts the SIT when launched, so it appears the tools are aware of each other. However, when I attempt to build the dll, I get the following error:
fatal error C1083: Cannot open include file: 'rtlibsrc.h': No such file or directory
I’m using the following: Matlab 2008b, SIT 5.0, and MS Visual Studio 2008, so the libraries and includes should be fairly up to date. What I don't get is that the files that are calling for this include are auto-generated by Simulink, so I don't know why it's not finding the rtlibsrc.h. Still, I found that in the RTW subdirectory, and copied it into my local directory. This gives me a different error:
### Linking ...
C:\PROGRA~1\MATLAB\R2008b\sys\perl\win32\bin\perl C:\PROGRA~1\MATLAB\R2008b\rtw\c\tools\mkvc_lnk.pl SensorCAN_sfcn.lnk SensorCAN_sfcn.obj rtGetInf.obj rtGetNaN.obj rt_logging.obj rt_matrx.obj rt_nonfinite.obj rt_printf.obj rt_sfcn_helper.obj nidll_main.obj rt_sim.obj SensorCAN_sfcn.res SensorCAN0_sf.obj
link /RELEASE /INCREMENTAL:NO /NOLOGO -entry:_DllMainCRTStartup@12 -dll /NODEFAULTLIB:MSVCRT LIBCMT.LIB kernel32.lib ws2_32.lib mswsock.lib advapi32.lib @SensorCAN_sfcn.lnk /dll -outensorCAN_sfcn.dll
Creating library SensorCAN_sfcn.lib and object SensorCAN_sfcn.exp
SensorCAN0_sf.obj : error LNK2019: unresolved external symbol _rt_Lookup referenced in function _mdlOutputs
Again, self-generated code, now with unresolved external symbols? I'm assuming that I'm linking the wrong version of a dll or obj that contains mdlOutputs, which appears to be something from Matlab. Can anyone point me in the correct direction? Missing headers and incorrect libraries lead me to believe that I've got a search path issue somewhere, but the Matlab/Simulink/LabView/Visual Studio are all fresh default installs. -
Hi,
I am facing a problem with the Boolean instruments when working with SIT.
On my VI I have some boolean instruments (On/Off Switch). These are connected to the Simulink model Constant blocks. SIT works fine (creates diagram etc). I am also able to run the VI and establish connection with the model. But, when I change value of either of the switch the VI 'stops'.
Instead of Boolean instrument, if I use a normal numeric instrument, then everything works just fine.
Any ideas to work around the problem?
Regards,
AmitHi Ricardo,
Thanks for your help. The issue has been resolved. One of your representatives was here with us this afternoon.
Apparently, there is a different workaround. The one you suggested will not work. We had tried out at our end. But your suggestion is inline with logic. There is something with the way the SIT makes connections.
Anyways, bottom line is the issue is resolved. I am attaching the solution that we came up with. This also might help some other users. Thanks for the help again.
Regards,
Amit
Attachments:
ModifiedBooleanAcceptor.vi 271 KB -
Connect hardware I/O to simulink model
Hello,
i developed a controller using simulink. It's already been testet by connecting signal generators via "simulation interface toolkit" between labview and simulink. That worked out very well. The next step would be testing the controleron the real process. Therefore I have to connect the inputs and outputs of the simulink model to measurements and manipulated variables of the real process.
Since there is no real time hardware on wich I could apply the .dll of the Simulink model for testing purpose I have to find a different way.
So here's my question: Is there a possibility to connect Simulink IN and OUTs to measurements within LabVIEW? And apart from that I want to send the manipulated variable which is calculated by simulink back to LabVIEW and via Rs232 e.g. to the real process.
I would be thankful for every answer or hint on how to fix this problem.
Solved!
Go to Solution.Hey,
Yes, it's possible to connect IOs via customized code in the realtime driver VI.
Please have a look at the following two webcasts (they are in German, I assume you are from Germany) where this will be explained in detail.
http://zone.ni.com/wv/app/doc/p/id/wv-619 (Das LabVIEW Simulation Interface Toolkit – Teil I – Grundlagen)
http://zone.ni.com/wv/app/doc/p/id/wv-621 (Das LabVIEW Simulation Interface Toolkit – Teil II – für Fortgeschrittene)
Christian -
Labview real-time and simpowersystems toolbx from matlab
Hello,
I have a simulink model built with SimPowerSystems toolbox. I want to run this model on a RT target which is a desktop ETS in this case. I follwoed the instructions on how to create and deploy the DLL. There are two problems I am facing--
1. The host screen grays out even though the mapping is correct. (This is verfied by using a similar working file.)
2. The RT target hangs and then the connection is lost. I don't get any error message and after some time as there is no communication, I get error 66/63 etc network related error.
The questions are:
1. Is SimPowerSystem toolbox supported in SIT? ( I read that the SimMechanics is not supported.)
2. Is there any limitation on how many nodes I can use so that the RT system can run the model without getting hung up.
The versions I'm using are:
LabView 8.2, SIT 3.0.2
Matlab R2006b, SIMULINK 6.5, Real-time workshop 6.5
microsoft visual C/C++ 6.0
Please let me know ASAP if anyone has faced this problem before or if someone can answer my questions.
Thanks,
GayatriSignals also can be removed when the code is generated and compiled due to optimizations. Right clicking on a signal and making it a testpoint forces RTW to include that signal in the compiled code signal list. The appropriate discussion is posted below.
Models Using Signal Storage Reuse, Block Reduction Optimization, or Virtual Blocks
Mappings might appear invalid if the model uses either Signal Storage Reuse or Block Reduction Optimization. These items are options you can set in the Simulink application software to reduce the memory footprint of the model. Disabling these options for the entire model makes all signals available for probing but increases the memory footprint of the model. You can mark individual signals as test points to maintain a reduced memory footprint while keeping certain signals available for probing. To make this change, load the model in the Simulink application software and perform the following actions:
For The MathWorks, Inc. MATLAB® application software release 13, right-click a signal and select Signal properties from the shortcut menu. Place a checkmark in the SimulinkGlobal(Test Point) checkbox and click the OK button to save changes.
For the MATLAB® application software release 14 and later, right-click a signal and select Signal properties from the shortcut menu. Click the Logging and accessibility tab, place a checkmark in the Test point checkbox, and click the OK button to save changes.
Note If you previously converted this model to a model DLL, you must convert the model to a model DLL again after marking signals as test points.
Similarly, you might not be able to probe signals from Virtual Blocks such as Mux, Demux, Bus Selector, and so on. Marking signals from these blocks as test points makes the signals available for probing.
Refer to the Simulink documentation for information about Signal Storage Reuse, Block Reduction Optimization, Virtual Blocks, and test points.
Models Using Inline Parameters
You might not be able to manipulate model parameters if that model uses the Inline parameters option in the Simulink application software. This option writes a constant value to each model parameter. You must launch the Simulink application software and disable this option so the Simulation Interface Toolkit can manipulate the model parameters.
Refer to the Simulink documentation for information about inline parameters.
Models Containing Linked or Masked Subsystems
You can create mappings to parameters and signals of masked subsystems. However, if a subsystem is linked, or linked and masked, any mappings to parameters and signals of that subsystem appear invalid. Refer to the Simulink documentation for information about linked and masked subsystems.
Subsystems without Parameters or Signals
If a model contains a subsystem that does not have any parameters or signals, that subsystem appears in the model tree when you create mappings. However, you cannot create mappings to/from that subsystem.
<SCRIPT type=text/javascript>
if (typeof(Print_Link)=="function") {
Print_Link();
</SCRIPT> -
How to use multiple Simulink Models on on Target and One Host VI?
My ultimate goal is to run two Simulink models simultaneously from one Real Time Target PC from one LabVIEW VI. As I understand it, this is possible but I have not found a solution or example on how to do this. For debugging and demonstration purposes, I would also like to run the same setup on my windows machine. We have had SIT (and VeriStand) working with one Simulink Model for some time now. I have tried using the SIT connection manager and coping the code, but I have not had success doing this. We are using LV 2009 and Matlab 2009. Any thoughts or inputs would be appreciated. Thanks for your help.
Just dawned on me to try and open two instances of Matlab, then set the SIT server on the second instance of matlab to a different port. This worked as I got two different simulink models to run. The question is, is there a better more efficent way of doing this? Any thoughts would be welcome.
-
How to use Labview 6i and Simulink model ????
HELLO I would like to use a simulink model written in matlab from labview
6i.
Can somebody help me?
NI says that there is a possibility but they don�t know it.
but - it can been done.
mottiHi Motti,
There are at least two ways to solve this depending on the problem. One ways is to use ActiveX technology to run a simulation model and get the results in the files saved from simulink. This is good if you have an off-line problem you do the calculations in simulink than the analysis in LabVIEW. If you have to communicate with the model interactively than you should use Real-Time WorkShop to create an executable and connect to it by TCP/IP. I have VIs for both solutions. I'm planning to release a LabVIEW toolkit for Matlab Simulink. If your problem is argent we can work out some deal.
Andras Ferencz
Naturen Kft. -
Compile Errors occured when simulink models including 'cmex' by SIT
I am trying to compile a simulink model to DLL with following softwares and hardwares.
Software:
LabVIEW 8.0.1
LabVIEW Realtime 8.0.1
Simulation Interface Toolkit 3.0
MATLAB R13
Visual C++ 6.0 Service Pack 4
Target Hardware:
PXI-1042RTPXI-8196
PXI-6289
When I tried to compile a model including 'cmex' function on Simulink to DLL, compile error about Visual C++ occured. Does SIT support the model including 'cmex' functions?
When I removed the function 'cmex', compiling is working correctly.
To import original model which is written by C or other language, I strongly want to use 'cmex' functions. To avoid the compile error, if you have any ideas, please let me know.
Thanks,
TsugoHello Tsugo,
I believe that it is possible to compile a DLL for SIT from a model that contains a cmex function.
To tell whether the issue is caused by SIT or not, you can try changing the RTW target file from nidll.tlc to grt.tlc (in the model's Simulation Parameters dialog, look in the Real-Time Workshop tab), and see whether the compile error still happens. If the compiler error occurs with grt.tlc, then please refer to the documentation provided by The MathWorks Inc. on how to get your cmex functions to work in Real-Time Workshop®.
If the compiler error does not occur with grt.tlc, then please post the whole text of the compiler error.
Thanks!
Andrew -
[SIT 5.0] Problem with running Simulink model dll on RT target
Hello!
This a continuation of my problem described here: http://forums.ni.com/ni/board/message?board.id=170&thread.id=431616
At the moment I am using following versions of software:
LabVIEW 8.6.1
LabVIEW Real-Time 8.6.1
NI-RIO 3.1.0
Simulation Interface Toolkit 5.0.0
Microsoft Visual C++ 6.0
MATLAB 7.4.0 (R2007a)
NI cRIO-9014
I have done everything mentioned in http://digital.natinst.com/public.nsf/$CXIV/ATTACH-AEEE-7JSQXS/$FILE/readme_sit_vxworks.txt
After that I was able to build nidll and nidll_vxworks using Matlab. Then I have configured SIT Connection manager, mapped controls and indicators, selected model dll etc. But when I have tried to deploy it on RT target I got following error message:
Initializing...
Calculating dependencies...
Checking items for conflicts. This operation could take a while...
Preparing items for download. This operation could take a while...
Deploying NI_SIT_Replay.lvlib
Deploying NI_SIT_driversupportVIs.lvlib
Deploying NI_SIT_ClientConnMngr.lvlib
Deploying NI_FileType.lvlib
Deploying NI_SIT_Data Log.lvlib
Deploying XDNodeRunTimeDep.lvlib
Deploying NI_SIT_util.lvlib
Deploying NI_SIT_SITServer.lvlib
Deploying project01_Driver.lvproj
Deploying NI-cRIO9014-00E9D6B1(successfully deployed target settings)
Deploying MD5Checksum pad.vi(8,86 K)
Deploying NI_SIT_Replay.lvlib:Read Select Data Packet FIFO.vi(24,89 K)
Deploying NI_SIT_driversupportVIs.lvlibIT Driver FP Strings.vi(2,39 K)
Deploying NI_SIT_Data Log.lvlib:Allocate Data Log State Machine Buffers.vi(10,17 K)
Deploying compatWriteText.vi(9,04 K)
Deploying NI_SIT_Replay.lvlib:Wait for Ack.vi(5,29 K)
Deploying NI_SIT_SITServer.lvlibITs Read Data Buffer.vi(20,24 K)
Deploying NI_SIT_ClientConnMngr.lvlib:Find Channel.vi(8,23 K)
Deploying NI_SIT_Data Log.lvlib:Get Current Configuration from Queue.vi(9,46 K)
Deploying NI_SIT_Data Log.lvlibend New Group Probe List.vi(5,82 K)
Deploying NI_SIT_Replay.lvlib:Write to Active FIFO.vi(8,71 K)
Deploying NI_SIT_Replay.lvlib:Create Configuration FIFO.vi(6,29 K)
Deploying NI_SIT_driversupportVIs.lvlib:sit Microsecond Timer.vi(9,62 K)
Deploying NI_SIT_Data Log.lvlib:Get All Configurations from Queue.vi(9,30 K)
Deploying NI_SIT_Data Log.lvlibwitch Active Configuration.vi(9,77 K)
Deploying NI_SIT_Data Log.lvlib:Update Current Configuration Log Filename.vi(8,85 K)
Deploying NI_SIT_SITServer.lvlibITs Send Packet.vi(26,80 K)
Deploying Invalid Config Data Reference.vi(2,86 K)
Deploying NI_SIT_driversupportVIs.lvlibIT Set Project Directory Path.vi(16,94 K)
Deploying NI_SIT_Replay.lvlib:Update TCL Position FIFO.vi(16,39 K)
Deploying XDNodeRunTimeDep.lvlib:loadlvalarms.vi(32,39 K)
Deploying NI_SIT_driversupportVIs.lvlibIT Task Loop.vi
Failed to download NI_SIT_driversupportVIs.lvlibIT Task Loop.vi
LabVIEW: Failed to load shared library SITs.*:TaskTakeOneStep:C on RT target device.
Deployment completed with errors
I was hoping that upgrading my software will fix all problems. But sadly, it didn't. Any idea? Many thanks for help!Hello,
I also had quite a lot of problems using Labview 8.6.1, RT and SIT 5.0.1. I upgraded a software using Labview 7.1 and SIT 2.0.3 beeing used for 5 years now and it was real pain.
I not using the SIT as you are (just load the model from a DLL, use a timeloop to step the model and finally close the model) but it seems that SIT 5.0.1 has a bug (confirmed recently by NI tech support) concerning inputs and outputs if you are using an array.
It seems that if you use an array for the input during the transcoding of the simulink model to the DLL an index is not well taken into account resulting in a model not beeing able to read its intputs. In my case whatever the inputs data could be the outputs were always 0.
The model has been changed to use only scalar data and everything works fine, ... well using the developpement software :
I cannot generate an RT target executable as during the deployment it fails all the time.
I saw once a message concerning SIT VIs deployment errors and it happened shortly after i upgraded my target : SIT 2.0.3 was still installed after SIT 5.0.
I spent a few years without updating Labview and i am amazed at how many problems occurs with all versions above 8.0.
Good luck, -
Aufruf des FPGA Konfiguration von Matlab/Simulink
Hallo ,
ich versuche gerade ein HIL zu testen mit NI Hardware PXI und FPGA , weiss jemand ob es möglich auf die Konfiguration des PXI mittel Matlab/Simulink zugreifen , so zu sagen ob ich kann die Funktionalität des FPGA oder CAN Karte als blockset in Simulink/Matlab statt in Labview aufrufen. Mein Arbeitsgeber will gerne, dass die ganze Fonktionalitäten als blockset wie zum beispiel unter dspace in Simulink/Matlab aufrufen kann.
Ich bedanke mich sehr für die Information
befaizHello First thanks for your answer and your interest, I try to explain what i want to realize. I have a Model in Simulink, I can this Model connect in LabVIEW with simulation interface toolkit, and with SIT Connection manager the hardware I/O as Model I/O configure.
I would like to make the I/O interfaces of a FPGA 7813R PXI system from Simulink accessible. Similarly as with dSPACE RTI block, I can access the I/O from Simulink means over S Function Block. for example Analog Input.
Also I want to define the I/O of the Model as FPGA I/O in Simulink and then can I build the ModelDLL in Matlab and in SIT download. finally run the Model-simulation on RT Target.
I think, we need access to the visa server. I am on the search for this concept.
Perhaps you or someone can support me.
My Regards and thanks
HooSSa
Maybe you are looking for
-
WIndows 8.1 64bit, Windows Installers stalls with any install, updates or third party programs. Third party program installations work if I restart in safe mode. Updates don't as they cannot be installed in safe mode and require normal mode. Been hap
-
All my icons have turned brighter?!??
Hello, All my icons, in Icon view, have become lighter, and I have no idea why. The text below the icons is still the same brightness level, as is the desktop backgrounds, it's only the icons that are lighter. The only icons that have not changed are
-
Hi Is it possible find out the no of curretly active sessions in portal. I tried the following query : SELECT * FROM WWCTX_SSO_SESSION$ WHERE ACTIVE=1 AND TO_CHAR(LAST_UPDATED,'DD-MON-YY') = TRUNC(SYSDATE); This does not give the correct status. For
-
Crystal Reports 2013 on SAP BW
Hi Gurus, We are trying to establish connection between Crystal Reports 2013 and SAP BW 7.4. Could you please let us know whether we can create Crystal Reports on following BW objects or not? -BW BEx Reports -BW Cubes -BW DSOs -BW Master data Info Ob
-
Sound issue with my msi 880gm-e41 mainboard
please help me to solve the problem as follows----------i have 5.1 speaker system and the sound is good at a medium sound range from my pc sound control,but when i increase the sound the song tends to stop and play randomly,i dont have such type of p