Download presentation
Presentation is loading. Please wait.
Published byBrenda Montgomery Modified over 9 years ago
1
PROGRAMMING LANGUAGES FINAL PROJECT FATIH SÜRER 2010514060 Serial Communication with MSP430
2
SERıAL COMMUNıCATıON 1) Serial communication is common method of transmitting data between a computer and a peripheral device such as a programmable instrument or even another computer. 2) Serial communication transmits data one bit at a time, sequentially, over a single communication line to a receiver. Serial communication used by many devices for instrumentation; numerous GPIB-compatible devices also come with an RS-232 based port. This method is used when data transfer rates are very low or the data must be transferred over long distances 3) Serial communication is popular because most computers have one or more serial ports, so no extra hardware is needed other than a cable to connect the instrument to the computer or two computers together.
3
HOW DOES SERıAL COMMUNıCATON WORKS Serial communication requires that you specify the following five parameters: 1) The speed or baud rate of the transmission 2) The number of data bits encoding a character 3) The sense of the optional parity bit (whether to be used or not, if yes then odd or even) 4) The number of stop bits 5) Full or half-duplex operation
4
SERıAL COMMUNıCATıON STANDARTS 1) RS-232 // Msp430 includes RS-232 2) RS-423 3) RS-485 4) USB 5) Fire Wire 6) Ethernet 7) MIDI 8) PCI Express 9) SPI & SCI 10) IIC 11) IrDA
5
EQUıPMENT LıST MSP430 Launchpad Developement Kit 5V Power Module HC-SR04 Ultrasonic sensor Light Emitting Diode (LED) Breadboard USB 2.0 Connection Cable Jumper Cable
7
PROGRAM OUTPUT
8
CODE AREA using System.IO.Ports; // For create serial port object serialport = new SerialPort(); // For creating serial port serialport.BaudRate = 9600; // BaudRate serialport.PortName = ‘’COM5’’; // Port Name if (!serialport.IsOpen){ serialport.Open(); } //Open Serial Port if it does not. serialport.ReadExisting() // Reads all immediately available bytes string bright = trackBar1.Value.ToString(); // geting tracbar value as a string progressBar1.Value = Convert.ToInt16(bright); // progress bar value changes by changing trackbar serialport.Write(bright); // send bright bits via serial port System.Threading.Thread.Sleep(100); // system waits 100 milisecond label5.Text = DateTime.Now.ToLongDateString(); // System Date label12.Text = DateTime.Now.ToLongTimeString(); // System Clock
9
textBox5.ForeColor = Color.Red // changes textbox color timer1Start(); // starts the timer timer3.Stop(); // stops the timer comboBox1.Items.Add("COM1"); // add COM1 item into combobox comboBox1.Text = comboBox1.Items[4].ToString(); // Show 5th item button2.Visible = false; // button2 get invisible button4.Enabled = false; // buton4 now enable timer4.Interval = 1000; // timer wait 1000 milisecond System.Diagnostics.Process.Start("devmgmt.msc"); // Open Device Menagement Environment.NewLine // add a new line in MessageBox switch (MessageBox.Show("Are you sure that you want to exit this program ? ", "Are you sure ? ",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question)) { case DialogResult.Yes: Close(); break; } // if user click yes button application will shut down. CODE AREA
10
REFERENCES http://msdn.microsoft.com/en-us/library/system.io.ports.serialport(vs.90) http://msdn.microsoft.com/en-us/library/system.io.ports.serialport(vs.90) http://stackoverflow.com/questions/7740458/extract-the-date-part- from-datetime-in-c-sharp http://stackoverflow.com/questions/7740458/extract-the-date-part- from-datetime-in-c-sharp http://www.dotnetperls.com/messagebox-show http://www.dotnetperls.com/messagebox-show http://stackoverflow.com/questions/12073703/call-tick-event-when- timer-starts http://stackoverflow.com/questions/12073703/call-tick-event-when- timer-starts http://stackoverflow.com/questions/2256909/messagebox-with- yesnocancel-no-cancel-triggers-same-event http://stackoverflow.com/questions/2256909/messagebox-with- yesnocancel-no-cancel-triggers-same-event
11
ANY QUESTıONS ?
12
Thanks for listening me carrefully.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.