]> rtime.felk.cvut.cz Git - mf6xx.git/blobdiff - src/HuLinux-2.4.3/samples/EncoderIn/EncConfig.c
Initial commit; HuLinux ver. 2.4.3; All files auto-indented
[mf6xx.git] / src / HuLinux-2.4.3 / samples / EncoderIn / EncConfig.c
diff --git a/src/HuLinux-2.4.3/samples/EncoderIn/EncConfig.c b/src/HuLinux-2.4.3/samples/EncoderIn/EncConfig.c
new file mode 100644 (file)
index 0000000..cdfbe95
--- /dev/null
@@ -0,0 +1,53 @@
+/* Humusoft data acquisition library.\r
+ *\r
+ * Example that shows configuration of\r
+ * encoder.\r
+ */\r
+\r
+/* Copyright 2002-2007 Humusoft s.r.o. */\r
+\r
+#include <stdio.h>\r
+\r
+#include "hudaqlib.h"\r
+\r
+\r
+int main(int argc, char* argv[])\r
+{\r
+       HUDAQHANDLE h;\r
+       int value;\r
+\r
+       /* open a handle to the first MF624 device in the system */\r
+       h = HudaqOpenDevice("MF624", 1, 0);\r
+       if (h==0)\r
+       {\r
+               printf("\nData acquisition device not found.\n");\r
+               return(-1);\r
+       }\r
+\r
+       /* Configure encoder to count input pulses. */  \r
+       if(HudaqSetParameter(h, 0, HudaqEncMODE, HudaqEncMODERISING) != HUDAQSUCCESS)\r
+       {\r
+               printf("\nCannot switch encoder to counting mode.\n");\r
+               HudaqCloseDevice(h);\r
+               return(-2);\r
+       }\r
+\r
+       /* Turn on hardware filter for input signal. */  \r
+       if(HudaqSetParameter(h, 0, HudaqEncFILTER, 1) != HUDAQSUCCESS)\r
+       {\r
+               printf("\nCannot filter input signal.\n");\r
+       }      \r
+\r
+       printf("Counting external pulses on input A by encoder, press Enter to continue.\n");\r
+       getchar();\r
+\r
+       /* Read encoder 0 value, print it. */\r
+       value = HudaqEncRead(h,0);\r
+       printf("Encoder channel 0, value read %d.\n", 0, value);\r
+\r
+       /* close the device handle */\r
+       HudaqCloseDevice(h);\r
+\r
+       return(0);\r
+}\r
+\r