0% found this document useful (0 votes)
140 views15 pages

Programming A Computer Application For A Control System Using Velleman, VM110 Kit

This document provides instructions for programming a computer application to control a system using a Velleman VM110 kit. The objective is to teach visual programming and control systems. The VM110N kit allows interfacing between a computer and control system via inputs like buttons, potentiometers and outputs like LEDs. The instructions provide a step-by-step process to create a visual C# program that can read sensor data, process it and output control signals to light LEDs on the kit in different patterns using timers.

Uploaded by

MohamedAlzarrugh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
140 views15 pages

Programming A Computer Application For A Control System Using Velleman, VM110 Kit

This document provides instructions for programming a computer application to control a system using a Velleman VM110 kit. The objective is to teach visual programming and control systems. The VM110N kit allows interfacing between a computer and control system via inputs like buttons, potentiometers and outputs like LEDs. The instructions provide a step-by-step process to create a visual C# program that can read sensor data, process it and output control signals to light LEDs on the kit in different patterns using timers.

Uploaded by

MohamedAlzarrugh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

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

1- Install a Microsoft visual studio 2010.


2- create a New C# project , then chose name for your project.

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.

* should now get connected with KIT.

part 1 :: illumination eight LED in different ways


8- add ten checkbox more plus one bottom ( names and text of each same ) as in figure below
9- add three comboBox , then change their names to SHL_T1 , SHr_T2, and blink_T3 . also add these value to
the comboBox " 500, 1000, 2000, 4000".after that add one button and change its name/text to " START
LED OUT".
* button name can't contain space , so add "_" => START_LED_OUT

10- Add three timers to the form as in figure below:


11- double click on SHL_LIGHT , then write the following code between brackets
SHR_LIGHT.Checked = false;
SHR_T2.Enabled = false; // TIMER 2 TIME INTERVAL
timer2.Enabled = false;
blink_T3.Enabled = false; // TIMER 3 TIME INTERVAL
timer3.Enabled = false;
the above lines used to disable SHR_LIGHT (checkbox),timer 2 , SHR_T2 ( combobox) ,
timer3 , and blink_T3 (combobox ).

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;

the above lines used to disable SHL_LIGHT (checkbox),timer 1 , SHL_T1 ( combobox) ,


timer3 , and blink_T3 (combobox ).
13- Double click on ' START LED OUT' then write the fowling code for these button between the Brackets.

if (START_LED_OUT.Text == "START LED OUT")


{
START_LED_OUT.Text = "STOP LED OUTP";

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.

17- Debug your code by pressing F5 key from keyboard


18- Now connect VM110N to your PC via USB port ,
19- On VM110N kit be sure that SK5 and SK6 jumper are installed ( in their place )
“ you can connect 4 different VM110N card through 4 USB port at the same time ,and control them using
one application just by changing jumper on the kit and SK5/SK6 checkBox.”
20-If there are errors , recheck you code to fix these error.
21- Press CONNECT bottom . must show the following text “Card 0 Connected “ on label
22- Repress DISCONNECT bottom (same button) . must show the following text “CARD DISCONNECTED “ on
label .

* 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

Part 2 : simple alarm system


the system reads the temperature using LM35 sensor ( 10mv/1 Celsius ) then through the one of
the analog input channel, your project has to read the value .
temperature = (value/51)/10
based on these temperature:
- alarm ( red light) must set to ON " via digital output channel 0" once the tempreture become greater
than 25 C
- FAN must set to ON "" via digital output channel 1" once the temperature become greater
than 30 C
-AIR CONDITION must set to ON " via digital output channel 3" once the temperature become greater
than 30 C.

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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy