Logo Banner

Velleman K8055 - [K8055 Hardware Tutorial]

K8055 Hardware Tutorial: Digital Inputs

Digital Inputs

The Velleman K8055 has five digital inputs. These kind of inputs can only handle two different states: ON or OFF ("1" or "0"). They are ideal to read the state of switches, ...

Using the digital inputs

Using the digital inputs is quite easy: you only need to create a connection between the I1...I5 and the GND. If they are connected the K8055 will read this as a "1". Otherwise it will read the input as a "0". So if you have switches you can just place them between the I1...I5 and the GND connections.

But sometimes it is more interesting to control the K8055's digital inputs with a control voltage: applying a certain voltage will read as a digital "1". If there is no voltage it reads as a digital "0". This can be done in many ways: by using a relay,transistor,FET,optocoupler,... In this tutorial I will show only one example: the optocoupler.

An optocoupler is an electronic component that contains an internal LED and a photo transistor. Both are electrically isolated, which is is interesting because this way the K8055 is protected against over voltages. You can compare the optocoupler with a switch: the switch is only closed when the internal LED is emitting. IOW: when there is a voltage at the inputs of the optocoupler.

The image below shows you the needed circuit for this. It is built around the 4N33 optocoupler. A control voltage is applied to the inputs 1 and 2, through the resistor R. This resistor is required to limit the current through the LED. Its value should be calculated as it depends on the input voltage you are planning to use. The value can be found with the aid of this formula:


The outputs of the circuit can be connected to one of the K8055's digital inputs: I1...I5. You need to connect the GND with the GND of the K8055. Of course, a separate optocoupler circuit is required for each of the digital inputs.

One thing to consider: the optocoupler is a semiconductor. You really need to watch the polarity of the input voltage (+/-). The optocoupler will not work if the polarity is wrong. A high inverse voltage can even destroy the optocoupler. You should ONLY apply DC (direct current) voltages to it.

How to program it?

The following sample program will read the value of the digital input #1 every 100 milliseconds. This value will be shown in the Form's title bar. The code is written for Visual Basic 2010. You need to create a new project with an empty form, called Form1. You don't need to place any components on the form but you do need to add my K8055 class to your project.

    Public Class Form1
      Dim myK8055 As New K8055()
      Dim WithEvents timer As New Windows.Forms.Timer
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        myK8055.connect(SK5:=False, SK6:=False)
        With timer
        .Enabled = True
        .Interval = 100
        End With
      End Sub
      Private Sub timer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles timer.Tick
        If myK8055.getDigitalInput(4) = True Then
        	Me.Text = "Channel 1 is ON"
        	Me.Text = "Channel 1 is OFF"
        End If
      End Sub
    End Class

The program creates an timer object. It will fire a timer.Tick event each 100 milliseconds. During this event the digital channel 4 is read. Its value will be shown in the title bar of the form.

Copyright ©1998-2022 Vanderhaegen Bart - last modified: August 24, 2013