About
minilab is a Ruby library for Measurement Computing’s miniLAB 1008 device. The minilab library provides a simple interface to several of the miniLAB 1008’s analog and digital IO functions. I’ve used the miniLAB to control the input and examine the output from our embedded devices; the minilab library allowed us to use automated system testing tools for Ruby.
minilab does not work with other Measurement Computing devices, but could be extended to do so.
Ruby 1.9
The minilab gem now requires Ruby 1.9 to run. The gem is built to run on the RubyInstaller package. minilab’s public interface has not changed as part of the Ruby 1.9 migration.
If you’re looking for Ruby 1.8 support, try using the 1.1.0 version of the gem. The code is available in the git repository via the v1.1.0 tag.
Installation
-
Install the minilab gem onto your system or unpack it into a local directory in your project. Install Measurement Computing’s Universal Library and InstaCal software; both come on CDs with the device.
-
Plug in the device and then fire up the InstaCal software. Go to Install -> Configure in the menus and the Custom Serial Number to 253, No. of Channels to 8 Single Ended, and Trigger Source to DIO0. Use the Flash LED button to ensure that InstaCal can communicate with the device (I’ve never had a problem with this). Although I don’t think the Custom Serial Number and Trigger Source make much difference to my library, the No. of Channels is important (see Known limitations below).
-
That should be it—you should now be able to require ‘minilab’, create a minilab object, and connect to it. If you can’t, please contact me! I’ve only installed this on a limited number of computers, so I’d like to hear about problems with the library installation, gem installation, LOAD_PATH, etc.
Usage
Build and connect
First you’ll need to build the Minilab object; use the Minilab.build
method to do this. The method is important to use instead of new
, since it takes care of a lot of behind-the-scenes object construction for you.
After building the object, use the connect
method. This will establish the connection to the library. None of the other methods will work until you connect.
Example:
minilab = Minilab.build
minilab.connect
Reading and writing data
I’ve created methods for reading and writing both digital and analog data from the device. Analog data goes through the read and write pins on the top of the device; no configuration is needed for the analog methods.
Digital data goes through either the DIO pins on the top of the device or the digital ports on the DB37 port. If you’re using the DIO pins, then you don’t need to do any configuration. If you’re using the DB37 pins, then you’ll need to configure the appropriate port for input and output. You can find a mapping of DB37 pin numbers to ports either in Measurement Computing’s miniLAB 1008 data sheet or at the end of this README.
Check out the read and write analog and read, write, and configure digital methods in the Minilab document for more information.
Example:
minilab.configure_input_port(:portb)
value = minilab.read_digital_byte(:portb)
assert_equal 12, value, "wrong value read for system time"
The adventurous may also want to look at the included acceptance tests for the device, since they are examples of how to use the device and are not contrived.
Tests
The minilab library comes with unit and acceptance tests. The unit tests stress individual units and can run without any hardware plugged in. The acceptance tests represent real use cases for the software when plugged into hardware.
See the end of this document for an outline of how a miniLAB and DB37 connector should be set up in order to run the system tests.
Known limitations
-
Ruby 1.8 is no longer supported.
-
The minilab library only supports one device plugged in at a time. I could add support for multiple devices, but since I only have one, I haven’t bothered adding support for more than one.
-
I never got around to writing out an entire digital byte because I never needed it.
-
Reading analog values only supports single-ended mode. As you can probably guess, I didn’t need differential mode, so I didn’t add support for it.
Contact information
-
Matt Fletcher ([email protected])
-
Atomic Object (atomicobject.com)
Appendix
DB37 pin to port mapping
- Pin
-
Port
- 30-37
-
:porta
- 3-10
-
:portb
- 26-29
-
:portcl
- 22-25
-
:portch
Acceptance test setup
On top of the miniLAB:
- CH0 IN
-
D/A OUT 1
- CH1 IN
-
GND
- CH2 IN
-
DIO0
- CH4 IN
-
PC 5V
- CH6 IN
-
D/A OUT 0
- DIO0
-
DIO3
- DIO1
-
PC 5V
- DIO2
-
GND
On the DB37 pins:
- 3
-
11
- 4
-
11
- 5
-
28
- 6
-
11
- 7
-
36
- 8
-
11
- 9
-
11
- 10
-
20
- 22
-
27
- 23
-
21
- 24
-
34
- 25
-
21
- 30
-
21