]> rtime.felk.cvut.cz Git - mf6xx.git/blob - src/HuLinux-2.4.3/samples/EncoderIn/EncRead.c
Added a few comments. Cleaned coding style.
[mf6xx.git] / src / HuLinux-2.4.3 / samples / EncoderIn / EncRead.c
1 /* Humusoft data acquisition library.\r
2  *\r
3  * Example that shows decoding IRC position \r
4  * using the function to read a single encoder.\r
5  */\r
6 \r
7 /* Copyright 2002-2006 Humusoft s.r.o. */\r
8 \r
9 #include <stdio.h>\r
10 \r
11 #include "hudaqlib.h"\r
12 \r
13 \r
14 int main(int argc, char* argv[])\r
15 {\r
16         HUDAQHANDLE h;\r
17         unsigned i;\r
18         int value;\r
19 \r
20         /* open a handle to the first MF624 device in the system */\r
21         h = HudaqOpenDevice("MF624", 1, 0);\r
22         if (h==0)\r
23         {\r
24                 printf("\nData acquisition device not found.\n");\r
25                 return(-1);\r
26         }\r
27 \r
28         printf("Counting external IRC pulses by encoders, press Enter to continue.\n");\r
29         getchar();\r
30 \r
31         /* Read all the 4 encoder values in a loop, print them. */\r
32         for (i=0; i<4; i++)\r
33         {\r
34                 value = HudaqEncRead(h,i);\r
35                 printf("Encoder channel %d, value read %d.\n", i, value);\r
36         }\r
37 \r
38         /* Close the device handle. */\r
39         HudaqCloseDevice(h);\r
40 \r
41         return(0);\r
42 }\r
43 \r