Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

segmentation fault when calling gpctr function from matlab mex file

I am trying to write a simple mex file for square wave generation using counter1 of PCI-6035E. I am using matlab's native compiler to compile and link with the nidaq32 library, ver.6.9.3, with no errors. When the mex function is called from a matlab script, however, the program crashes at the first call, to reset the counter. (I can generate a square wave with the test panel.)
0 Kudos
Message 1 of 5
(3,725 Views)
Soman,

To better troubleshoot the issue, can you post your code? Also, any specific information you can give about errors you may be receiving would be much appreciated. Have a great day.
0 Kudos
Message 2 of 5
(3,725 Views)
Sorry for the delay in responding. I got caught up in other stuff. I am attaching my little program as requested. As you can see, I have just wrapped a mexFunction call round the example code for square wave generation. After I posted this, I tracked down a copy of BorlandC++, installed it on my computer and recompiled using that compiler and *b.* libraries. And would you know it, the program works. The question remains, though, why it doesn't work with Matlab's native lcc compiler. Plus, I have limited disk space, so if I can do without BorlandC, I can use the extra room. The runtime error was a Segmentation fault that I traced to the first call to GPCTR_Control.
0 Kudos
Message 3 of 5
(3,725 Views)
Soman,
After looking through the Data Acquisition Toolbox for MATLAB User Manual in depth, it seems that counter operations are not supported. However, analog and digital output are supported so if you want to use only MATLAB, try one of those methods. If the counter method is a must, you'll have to use another language that supports the counter functions such as your BorlandC++ method. Other supported languages include LabVIEW, LabWindows/CVI, and Visual Basic - just to name a few. Good luck with your application.
0 Kudos
Message 4 of 5
(3,725 Views)
Sarah,
Thanks for your time on this. I too couldn't find any direct Matlab commands for counter operations. I need the analog output channels for other purposes (controlling force and position of a lever arm), and digital I/O doesn't give me precise control of frequency. Hence the use of the counter. I suppose I must be satisfied with the non-Matlab-compiler solution. My diagnosis is that the nidaq32.lib is not quite compatible with Matlab's lcc. At least the cat got skinned, eh? Thanks once again for your help.
0 Kudos
Message 5 of 5
(3,725 Views)