Site Tools


howto:ni-pci-6503:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

howto:ni-pci-6503:start [2018/11/27 03:07]
sjdavies created
howto:ni-pci-6503:start [2018/11/27 04:15] (current)
sjdavies
Line 1: Line 1:
 ====== National Instruments PCI-6503 DAQ Board ====== ====== National Instruments PCI-6503 DAQ Board ======
 +
 +Found this [[http://​www.ni.com/​pdf/​manuals/​374938b.pdf|PCI board]] installed in one of the unused PC towers.
 +It provides 24 pins of digital IO. Pins operate at 5 volt levels.
  
 {{:​howto:​ni-pci-6503.jpg?​200|}} {{:​howto:​ni-pci-6503.jpg?​200|}}
-Created Nov 2018 by Stephen Davies. 
  
 +The National Instruments documentation only mentions support for a Windows driver. Further investigation reveals that Linux supports the board out of the box (Ubuntu 16.04) using the [[http://​www.comedi.org/​|comedi]] driver. Whilst the device drivers are installed by default, the client libraries are not. If you want to program the board you will need to install the libcomedi0 and libcomedi-dev packages.
 +
 +The comedy driver installs device support under /dev. When I tried **/​dev/​comedi0** was present.
 +
 +<code c>
 +#include <​stdio.h>​
 +#include <​comedilib.h>​
 +
 +int main(void)
 +{
 +        comedi_t *cdev;
 +        int      rc;
 +
 +        cdev = comedi_open("/​dev/​comedi0"​);​
 +        if (!cdev) {
 +                comedi_perror("​comedi_open"​);​
 +                return -1;
 +        }
 +
 +        // All pins as outputs
 +        for (int i = 0; i < 24; i++) {
 +                rc = comedi_dio_config(cdev,​ 0, i, COMEDI_OUTPUT);​
 +                if (rc) {
 +                        comedi_perror("​comedi_dio_config"​);​
 +                        return -1;
 +                }
 +        }
 +
 +        // Write to PA0 and PA1
 +        comedi_dio_write(cdev,​ 0, 0, 0);
 +        comedi_dio_write(cdev,​ 0, 1, 1);
 +
 +        return 0;
 +}
 +</​code>​
 +
 +Compile your code:
 +<code bash>gcc -Wall foo.c -L/usr/lib -lcomedi -o foo</​code>​
 +
 +Run your code:
 +<code bash>​sudo ./​foo</​code>​
 +
 +Created Nov 2018 by Stephen Davies.
howto/ni-pci-6503/start.txt ยท Last modified: 2018/11/27 04:15 by sjdavies