Logo Banner

Velleman K8000 - [Serial K8000]

Serial controller for the Velleman K8000


I recently designed my own RS-232 computer interface: a circuit with digital outputs that ca, be controlled with a simple program. This circuit uses shift registers to control the outputs.

I now redesigned the circuit to make it work with the Velleman K8000 card: The microcontroller now outputs I2C signals instead of controlling signals for shift registers. This circuit can be used to control the Velleman K8000 over a serial port, rather than a parallel port. In a way the circuit acts as a basic RS-232 to I2C converter.

I won't explain this project in detail, because the project is very similar to the RS-232 computer interface. Please see that project for a complete description of the circuit.


This project is only a basic RS-232 to I2C converter: it can only control (all) the digital outputs of the K8000 card. It is not possible to control the analog outputs. Neither is it possible to read back any information from the K8000.

This circuit must be connected to the screw terminal connector at the side of the K8000 board. This means there is no optical isolation between the RS-232 interface and the K8000. In the future I will explain how you could use the K8000's optocouplers to isolate this circuit from the outputs of the K8000.

The PIC circuit

The circuit is based on a PIC 16F628A. This PIC has a hardware USART. It doesn't have a build-in I2C port, it is easy enough to program your own I2C controller. The image below shows the complete circuit. You can also download it as a PDF.

The circuit has its own power supply, based on the 7805 regulator, to generate a stable 5 VDC voltage. You could eliminate this supply by connecting this circuit to the +5V output of the Velleman K8000.

The MAX232 IC will convert the serial signals (+/- 9 V) to TTL signals (0/5 V). The surrounding capacitors acts as a charge pump: they allow the MAX232 to generate voltages above the +5V supply voltage.

The PIC16F628A is controlled by a fast 19.6608 MHz crystal. I have chosen this value because it is a perfect match for a 9600 baud communication, the communication speed between the computer and this circuit.

The connector J1 outputs the I2C signals (SCL, SDA and the GND). I didn't place pull-up resistors (required for I2C to work properly) because the K8000 board has them already. You will need to place them if you want to control your own I2C circuit.

The firmware

The firmware is very similar to the firmware I wrote for my other RS-232 interface. I only replaced the code for the shift registers by I2C code.

I also defined an array with the I2C addresses. They contain the I2C write addresses for all I/O chips on the four possible K8000 cards. The program will lookup the corresponding I2C address from this table.

    char i2cAddresses[]={0x70,0x72,0x74,0x76,0x78,0x7A,0x7C,0x7E};

The code below is the complete firmware for this project. It was written in High-Tech C.

The computer software

The computer software is written in Visual Basic .NET. The software is almost identical to the software I wrote for my other RS-232 interface project.

You can select 1 to 4 K8000 cards. After creating the connection a checkbox for each I/O output will appear. The state of the output will be changed as soon as you click one of the checkboxes. You could change all outputs simultaneous by clicking one of the buttons at the bottom of the screen.

The software creates a connection with the COM port by using standard Visual Basic code. No special drivers are required. (besides maybe the driver for your USB to RS/232 adaptor, if you are using one).

The software doesn't control individual ports on the K8000: instead it sends a request frame with the desired state of each output channel. So it always updates all of the output channels.

Sample basic code

The following code demonstrates how easy it is to control your K8000 from a Visual Basic program. You only need to add the BVInterface class to your project. Then you could use the following code to control a single K8000 card. This example will clear all outputs, and then set the outputs one by one. Each time a 100 ms delay occurs.

    Dim myInterface As New BVinterface()

    With myInterface
        .comPort = "COM1"  		' use COM1
        .shiftRegisters = 2 		' use 2 IO chips (16 outputs)
        .sendImmediately = True		' send each command immediately
        .shiftBitOneFirst = True
        .shiftByteOneFirst = True				

        If .connect() Then
            .clearAllOutputs()  ' clear all outputs
            ' run toggling function
            For cnt As Integer = 1 To 16
        End If
    End With		


Click the following button to download a ZIP containing all project files: the Visual Basic .NET source files and the high-tech C files with the PIC's firmware.

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