Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL...
-
Upload
walter-sparks -
Category
Documents
-
view
214 -
download
0
Transcript of Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL...
![Page 1: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/1.jpg)
Interfacing Embedded System with Computer Software Using VB.net
Presented by :- Sulaiman Salim AL Habsi
![Page 2: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/2.jpg)
Why VB.NET ????????
• New implementation of classic VB on .NET framework .
• Object Oriented Programming Language .• Very close to human language .• Not case sensitive . • Easier Graphical User Interface (GUI).
![Page 3: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/3.jpg)
Data types and Declaration
• int Integer • string String • double Double • char Char • bool Boolean• Dim [variable name] As [data type].• Do not use semicolon !!!!! .
![Page 4: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/4.jpg)
Function and Loops
• While loop
• Do While (condition)• - statement • Loop
• Do Until (condition)• -statement • loop
![Page 5: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/5.jpg)
Functions and loops
• For loop
• For [variable name]=init To [max]• -statement • Next• For each (google)
![Page 6: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/6.jpg)
Function
• Public Sub functionName(ByRef f As Integer)
• End Sub
![Page 7: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/7.jpg)
Function
• Public Function R_function(ByVal h As String) As String
• Return "String"• End Function
![Page 8: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/8.jpg)
DLL
• Use ready code • Intermediate language for all .NET frame work• Add to the project • Import to the class
![Page 9: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/9.jpg)
URL request
• URL request are used request a html document from a web server .
• If you are behind a web proxy you’ll need to but proxy setting .
![Page 10: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/10.jpg)
How to make a URL requist
• Imports System.Net• Imports System.IO• New webClient • New stream = webClient.OpenRead• New StreamReader(stream)• While Not isr.EndOfStream• str += isr.ReadLine()• End While
![Page 11: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/11.jpg)
Proxy setting
• New NetworkCredential(“username", “pass", “domain")
• New WebProxy(“proxyserver", port)• proxy.Credentials = cr• Dim stoper As Boolean = True• proxy.BypassProxyOnLocal = True
![Page 12: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/12.jpg)
Thread
• Thread: making the program doing more than one task at the same time .
• Some object already have threads • VB does not allow accessing thread form an
other thread . We need an other solution • Timer is on of the solution of the problem • If your thread task is done then you cant
start the thread again
![Page 13: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/13.jpg)
How to create a thread
• Imports Threading ‘ outside the class• Dim myThread As Thread • myThread = new Thead(addressOf myInfitTask)• myThread.start()
![Page 14: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/14.jpg)
Example
• Make a http request to Google web site .• 1- display full html in a text field • 2- display the head tag only .• 3- make a other button to request SQU web
site in the same time .• 4- modify the code in 3 so you use less
redundancy .
![Page 15: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/15.jpg)
Serial communication in ES
• Atmel AVR microcontrollers
![Page 16: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/16.jpg)
Serial communication
• Send bits in serial • Less wiring and asynchronous and synchronous • Baud rate is number of bits per second
=(F_CPU/16*baud)-1• voltage level in microcontroller is different
from computer (use Max232).
![Page 17: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/17.jpg)
![Page 18: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/18.jpg)
RCX: Data receive completeUDRE:Ready for transitionU2X : double the transition baud rate
RXEN: Enable Receive DataTXEN: Enable Transmit Data
UCPOL: Using the USART as synchronous or a synchronous UCSZ0/1:select the Size Of data(5,6,7,8)bitsUSBS: number of stop bit UPM0/1:parity (none, odd , even)UMSEL /URSEL : put to Zero.
UBRR : set baud rateUDR : transmit receive data
![Page 19: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/19.jpg)
![Page 20: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/20.jpg)
Serial port object
• Imports system.io.ports• Define connection configurations • Using with • Read the buffer using timer • Change the ports form the system • Some GSM modems use virtual serial port• Using AT command to control GSM Modem• You can put some of the configuration during the
creation of the object.
![Page 21: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/21.jpg)
Create and configure serial port
• Imports System.IO.Ports• Dim serialport As new SerialPort• With serialport • .PortName = “COM1"• .BaudRate = 9600• .StopBits = StopBits.One• .DataBits = 8• .Parity = Parity.None• .Open()• End With
![Page 22: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/22.jpg)
example
• Write a program in VB.net that receive a message (number from a web server and display it in a BCD 7 segments in the testing board) use the URL (http://172.22.13.12/embedded)
![Page 23: Interfacing Embedded System with Computer Software Using VB.net Presented by :- Sulaiman Salim AL Habsi.](https://reader034.fdocuments.in/reader034/viewer/2022051619/56649da15503460f94a8d713/html5/thumbnails/23.jpg)
If you are enemy of Proprietary software
• You can use shell script to access your computer hard ware and web servers .
• You can user javacomm library to access you computer hard ware and make URL request .
• You can follow the new project www.mono-project.com/.• Or any other Opensource languages like python .• You can use a GSM/GPRS modem to direct access the
internet with out the need for computer.• Smart phone already have application to handle web
events and send notifications