Pages

Tuesday, 3 March 2015

Integrating C#.NET with Embedded System:chapter-2


DATA TYPES AND VERIABLES

“Variables” are simply storage locations for data. You can place data into them and retrieve their contents as part of a C# expression. The interpretation of the data in a variable is controlled through “Types”.

The C# simple types consist of:

·         Boolean type
·         Numeric types: Integrals, Floating Point, Decimal
·         String type

BOOLEAN TYPES

Boolean types are declared using the keyword “bool”. They have two values: “true” or “false”. In other languages, such as C and C++, boolean conditions can be satisfied where 0 means false and anything else means true. However, in C# the only values that satisfy a boolean condition is true and false
 Example:
         bool content = true; bool  
         noContent=false ;

Numeric types: Integrals, Floating Point, Decimal

Example:int i=35;
                long y=654654;
                float x;
                decimal z;


String type
            Example: string myString=”Hai everyone”;

Special characters that may be used in strings:
  


Arrays             
          Example:   int[] myInts = { 5, 10, 15 };

Control Flow
To be able to control the flow in your program is important in every programming language.
 
The two most important techniques are:
        The if Statement
        The switch Statement 



The if Statement 
The if statement is probably the most used mechanism to control the flow in your application. An if statement allows you to take different paths of logic, depending on a given condition. When the condition evaluates to a Boolean true, a block of code for that true condition will execute. You have the option of a single if statement, multiple else if statements, and an optional else statement. 


