Programming A Computer Application For A Control System Using Velleman, VM110 Kit
Programming A Computer Application For A Control System Using Velleman, VM110 Kit
BY
E.OUN,ABDULHAMID
Experiment Objective:
In general, this experiment aims to give the student a sufficient ability start a programming
“Visual programming” ,and control systems using a VM110N kit. After completing this experiment
,student will gain an experience for reading data, processing, and outputting control signal. i.e. the
student will dominate the whole control circle.
Introduction
Control, is a term used in everything around, in which it become the key of any industrial
process. Most mechanical machines and electronic devices needs a large processing , which is not
enough to use microcontroller. This aids to use a computer (PC) for control the system using
software.
There for to be able to control any such system (open loop control system/ closed loop system ) you
have to interconnect the system to a PC. In which another trouble you are going to face. VM110N is
the solution for this. The Velleman VM110N USB experiment interface board has the following inputs
and outputs:
• 5 digital inputs (with test buttons provided on the boards)
• 2 analog inputs (with test potentiometers provided on the board)
• 8 digital outputs (with LED indicators provided on the board)
• 2 analog outputs (as voltage signals and as PWM, with LED indicators provided on
the board)
Velleman VM110N
The Velleman VM110N USB experiment interface board has the following inputs and outputs:
• 5 digital inputs (with test buttons provided on the boards)
• 2 analog inputs (with test potentiometers provided on the board)
• 8 digital outputs (with LED indicators provided on the board)
• 2 analog outputs(as voltage signals and as PWM, with LED indicators provided on the board)
In addition the board contains two 16-bit counters triggered by inputs I1 and I2 (the debouncing
control is provided). The detailed description of the board can be found, for instance, at
www.velleman.be. It is readily available from distributors in many parts of the world, either as the
K8055 kit for assembly yourself, or as the assembled VM110 module.
Experiment equipment :
* hardware
1- VM110N kit.
2- Power supply unit 5V, 15V.
3- bipolar stepper motor kit (SCHRIT MOTOR S04000-2C.
4- power connection cable.
6- logic probe for signal logic test.
7- Personal computer (windows XP service back 3 /windows 7 ).
8- LM35 temperature sensor
9-12vdc relay
* software
1- Visual studio 2010 package
2- K8055_dll file
Experiment procedure :
Step by step learn how to make your own first visual C# program
3- Add two checkboxes, buttons, and one label to the form as in figure below.
* these component used to open connection between your software and KIT.
4- for the textbox and label change their name and text to be identical , also do the same for the
button .remember names cant accept space .
5- write click on the form and choose "view code" . then add the following lines to the code as in figure
below :
using System.Runtime.InteropServices;
[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 ClearDigitalChannel(int Channel);
[DllImport("k8055d.dll")]
public static extern void SetDigitalChannel(int Channel);
[DllImport("k8055d.dll")]
public static extern void ClearAllDigital();
[DllImport("k8055d.dll")]
public static extern void SetAllDigital();
[DllImport("k8055d.dll")]
public static extern bool ReadDigitalChannel(int Channel);
* for more function refer to the appendix
6 - Go back to the form , then Duble click on 'CONNECT' and write the following code between the two
Brackets.
if (CONNECT.Text == "CONNECT")
{ int CardAddr = 3 - (Convert.ToInt32(SK5.Checked) +
Convert.ToInt32(SK6.Checked) * 2);
int h = OpenDevice(CardAddr);
switch (h)
{ case 0 : CONNECT.Text = "DISCONNECT";
STATUS.Text = " CARD "+ h.ToString()+" IS CONNECTED";
break;
case 1 :CONNECT.Text = "DISCONNECT";
STATUS.Text = " CARD "+ h.ToString()+" IS CONNECTED";
break;
case 2 :CONNECT.Text = "DISCONNECT";
STATUS.Text = " CARD "+ h.ToString()+" IS CONNECTED";
break;
case 3: CONNECT.Text = "DISCONNECT";
STATUS.Text = " CARD "+ h.ToString()+" IS CONNECTED";
break;
default: CONNECT.Text = "CONNECT";
STATUS.Text = " CARD "+ h.ToString()+" IS NOT CONNECTED";
break;
}
}
else
{ CONNECT.Text = "CONNECT";
CloseDevice();
STATUS.Text = "CARD DISCONNECTED";
}
7- Before debugging above steps copy the following file K8055D.DLL to the Windows' System32'
folder. In 64-bit environment the file must be copied to Windows' SysWOW64 folder.
12- double click on SHR_LIGHT , then write the following code between brackets
SHL_LIGHT.Checked = false;
SHL_T1.Enabled = false; // TIMER 1 TIME INTERVAL
timer1.Enabled = false;
blink_T3.Enabled = false; // TIMER 3 TIME INTERVAL
timer3.Enabled = false;
if(SHL_LIGHT.Checked==true)
{ timer1.Interval = Convert.ToInt32(SHL_T1.Text);
timer1.Enabled = true;
}
else if (SHR_LIGHT.Checked == true)
{
timer2.Interval = Convert.ToInt32(SHR_T2.Text);
timer2.Enabled = true;
}
else
{
// no shift write no left just blinking ( ON/OFF) based on timer 3
timer1.Enabled = false;
timer2.Enabled = false;
timer3.Interval = Convert.ToInt32(blink_T3.Text);
timer3.Enabled = true;
}
}
else
{
START_LED_OUT.Text = "START LED OUT";
ClearAllDigital();
timer1.Enabled = false;
timer2.Enabled = false;
timer3.Enabled = false;
}
14- to do a shift left for the 8 output digital channel each time, once the timer 1 tick ( i.e after the time
interval pass) , it will execute the following code .
double click on "timer1" the write the following code between the brackets.
bool ch_bre;
{ // to do Left shift for the checkbox based on the original value
ch_bre = Convert.ToBoolean(DIG_CH8.CheckState);
DIG_CH8.Checked = Convert.ToBoolean(DIG_CH7.CheckState);
DIG_CH7.Checked = Convert.ToBoolean(DIG_CH6.CheckState);
DIG_CH6.Checked = Convert.ToBoolean(DIG_CH5.CheckState);
DIG_CH5.Checked = Convert.ToBoolean(DIG_CH4.CheckState);
DIG_CH4.Checked = Convert.ToBoolean(DIG_CH3.CheckState);
DIG_CH3.Checked = Convert.ToBoolean(DIG_CH2.CheckState);
DIG_CH2.Checked = Convert.ToBoolean(DIG_CH1.CheckState);
DIG_CH1.Checked = ch_bre;
// to set the digital channel or clear it based on the corresponding checkbox
if (DIG_CH1.Checked == true) SetDigitalChannel(1);
else ClearDigitalChannel(1);
if (DIG_CH2.Checked == true) SetDigitalChannel(2);
else ClearDigitalChannel(2);
if (DIG_CH3.Checked == true) SetDigitalChannel(3);
else ClearDigitalChannel(3);
if (DIG_CH4.Checked == true) SetDigitalChannel(4);
else ClearDigitalChannel(4);
if (DIG_CH5.Checked == true) SetDigitalChannel(5);
else ClearDigitalChannel(5);
if (DIG_CH6.Checked == true) SetDigitalChannel(6);
else ClearDigitalChannel(6);
if (DIG_CH7.Checked == true) SetDigitalChannel(7);
else ClearDigitalChannel(7);
if (DIG_CH8.Checked == true) SetDigitalChannel(8);
else ClearDigitalChannel(8);
15- same as previous step , to do right shift one step after time interval of timer 2 is passing.
16- last step for illumination of eight LED is to blinking these LED based on the status of corresponding
checkbox (true , false) without shifting.
* do it at home as homework.
* By the above step you should become familiar with visual C# design as beginners .
23 - connect wires 8 LED to the kit ( 8 output digital channel ) ,as in figure below
alarm , Fan , and Ac are working with AC power 220V .Therefore we are going to use relay SRU-12VDC SL-C
, until can turn it ON/OFF .
have a look to the design below , and the circuit , and your responsibility is to write the appropriate code.
LAB QUIESTION
1- Provide at least three other control application that can be controlled via VM110N kit
2- design an application that read analog value from a input device such as sensor and gain that
signal to the double and send it to the one of the analog output channel .
Report:
Each student should submit a report within a 3 week, the report should include the answer to lab
questions and questions, summary of observations of the lab-work; importance and use of
experiment ; conclusion and discussion.