DesignSpark Electrical Logolinkedin

Using the DrDAQ with a Raspberry Pi

Raspberry Pi and DrDAQ

The DrDAQ is a multifunction USB device that incorporates sensors for light, sound and temperature, supports external sensors including a pH electrode, and which has inputs and outputs that allow it to be used as a data logger, oscilloscope and signal generator. This post covers initial experiences using the DrDAQ with a Raspberry Pi and Debian Linux.

The manufacturers of the DrDAQ, Pico Technology, have made a beta version of a Linux/Raspberry Pi driver available via their Labs website. Installing this is as simple as downloading a compressed tar file and installing the two Debian packages it contains.

The default for many Linux devices is that only the root user can access them, and rather than running software as root it's recommended to create a rules file that will instruct udev to set the ownership of the DrDAQ device to a group to which you then add ordinary users. The driver comes provided with such a file, 95-pico.rules, and this can be copied to /etc/udev/rules.d. However, at the time of writing the file contained a small typo which prevented it from working and the single quotes around the word usb should be changed to double, such that the line in question reads:

SUBSYSTEMS=="usb", ATTRS{idVendor}=="0ce9", MODE="664", GROUP="pico"

Once this file is in place and correct it's necessary to force udev to reload its rules:

$ sudo udevadm control –reload-rules 

It will also be necessary to add users, e.g. the user pi, to the pico group as described in the rules file.

And to log out and back in again so that your account picks up the new group membership. If the DrDAQ was plugged in before udev reloaded its rules, it may also be necessary to unplug this and plug it back in.

Should any problems be experienced when it comes to running programs that access the DrDAQ, the supplied usbtest script can be used in debugging.

Using the example program

Example Program

The driver comes with an example program that can be used to test the DrDAQ and demonstrate its capabilities, and which may be useful for some simple applications. This is supplied as source code and can be compiled with the command:

$ gcc USBDrDAQcon.c -oUSBDrDAQcon -lUSBDrDAQ -lusb_pico-1.0

Upon executing the USBDrDAQcon binary we are then presented with a menu which allows us to, for example, take an ADC reading, read the status of digital inputs, set the signal generator waveform type and frequency etc. and set the colour of the RGB LED.

Writing software

DrDAQ with Green LED Lit

The USBDrDAQcon program also serves as an aid to writing new programs as the C source code is well commented and makes use of easy to understand functions. For example, in order to set the colour of the DrDAQ LED to green we simply need to call two functions:

UsbDrDaqEnableRGBLED(g_handle, (short)1);

UsbDrDaqSetRGBLED(g_handle, (unsigned short)0, (unsigned short)255, (unsigned short)0);

The first instructs the driver to enable the LED, and the second tells it to set the values for red, green and blue to 0, 255 and 0 respectively.

Conclusion

The Raspberry Pi and DrDAQ each pack a lot into a small package and seem like natural companions. And together they could be used as the basis for things such as a low cost web-enabled data logger, where data is stored locally, processed and then served over the network via a HTML interface or a HTTP API.

At this point it doesn't look as though there are any basic end user Linux applications available for the USB DrDAQ, such as an oscilloscope or signal generator. But now that Linux drivers are available for both x86 and ARM architectures it should only be a matter of time before these are developed.

Finally, an easy to use Python library would seem like an obvious thing to create, as the DrDAQ is clearly something that could — if it doesn't already — find much use in schools. In fact, it should be possible to kill two birds with one stone and create a Python library upon which platform independent GUI applications are then built using wxPython.

Andrew Back

Open source (hardware and software!) advocate, Treasurer and Director of the Free and Open Source Silicon Foundation, organiser of Wuthering Bytes technology festival and founder of the Open Source Hardware User Group.

Comments

0 Votes
phillmac

June 2, 2013 09:51

Why is 2 54" translated to 1.3mm with cumulitive errors when that is not the value , the whole world is metrc?