Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Ruby Wrapper for Vellman K8055 USB Experiment Interface

branch: master
README.textile

RubyK8055

This is a ruby wrapper for the ‘libk8055’ linux driver, found here: http://libk8055.sourceforge.net/
I highly recommend downloading and installing that driver first, and making sure that you can get your
K8055 board working under linux first.

Compiling and Installing

  • To compile the wrapper, you must have the ‘libusb’ (v 0.1.12 or lower) library installed, as well as ‘libusb-dev’
sudo apt-get install libusb-dev
ruby extconf.rb
make
make install
  • If you have the rspec gem installed, connect your K8055 and run the following, to test that the wrapper works with your K8055.
spec rubyk8055_spec.rb
  • Note: This will run live tests with your connected K8055 and make sure all the methods are doing what they are supposed to do.
  • Run the following to test that you can load the wrapper:
irb -r irb_test.rb
  • The wrapper can then be accessed via the ‘@r’ instance variable.

Usage

require 'rubyk8055'
include USB
r = RubyK8055.new

Methods (with required params)

Method Params Description
connect address=0 Connects to the K8055 board.
disconnect Terminates the current connection.
connected attr_accessor for @connected.
board_address attr_accessor for @board_address.
get_analog channel Returns the value of the specified analog input channel.
set_analog channel, value Sets the value of the specified analog output channel.
set_analog_max channel Sets the value of the specified analog output channel to max value (255).
set_analog_min channel Sets the value of the specified analog output channel to min value (0).
get_digital channel Returns the value of the specified digital input channel.
digital_on channel Sets the value of the specified digital output channel to true.
digital_off channel Sets the value of the specified digital output channel to false.
set_digital channel, value Sets the specified digital output channel to the given value.
write_all_digital value Writes all outputs at once with 1 byte (containing each output as 1 bit).
set_all_digital Sets all digital outputs to true.
clear_all_digital Sets all digital outputs to false.
set_all_analog Sets all analog outputs to true.
clear_all_analog Sets all analog outputs to false.
all_inputs Returns an array with the following values: [dinp1, dinp2, dinp3, dinp4, dinp5, ainp1, ainp2, ctr1, ctr2].
to_s Returns all inputs, formatted as a ‘;’ separated string.
read_counter counter_index Reads the value of the counter at the specified index.
reset_counter counter_index Resets the specified counter to 0.
set_debounce counter_index, time (ms) Sets debounce time for the specified counter.
Something went wrong with that request. Please try again.