Pages

Thursday, 9 July 2015

INTEGRATED EMBEDDED SYSTEM WITH Vb.Net- Chapter 4

GSM INTERFACE






There are many different kinds of applications SMS applications in the market today, and many others are being developed. Applications in which SMS messaging can be utilized are virtually unlimited. Some common examples of these are given below:
  • Person-to-person text messaging is the most commonly used SMS application, and it is what the SMS technology was originally designed for.
  • Many content providers make use of SMS text messages to send information such as news, weather report, and financial data to their subscribers.
  • SMS messages can carry binary data, and so SMS can be used as the transport medium of wireless downloads. Objects such as ringtones, wallpapers, pictures, and operator logos can be encoded in SMS messages.
  • SMS is a very suitable technology for delivering alerts and notifications of important events.
  • SMS messaging can be used as a marketing tool.
In general, there are two ways to send SMS messages from a computer / PC to a mobile phone:
  1. Connect a mobile phone or GSM/GPRS modem to a computer / PC. Then use the computer / PC and AT commands to instruct the mobile phone or GSM/GPRS modem to send SMS messages.
  2. Connect the computer / PC to the SMS center (SMSC) or SMS gateway of a wireless carrier or SMS service provider. Then send SMS messages using a protocol / interface supported by the SMSC or SMS gateway

AT Commands

AT commands are instructions used to control a modem. AT is the abbreviation of ATtention. Every command line starts with "AT" or "at". That's why modem commands are called AT commands. There are two types of AT commands:
1.       Basic commands are AT commands that do not start with a "+". For example, D (Dial), A (Answer), H (Hook control), and O (Return to online data state) are the basic commands.
2.       Extended commands are AT commands that start with a "+". All GSM AT commands are extended commands. For example, +CMGS (Send SMS message), +CMGL (List SMS messages), and +CMGR (Read SMS messages) are extended commands.

The FORM DESIGN as show below, Here we using combo box for port selection  and textbox for entering mobile number to send sms,and message field to type message and send button.




The complete code as given below, Here we have to create two class 1)sms ,2)program
The class sms will set all pre-requirements in order to send sms,and port values and program class will load the forms and this will initiate the application.

Imports System.Data.SqlClient
Imports System.Net.Sockets
Imports System.Text
 Public Class Form1

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        If SerialPort1.IsOpen Then
            SerialPort1.Close()
        End If

        Try
            With SerialPort1
                .PortName = "COM11"
                .BaudRate = 9600
                .Parity = IO.Ports.Parity.None
                .DataBits = 8
                .StopBits = IO.Ports.StopBits.One
                .Handshake = IO.Ports.Handshake.None
                .NewLine = vbCrLf
                .RtsEnable = True
                .RtsEnable = True
            End With
            SerialPort1.Open()
            SerialPort1.WriteLine("at+cmgf=1" & vbCrLf)
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try



    End Sub


Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim Num as Integer
Dim Msg as String
Num=TexBox1.text
Msg=TexBox2.text
Send_sms(Num,Msg)

End Sub

Sub send_sms(ByVal Cont_no As String, ByVal acc_details As String)
        Dim Mobile = Cont_no
        Dim message = acc_details
        SerialPort1.WriteLine("at+cmgd=1" & vbCrLf)
        Sleep(1000)
        Dim a As String
        a = "at+cmgs=""+91" & Mobile & """"
        SerialPort1.WriteLine(a & vbCrLf)
        Sleep(1000)
        SerialPort1.WriteLine(message & Chr(26))
    End Sub

End Class

INTEGRATED EMBEDDED SYSTEM WITH Vb.Net- Chapter 3



FT245 RELAY CONTROLLER








relay is an electrically operated switch. Many relays use an electromagnet to mechanically operate a switch, but other operating principles are also used, such as solid-state relays. Relays are used where it is necessary to control a circuit by a low-power signal (with complete electrical isolation between control and controlled circuits), or where several circuits must be controlled by one signal. The first relays were used in long distance telegraph circuits as amplifiers: they repeated the signal coming in from one circuit and re-transmitted it on another circuit. Relays were used extensively in telephone exchanges and early computers to perform logical operations.

Here we are making use of 4 channel relay to controlling it, The following picture show the design part of it, in this we have used one combo box for reading com port and open button to open the selected port, and DATA text box, this is for entering manually which relay should turn on suppose if you enter ‘ff’ it will turn on relay1.


The complete source code for controlling 4/8 channel relay.
Imports System.Data.SqlClient
Imports System.Net.Sockets
Imports System.Text

Public Class Form1

Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label11.Text = "Hi" + " " + Form2.TextBox1.Text + " , " + "Welcome you to PSA"
        user = Form2.TextBox1.Text


        total = 0
        k = 0
        If SerialPort1.IsOpen Then
            SerialPort1.Close()
        End If
        Try
            With SerialPort1
                .PortName = "COM5"
                .BaudRate = 9600
                .Parity = IO.Ports.Parity.None
                .DataBits = 8
                .StopBits = IO.Ports.StopBits.One
                .Handshake = IO.Ports.Handshake.None
            End With
            SerialPort1.Open()

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try


    End Sub         


       Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
                      If SerialPort1.IsOpen Then
            SerialPort1.Close()
        End If
            SerialPort1.Open()


              Button2.Enabled = true
              Button3.Enabled = true
              Button4.Enabled = true
              Button5.Enabled = true
              Button6.Enabled = true
              Button7.Enabled = true
              Button8.Enabled = true
              Button9.Enabled = true
              Button10.Enabled = true
       End Sub


Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button1.Click       
         
SerialPort1.WriteLine(TextBox1.Text);
       
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button1.Click       
            SerialPort1.WriteLine ("02");
       
End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button1.Click       
           SerialPort1.WriteLine ("00");
        End Sub


Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button1.Click 
          SerialPort1.WriteLine ("08");
        End Sub


Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button1.Click       
            SerialPort1.WriteLine ("00");
        End Sub


Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button1.Click       
            SerialPort1.WriteLine ("20");
        End Sub


Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button1.Click       
        SerialPort1.WriteLine ("00");
        End Sub



Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button1.Click
       
SerialPort1.WriteLine ("80");
        End Sub


Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button1.Click       
SerialPort1.WriteLine ("00");
        End Sub

    End Class