]> rtime.felk.cvut.cz Git - mf6xx.git/blob - src/HuLinux-2.4.3/samples/CounterIn/CtrRead.c
8352bb3c4ba738aadee4d07982e1105f514e8e21
[mf6xx.git] / src / HuLinux-2.4.3 / samples / CounterIn / CtrRead.c
1 /* Humusoft data acquisition library.\r
2  *\r
3  * Example that shows reading of counters and counting pulses.\r
4  */\r
5 \r
6 /* Copyright 2002-2006 Humusoft s.r.o. */\r
7 \r
8 #include <stdio.h>\r
9 \r
10 #include "hudaqlib.h"\r
11 \r
12 \r
13 int main(int argc, char* argv[])\r
14 {\r
15         HUDAQHANDLE h;\r
16         unsigned i;\r
17         int value;\r
18 \r
19         /* open a handle to the first MF624 device in the system */\r
20         h = HudaqOpenDevice("MF624", 1, 0);\r
21         if (h==0)\r
22         {\r
23                 printf("\nData acquisition device not found.\n");\r
24                 return(-1);\r
25         }\r
26 \r
27         /* Do reset of counters. Each counter is switched to counting mode\r
28            after its first usage. */\r
29         for (i=0; i<4; i++)\r
30         {\r
31                 HudaqCtrReset(h,i);\r
32         }\r
33 \r
34         printf("Counting external pulses by counters, press Enter to continue.\n", i, value);\r
35         getchar();\r
36 \r
37         /* read all the 4 counters in a loop, print their values */\r
38         for (i=0; i<4; i++)\r
39         {\r
40                 value = HudaqCtrRead(h,i);\r
41                 printf("Counter channel %d, value read %d.\n", i, value);\r
42         }\r
43 \r
44         /* close the device handle */\r
45         HudaqCloseDevice(h);\r
46 \r
47         return(0);\r
48 }\r
49 \r