Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling Counter Timer of PCI6259 from Matlab

Hi,

 

My Name is Abtin, Im from Germany and i Hope my English is good enough to discribe my Problem. Im using a PCI 6259 Card, and I want to set the general Purpose Counter and Timer from Matlab. But I still dont manage it. have sombody experience with this card and could help me. Im really in trouble i hope somebody answere....

I want to set the Timer as output and use it for triggerung. But how can i access to the Counter??? I dont find no example for Matlab.

 

Regrads,
Abtin

0 Kudos
Message 1 of 7
(5,956 Views)

Hello Abtin,

 

since you are from Germany i may as well continue in German. NI Hardware kann von Matlab aus mittels der Toolbox angesprochen werden. Unter folgenden Link findet sich eine Kompatibilitätsliste:

 

http://www.mathworks.com/products/daq/supportedio14005.html 

 

Dort findet sich auch folgender Hinweis:

 

"Note: Data Acquisition Toolbox supports voltage measurements on analog input and analog output subsystems. On digital I/O, it provides static acquisition and control. If using specialized analog measurement capabilities (such as thermocouple CJC compensation and IEPE excitation), hardware clocked digital I/O, or the counter/timer subsystem are valuable to you, please let us know by completing the form at the bottom of this page"

 

Nach meinem Wissensstand unterstüzt Mathworks die Counter Funktionen lediglich für einige E-Serien Karten und noch nicht für M-Serien Karten.

Ein Beispeil für MIO Karten unter Matlab findet sich unter folgendem Link:

 

http://webscripts.softpedia.com/script/Scientific-Engineering-Ruby/Test-and-Measurement/Counter-Example-36128.html 

 

Um die Counterfunktionalität der Karte dennoch nutzen zu können, ist es möglich die DAQmx Treiber dlls auch direkt aufzurufen. 

Um dazu eine Hilfestellung zu erhalten währe es sinnvoll bei der Installation des DAQmx Treibers die C-Unterstützung zu aktivieren. Dadurch werden sowohl die C Beispiele als auch die Hilfe zu den DAQmx Funktionen installiert. Unter "Start>Programme>National Instruments>NI DAQ>NI DAQmx C Reference Help" kann die Hilfe aufgerufen werden. Sie ist als Basis für die dll Aufrufe in Matlab zu sehen. 

 

Viele Grüsse

Wetzer 

 

0 Kudos
Message 2 of 7
(5,946 Views)

Vielen dank für die Antwort. ich werde mir gleich die Links anschauen. Ich bin auch schon dabei mich mit der C-Funktion zu beschäftigen. Ich denke auch dass eine dll in C zu schrieben und dann in Matlab mit der mex funktion einzubinden, die beste lösung ist. Wenn das funktioniert werde ich es hier im Tread veröffentlichen falls einer vor der gleichen Frage steht. Ich danke dir nochmals für die Mühe und einen schönen Abend noch.

 

0 Kudos
Message 3 of 7
(5,941 Views)

hello abtin--i've been able to read the counter using the c function

DAQmxReadCounterScalarU32.  i've followed the outline

from http://forums.ni.com/ni/board/message?board.id=250&message.id=10165

in order to establish contact between the 6259 and matlab.  but i

haven't yet been able to set up a 'pause trigger' which would

enable me to gate the counters with a window instead of

reading them on an edge.  have you had any luck with that?

sid gulick

0 Kudos
Message 4 of 7
(5,901 Views)

Hi,

 

Its very funny i find the same website and beginn to write my Programm from the same example. I will try to set the Pausetrigger and if I succes I send you my Programm. maybe i can help you. But i will chek it on Thursday, and i try to answere you on the same day.  

My this helps you, my first programm dosnt work becouse i use a wrong taskhandle. Did you get any Errorcode? Maybe that help you??? If you have Errorcode look in the header-File to see the discription.... 

0 Kudos
Message 5 of 7
(5,897 Views)
hello abtin--

i've managed to write a small matlab routine which does what i want although i'm not certain the timing is really

rocksolid and i haven't taken account of possible sticks which can be thrown in the spokes.

i use the 'nidaq' adaptor from the matlab data acquisition toolbox to set up an analog output and

analog input task, and the c library function calls to access the counter.  i set up a pause trigger

for the counter and a dummy analog input to receive a trigger in order to locate the counter in

time.  my program outputs a dc voltage, enters an interior loop in which it reads the counter

20 times and resets it after reading it, and then exits to an exterior loop which increments

the dc voltage 10 times.  i think i've attached my 'm' file if it's any use to someone with a similar

problem.  i'll try to improve the timing--i'm not sure whether the delay between the analog

in trigger and the counter gate is just a fortuitous coincidence of hardware and software or

whether there's really a constant time between the call to the ai read and the call to the

counter read. 

0 Kudos
Message 6 of 7
(5,864 Views)

Thank you very much for your example. I still have some problems with the Loadlibrary command. Sometimes i get a mistake and sometimes it works???? I  find out that i have to load the libery at first. If I start the programm and a function load the libery somewhere in beetween i get an error and doesnt work. If the loadibery is the first command it works. Strange i dont know why. is it ab bug of R2007a??????

And if it is the first command, although it works, I get some errors, but i can continue working with it, and the libery is loadet. Why does it crat errors although it works?????

0 Kudos
Message 7 of 7
(5,861 Views)