Skip to content
ggodart edited this page Jan 4, 2021 · 1 revision

K8055 Interface Board

What it is

The K8055 is a kit based, USB interface board from Velleman that provides:

  • 5 digital inputs (2 have automated counters with modifiable debounce timers)
  • 2 analogue inputs (0-5 V) with op-amps
  • 8 digital outputs
  • 2 analogue outputs (0-5 V) and PWM outputs (0-100% duty cycle at 5 V)

Support for this board is available in CVS or version 2.102 and above.

Details

Support for the K8055 is implemented as a client interface to a daemon. Code for the daemon is included in mh/code/public/k8055d.tar.bz2.

Run perldoc K8055.pm in mh/lib to get more info about the interface itself.

The code is designed to automatically (every 10 seconds by default) read a subset of all the input ports. In other words, asking for the current state of digital port 1 actually returns the last retrieved value of digital port 1, it doesn't ask the board at that point in time. You can call K8055->update() to get the code to immediately request new values, however this will still happen asynchronously, so it is not guaranteed that the next call to read values includes the updated value.

You need to tell K8055 which ports to get values for. If you don't, no values will be retrieved, either on the 10 second schedule or on a manual update call. If the value of a monitored port changes, the value of K8055->state_now will be set to the name of the port (i.e. "digital 1" if digital port 1 goes from 0 to 1 or from 1 to 0).

There is a basic web interface in mh/web/bin/k8055.pl that relies on $k8055 being a K8055 object, created somewhere in your user code.

Sample Code

use K8055;
$k8055 = new K8055;

$k8055->tie_event('&k8055_updated($state)');

if ($Reload) {
  # we want to retrieve values for digital port 1 and analogue port 2
  k8055->doUpdateDigital(1);
  k8055->doUpdateAnalogue(2);
}

sub k8055_updated {
  my ($state)=@_;

  speak ("port $state just changed");
}

$v_show_k8055 = new Voice_Cmd("show k8055");

if ($state = $v_show_k8055->said) {
  my $response;
  $response = "digital 1 is ".$k8055->readDigital(1)."\n";
  $response .= "analogue 2 is ".$k8055->readAnalogue(2)."\n";
  respond(text=>$response);
}

Links

Clone this wiki locally