Example:
      myTest=false;
 if (myTest==false)
  {
    essageBox.Show("Hello”);
  } 


output:
 For more complex logic we use the if … else statement.

Example:
               bool myTest;
               myTest=true;
               if (myTest == false)
               {
                  MessageBox.Show("Hello1");
                }
      else
               {
                        MessageBox.Show("Hello2");
                } 


Or you can use nested if… else if sentences.

 Example:
         int myTest;
         myTest=2;
         if (myTest == 1)
    {
       MessageBox.Show("Hello1");
     }
    else if (myTest == 2)
     {
         MessageBox.Show("Hello2");
      }
else
     {
        MessageBox.Show("Hello3");
     } 




The switch Statement

Another form of selection statement is the switch statement, which executes a set of logic depending on the value of a given parameter. The types of the values a switch statement operates on can be booleans, enums, integral types, and strings.
 example:

           switch (myTest)
     {
        case 
             1:MessageBox.Show("Hello1");break;
       case
            2:MessageBox.Show("Hello2");break;
       default:MessageBox.Show("Hello”);break;
}

 




       
 
 

 
 
   

 


   

 

 

     
 

Integrating C# .NET with Embedded System:Chapter-1

OVERVIEW

C# is a modern, general-purpose, object-oriented programming language developed by Microsoft and approved by Ecma and ISO.C# was developed by Anders Hejlsberg and his team during the development of .Net Framework.


C# is designed for Common Language Infrastructure (CLI), which consists of the executable code and runtime environment that allows use of various high-level languages to be used on different computer platforms and architectures.



The following reasons make C# a widely used professional language:


·         Modern, general-purpose programming language.

·         Object oriented.

·         Component oriented.

·         Easy to learn.

·         Structured language.

·         It produces efficient programs.

·         It can be compiled on a variety of computer platforms.


·         Part of .Net Framework.

Getting started

Creating a new visual studio C# project:
Once Visual Studio is running the first step is to create a new project. Do this by selecting New Project from the File menu. This will cause the New Project window to appear containing a range of different types of project. For the purposes of this tutorial we will be developing a Windows Forms Application so make sure that this option is selected.

CREATING NEW PROJECT

The first thing you do when you want to create a new application is to create a NEW PROJECT.

This can be done from start page.

New project created from the NEW PROJECT window:

Then the “NEW PROJECT” window will appear.

In this window you will select an appropriate template based on what kind of application you want to create, and a name and location for your project and solution.


The most common applications are:
  •        Windows form application.
  •        Console application.
  •      WPF application
  •       ASP.NET web application.
  •      Silverlight application. 
Select WINDOWS FORMS APPLICATION.

TOOL BOX

When you select WINDOWS FORM APPLICATION, you will get FORM DESIGN WINDOW,it is used to design USER interface by making use of TOOLBOX on the left side of window,

The TOOLBOX contains all the necessary controls, etc. You need to create a user interface by making use of these controls as shown in figure below.



In order to use these controls, just drag and drop it on to your Design forms, as shown in figure.



Figure shows TOOLBOX and DESIGN FORM:


The following screenshot shows, making use of these toolbox controls for designing the user interface on DESIGN FORM.




PROPERTIES WINDOW


Each TOOLBOX we have used on our form has many properties that we can set. This is done by using Properties window. We can find the property window on the right bottom side of your project.


BUILD AND DEBUGGING TOOL

The visual studio has lots of Build and Debugging Tools,


BUILD MENU:


Below we see the Build menu. The most used Build tool is BUILD SOLUTIONS.


DEBUG MENU:


In order to RUN or DEBUG your windows form we make use of DEBUG TOOLs. The most used debug tool is START DEBUGGING.it can be find the shortcut for this on the top of your visual studio windows.      



                                                                                                                                                                                                     

Windows programming


When creating ordinary windows form application, we can select between the following:



·         Windows form Application

·         WPF application




HELLO WORLD


We start by creating traditional “HELLO WORLD” application using Windows Form Application is shown below. Thevisual studio UI shown below.



In this application we make use of simple textbox and Button(Button name is changed to Submit in the properties) when we click on submit the “HELLO WORLD ”massage will be displayed in the Textbox.

The OUTPUT  of this form as shown below:
THE CODE IS AS FOLLOW:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication9
{
publicpartialclassForm1 : Form
    {
public Form1()
        {
            InitializeComponent();
        }

privatevoid textBox1_TextChanged(object sender, EventArgs e)
        {

        }

privatevoid button1_Click(object sender, EventArgs e)
        {
            textBox1.Text = "HELLO WORLD";//displaying hello worldin the textbox.
        }
    }
}




ATMEL Mini Development Board


OVERVIEW:

If you are learning microcontrollers or want to quickly develop embedded solution based on standard 8051 core, this board will help you quick start with the application by giving you access to everything required to run the AT89S52 microcontroller. With this board you can develop and prototype with any of 8051 40 pin microcontrollers.The board have User buttons and status LEDs.



FEATURES OF PRODUCT:
  • Quartz crystall 11.0592Mhz.
  • The DIP40 locking device, easy to remove the ATMEL microcontroller for reuse.
  • Reset button.
  • Power Indicating LED.
  • External TX,RX, GND
  • Pull up resistor for PORT0.
  • On board ISP programmer.
  • Coour :RED
For more Sample codes and schematics: CLICK HERE

Monday, 2 March 2015

PIC Mini Development Board


OVERVIEW:

PICs are popular with both industrial developers and hobbyists alike due to their low cost, wide availability, large user base, extensive collection of application notes, availability of low cost or free development tools, and serial programming (and re-programming with flash memory) capability. They are also commonly used in educational programming .
With this board you can develop and prototype with any of Microchip's 40 pin PIC microcontrollers.The board have User button and status LED.


FEATURES OF THE PRODUCT: 
  • PIC Development Board for Microchip PIC Series.
  • Quartz crystall 20Mhz.
  • The DIP40 locking device, easy to remove the PIC microcontroller for reuse.
  • External TX,RX, GND
  • On board programming ISP.
  • Power indicator LED.
  • Reset Switch for the IC.
  • Colour :RED
  • High quality PCB FR4 Grade with FPT Certified.
For More Sample codes and Schematic: CLICK HERE