Velleman K8055 C# test application

August 19th, 2009 by Dragos Leave a reply »

In my attempt to (re)learn electronics and PIC programming I’ve bought a K8055 board from Velleman. I know it’s not good to learn PIC (actually you can’t do it with this board) but all i want initially is to make some simple projects without the headache of  programming the PIC.

K8055

The board comes with source code for C++ and a DLL so you can use it in your project to easly communicate with the board. If you need the library for linux get it from here.

As my C++ skills are … well … let’s just say i haven’t programmed anything in C++ for a long time, I made myself a small program in C#.

In order to use the DLL in a C# project you must create a new class in order to declare it. You can achieve this by using [DllImport(“name.dlll”)].

Here is the C# class for K8055.dll

using System;
using System.Runtime.InteropServices;

public class K8055CSharp
{
    [DllImport("K8055D.dll")]
    public static extern int OpenDevice(int CardAddress);

    [DllImport("K8055D.dll")]
    public static extern void CloseDevice();

    [DllImport("K8055D.dll")]
    public static extern int ReadAnalogChannel(int Channel);

    [DllImport("K8055D.dll")]
    public static extern void ReadAllAnalog(int Data1, int Data2);

    [DllImport("K8055D.dll")]
    public static extern void OutputAnalogChannel(int Channel, int Data);

    [DllImport("K8055D.dll")]
    public static extern void OutputAllAnalog(int Data1, int Data2);

    [DllImport("K8055D.dll")]
    public static extern void ClearAnalogChannel(int Channel);

    [DllImport("K8055D.dll")]
    public static extern void SetAllAnalog();

    [DllImport("K8055D.dll")]
    public static extern void ClearAllAnalog();

    [DllImport("K8055D.dll")]
    public static extern void SetAnalogChannel(int Channel);

    [DllImport("K8055D.dll")]
    public static extern void WriteAllDigital(int Data);

    [DllImport("K8055D.dll")]
    public static extern void ClearDigitalChannel(int Channel);

    [DllImport("K8055D.dll")]
    public static extern void ClearAllDigital();

    [DllImport("K8055D.dll")]
    public static extern void SetDigitalChannel(int Channel);

    [DllImport("K8055D.dll")]
    public static extern void SetAllDigital();

    [DllImport("K8055D.dll")]
    public static extern bool ReadDigitalChannel(int Channel);

    [DllImport("K8055D.dll")]
    public static extern int ReadAllDigital();

    [DllImport("K8055D.dll")]
    public static extern int ReadCounter(int CounterNr);

    [DllImport("K8055D.dll")]
    public static extern void ResetCounter(int CounterNr);

    [DllImport("K8055D.dll")]
    public static extern int SetCounterDebounceTime(int CounterNr, int DebounceTime);
}

Compile it or add the project to your main application solution and you can use it in the same way you would use the unmanaged DLL

K8055CSharp.OpenDevice(0); // open the device (SK5 and SK6 jumpers are on)
K8055CSharp.SetAllDigital(); // set all digital outputs
K8055CSharp.CloseDevice(); // close the device

I also created some custom user controls.

Here are some screen shots from my application.

Download this application from here (version 1.0.0.2) (installer & C# source code)

Have fun with this application !

VN:F [1.9.22_1171]
Rating: 9.7/10 (6 votes cast)
Velleman K8055 C# test application, 9.7 out of 10 based on 6 ratings
Advertisement

4 comments

  1. Dragos says:

    Please check out other post for a newer version

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  2. edouard says:

    hello i’m student french,
    i like your programme it’s verry good !
    but i want to add a line in the two page .. for effect light witch a LED…

    because this is my “passtime” .. http://www.youtube.com/watch?v=PtIef-M7pIA

    me, i have making the man blue .. and i want to created my system ….

    thanck you very mutch
    and sorry for the Faults 🙂

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • Dragos says:

      I am sorry Edouard, but i can not understand what you want. please try to make it a little bit clearer.

      VN:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  3. edouard says:

    hy
    i want to add line in the “square” page 2 of the software .. i want 30 line for make a best Lighting effects
    because 6 is very little
    that is practicable ?

    or change test 1 or 2 ….

    do you ave got understand ?
    i’m sorry

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)