Giao tiếp PC và ngoại vi qua cổng máy i1 potx

15 296 0
Giao tiếp PC và ngoại vi qua cổng máy i1 potx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Giao tiếp PC và ngoại vi qua cổng máy in Giao tiếp PC và ngoại vi qua cổng máy in - Mã nguồn (Code) - Sơ đồ mạch Chân Ký hiệu Vào/ra Chức năng 1 STROBE Ra Xung âm xác định máy tính đã gởi dữ liệu 2 D0 Ra Đường dữ liệu D0 3 D1 Ra Đường dữ liệu D1 4 D2 Ra Đường dữ liệu D2 5 D3 Ra Đường dữ liệu D3 6 D4 Ra Đường dữ liệu D4 7 D5 Ra Đường dữ liệu D5 8 D6 Ra Đường dữ liệu D6 9 D7 Ra Đường dữ liệu D7 10 ACK Vào 0: Tín hiệu xác nhận máy in đã in xong (Acknowledge) 11 BUSY Vào 1: Máy in bận 12 PE Vào 1: Hết giấy (Paper Empty) 13 SLCT Vào 1: Đã có máy in (Select) 14 AF Ra 0: Máy in xuống dòng tự động (Auto Feed) 15 ERROR Vào 0: Lỗi 16 INIT Ra 0: Khởi động máy in 17 SLCTIN Ra 0: Chọn máy in (Select In) 18-25 GND Nối đất Cổng máy in có địa chỉ cơ sở đối với máy tính là 378h hay 278h bao gồm 3 thanh ghi: thanh ghi dữ liệu, thanh ghi trạng thái (địa chỉ cơ sở + 1) và thanh ghi điều khiển (địa chỉ cơ sở + 2) Thanh ghi dữ liệu (378h, 278h) D7 D6 D5 D4 D3 D2 D1 D0 Thanh ghi trạng thái (379h, 279h) BUSY ACK PE SLCT ERROR IRQ - - Sơ đồ mạch thiết kế Thanh ghi điều khiển (37Ah, 27Ah) - - Direction IRQ Enable SLCTIN INIT AF STROBE Trong các chân của thanh ghi điều khiển và thanh ghi trạng thái, các chân SLCTIN, AF, STROBE sẽ bị đảo mức logic trước khi dưa ra ngoài còn chân BUSY cũng bị đảo mức trước khi đưa vào PC. Sơ đồ mạch thiết kế như sau: Tải về ảnh gốc Đọc dữ liệu từ ngoại vi Đoạn chương trình sau dùng để đọc từ thiết bị ngoại vi có địa chỉ 300h: ; Xuất 8 bit địa chỉ thấp MOV AL,00h MOV DX,378h OUT DX,AL MOV AL, 0Ah ; Xuất giá trị ra thanh ghi điều khiển để PC_CS2 = 0 MOV DX,37Ah ; SLCTIN = 0, INIT = 0, AF = 0, STROBE = 1 nên OUT DX,AL ; thanh ghi điều khiển = 0000 1010b = 0Ah (các bit SLCTIN, AF, STROBE bị đảo mức) MOV AL,00h ; Xuất giá trị ra thanh ghi điều khiển để PC_CS2 = 1 MOV DX,37Ah OUT DX,AL ; Xuất 8 bit địa chỉ cao MOV AL,03h MOV DX,378h OUT DX,AL MOV AL, 09h ; Xuất giá trị ra thanh ghi điều khiển để PC_CS3 = 0 MOV DX,37Ah ; SLCTIN = 0, INIT = 0, AF = 1, STROBE = 0 nên OUT DX,AL ; thanh ghi điều khiển = 0000 1001b = 09h MOV AL,00h ; Xuất giá trị ra thanh ghi điều khiển để PC_CS3 = 1 MOV DX,37Ah OUT DX,AL ; Chốt 8 bit dữ liệu đọc vào MOV AL, 0Eh ; Xuất giá trị ra thanh ghi điều khiển để PC_CS6 = 0 MOV DX,37Ah ; SLCTIN = 0, INIT = 1, AF = 0, STROBE = 1 nên OUT DX,AL ; thanh ghi điều khiển = 0000 1110b = 0Eh MOV AL,00h ; Xuất giá trị ra thanh ghi điều khiển để PC_CS6 = 1 MOV DX,37Ah OUT DX,AL ; Đọc 4 bit dữ liệu thấp MOV AL, 0Dh ; Xuất giá trị ra thanh ghi điều khiển để PC_CS7 = 0 MOV DX,37Ah ; SLCTIN = 0, INIT = 1, AF = 1, STROBE = 0 nên OUT DX,AL ; thanh ghi điều khiển = 0000 1101b = 0Dh MOV DX,379h ; Đọc 4 bit dữ liệu về IN AL,DX MOV AH,AL ; AH chứa 4 bit thấp nhưng giá trị trong thanh ghi MOV CL,4 ; trạng thái chứa ở 4 bit cao nên phải dịch phải SHR AH,CL ; Đọc 4 bit dữ liệu cao MOV AL,00h ; Xuất giá trị ra thanh ghi điều khiển để PC_CS7 = 1 MOV DX,37Ah OUT DX,AL MOV DX,379h ; Đọc 4 bit dữ liệu về IN AL,DX AND AL,0F0h ADD AL,AH ; AL chứa 8 bit dữ liệu Xuất dữ liệu ra ngoại vi Đoạn chương trình sau dùng để xuất dữ liệu ra thiết bị ngoại vi có địa chỉ 301h: PUSH AX ; Xuất 8 bit địa chỉ thấp MOV AL,01h MOV DX,378h OUT DX,AL MOV AL, 0Ah ; Xuất giá trị ra thanh ghi điều khiển để PC_CS2 = 0 MOV DX,37Ah ; SLCTIN = 0, INIT = 0, AF = 0, STROBE = 1 nên OUT DX,AL ; thanh ghi điều khiển = 0000 1010b = 0Ah (các bit SLCTIN, AF, STROBE bị đảo mức) MOV AL,00h ; Xuất giá trị ra thanh ghi điều khiển để PC_CS2 = 1 MOV DX,37Ah OUT DX,AL ; Xuất 8 bit địa chỉ cao MOV AL,03h MOV DX,378h OUT DX,AL MOV AL, 09h ; Xuất giá trị ra thanh ghi điều khiển để PC_CS3 = 0 MOV DX,37Ah ; SLCTIN = 0, INIT = 0, AF = 1, STROBE = 0 nên OUT DX,AL ; thanh ghi điều khiển = 0000 1001b = 09h MOV AL,00h ; Xuất giá trị ra thanh ghi điều khiển để PC_CS3 = 1 MOV DX,37Ah OUT DX,AL POP AX ; Xuất 8 bit dữ liệu ra MOV DX,378h OUT DX,AL MOV AL, 0Ch ; Xuất giá trị ra thanh ghi điều khiển để PC_CS8 = 0 MOV DX,37Ah ; SLCTIN = 0, INIT = 1, AF = 1, STROBE = 1 nên OUT DX,AL ; thanh ghi điều khiển = 0000 1100b = 0Ch MOV AL,00h ; Xuất giá trị ra thanh ghi điều khiển để PC_CS8 = 1 MOV DX,37Ah OUT DX,AL MOV AL, 0Bh ; Xuất giá trị ra thanh ghi điều khiển để PC_CS1 = 0 MOV DX,37Ah ; SLCTIN = 0, INIT = 0, AF = 0, STROBE = 0 nên OUT DX,AL ; thanh ghi điều khiển = 0000 1011b = 0Bh MOV AL,00h ; Xuất giá trị ra thanh ghi điều khiển để PC_CS1 = 1 MOV DX,37Ah OUT DX,AL Read more: http://www.ant7.com/forum/forum_post.asp?TID=1563#ixzz0dpMRAgyP Visual Basic cho Vi Điều Khiển About Visual Basic: Visual Basic (VB) is an event driven programming language and associated development environment from Microsoft for its COM programming model.[1] Visual Basic was derived from BASIC and enables the rapid application development (RAD) of graphical user interface (GUI) applications, access to databases using DAO, RDO, or ADO, and creation of ActiveX controls and objects. Scripting languages such as VBA and VBScript are syntactically similar to Visual Basic, but perform differently.[2] A programmer can put together an application using the components provided with Visual Basic itself. Programs written in Visual Basic can also use the Windows API, but doing so requires external function declarations. Language features Visual Basic was designed to be easy to learn and use. The language not only allows programmers to easily create simple GUI applications, but also has the flexibility to develop fairly complex applications as well. Programming in VB is a combination of visually arranging components or controls on a form, specifying attributes and actions of those components, and writing additional lines of code for more functionality. Since default attributes and actions are defined for the components, a simple program can be created without the programmer having to write many lines of code. Performance problems were experienced by earlier versions, but with faster computers and native code compilation this has become less of an issue. Although programs can be compiled into native code executables from version 5 onwards, they still require the presence of runtime libraries of approximately 2 MB in size. This runtime is included by default in Windows 2000 and later, but for earlier versions of Windows it must be distributed together with the executable. Forms are created using drag and drop techniques. A tool is used to place controls (e.g., text boxes, buttons, etc.) on the form (window). Controls have attributes and event handlers associated with them. Default values are provided when the control is created, but may be changed by the programmer. Many attribute values can be modified during run time based on user actions or changes in the environment, providing a dynamic application. For example, code can be inserted into the form resize event handler to reposition a control so that it remains centered on the form, expands to fill up the form, etc. By inserting code into the event handler for a keypress in a text box, the program can automatically translate the case of the text being entered, or even prevent certain characters from being inserted. Visual Basic can create executables (EXE files), ActiveX controls, DLL files, but is primarily used to develop Windows applications and to interface web database systems. Dialog boxes with less functionality (e.g., no maximize/minimize control) can be used to provide pop-up capabilities. Controls provide the basic functionality of the application, while programmers can insert additional logic within the appropriate event handlers. For example, a drop-down combination box will automatically display its list and allow the user to select any element. An event handler is called when an item is selected, which can then execute additional code created by the programmer to perform some action based on which element was selected, such as populating a related list. VB serial communication: This chapter discusses how Visual Basic can be used to access serial communication functions. Windows hides much of the complexity of serial communications and automatically puts any received characters in a receive buffer and characters sent into a transmission buffer. The receive buffer can be read by the program whenever it has time and the transmit buffer is emptied when it is free to send characters. Communications control Visual Basic allows many additional components to be added to the toolbox. The Microsoft Comm component is used to add a serial communication facility. In order to use the Comms component the files MSCOMM16.OCX (for a 16-bit module) or MSCOMM32.OCX (for a 32-bit module) must be present in the \WINDOWS\SYSTEM directory. The class name is MSComm. The communications control provides the following two ways for handling communications: Event-driven. Event-driven communications is the best method of handling serial communication as it frees the computer to do other things. The event can be defined as the reception of a character, a change in CD (carrier detect) or a change in RTS (request to send). The OnComm event can be used to capture these events. and also to detect communications errors. Polling. CommEvent properties can be tested to determine if an event or an error has occurred. For example, the program can loop waiting for a character to be received. Once it is the character is read from the receive buffer. This method is normally used when the program has time to poll the communications receiver or that a known response is imminent. Visual Basic uses the standard Windows drivers for the serial communication ports (such as serialui.dll and serial.vxd). The communication control is added to the application for each port. The parameters (such as the bit rate, parity, and so on) can be changed by selecting Control Panel ? System ? Device Manager ? Ports (COM and LPT) ? Port Settings. The settings of the communications port (the IRQ and the port address) can be changed by selecting Control Panel ? System ? Device Manager ? Ports (COM and LPT) ? Resources for IRQ and Addresses. Properties of Communication Port Control: The Comm component is added to a form whenever serial communications are required. By default, the first created object is named MSComm1 (the second is named MSComm2, and so on). It can be seen that the main properties of the object are: CommPort, DTREnable, EOFEnable, Handshaking, InBufferSize, Index, InputLen, InputMode, Left, Name, NullDiscard, OutBufferSize, ParityReplace, RThreshold, RTSEnable, Settings, SThreshold, Tag and Top. Settings The Settings property sets and returns the RS-232 parameters, such as baud rate, parity, the number of data bit, and the number of stop bits. Its syntax is: [form.]MSComm.Settings = setStr[$] where the strStr is a string which contains the RS-232 settings. This string takes the form: "BBBB,P,D,S" where BBBBdefines the baud rate, P the parity, D the number of data bits, and S the number of stop bits. The following lists the valid baud rates (default is 9600Baud): 110, 300, 600, 1200, 2400, 9600, 14400, 19200, 38400, 56000, 128000, 256000. The valid parity values are (default is N): E (Even), M (Mark), N (None), O (Odd), S (Space). The valid data bit values are (default is 8): 4, 5, 6, 7 or 8. The valid stop bit values are (default is 1). 1, 1.5 or 2. An example of setting a control port to 4800Baud, even parity, 7 data bits and 1 stop bit is: Com1.Settings = "4800,E,7,1" CommPort The CommPort property sets and returns the communication port number. Its syntax is: [form.]MSComm.CommPort = portNumber which defines the portNumber from a value between 1 and 99. A value of 68 is returnedif the port does not exist. PortOpen The PortOpen property sets and returns the state of the communications port. Its syntax is: [form.]MSComm.PortOpen = [{True | False}] A True setting opens the port, while a False closes the port and clears the receive andtransmit buffers (this automatically happens when an application is closed). The following example opens communications port number 1 (COM1:) at 4800 Baud with even parity, 7 data bits and 1 stop bit: Inputting data The three main properties used to read data from the receive buffer are Input, InBuffer Count and InBufferSize. Input The Input property returns and removes a string of characters from the receive buffer. Its syntax is: [form.]MSComm.Input To determine the number of characters in the buffer the InBufferCount property is tested (to be covered in the next section). Setting InputLen to 0 causes the Input property to read the entire contents of the receive buffer. InBufferSize The InBufferSize property sets and returns the maximum number of characters that can be received in the receive buffer (by default it is 1024 bytes). Its syntax is: [form.]MSCommInBufferSize = [numBytes%] The size of the buffer should be set so that it can store the maximum number of characters that will be received before the application program can read them from the buffer. The InBufferCount property returns the number of characters in the receive buffer. It can also be used to clear the buffer by setting the number of characters to 0. Its syntax is: [form.]MSCommInBufferCount= [count%] Outputting data The three main properties used to write data to the transmit buffer are Output, OutBufferCount and OutBufferSize. The Output property writes a string of characters to the transmit buffer. Its syntax is: [form.]MSComm. output= [outString$] OutBufferSize The OutBufferSize property sets and returns the number of characters in the transmit buffer (default size is 512 characters). Its syntax is: [form.]MSCommOutBuffer size = [NumBytes%] OutBufferCount The OutBufferCount property returns the number of characters in the transmit buffer.The transmit buffer can also be cleared by setting it to 0. Its syntax is: [form.]MSCommOutBufferCount. = [0] Basic Circuit Diagram for PC to Microcontroller Communication: Using the Serial Port 8051 provides a transmit channel and a receive channel of serial communication. The transmit data pin (TXD) is specified at P3.1, and the receive data pin (RXD) is at P3.0. The serial signals provided on these pins are TTL signal levels and must be boosted and inverted through a suitable converter(MAX232) to comply with RS232 standard. All modes are controlled through SCON, the Serial CONtrol register. The SCON bits are defined as SM0, SM1, SM2, REN, TB8, RB8, TI, RI from MSB to LSB. The timers are controlled using TMOD, the Timer MODe register, and TCON, the Timer CONtrol register. Sending Data From The PC to a Microcontroller: In this article we are going to learn how to send data to a microcontroller and make the microcontroller respond to the data. For simplicity we are just going to send data to turn on and off an LED which is connected at port P2.0. So lets start off with designing a communications protocol. From VB we will send an ASCII 255, as a synch byte, and the on/off state (0 or 1). The microcontroller will wait for two (2) bytes of data. After these two bytes of data are received, it will then either switch on/off the LED Visual Basic at PC side To get started open Visual Basic.  Start a new Standard EXE.  Next go to the Project | Components menu  Check the Microsoft Comm control 6.0.  Click OK. Next double-click on the yellow phone in the toolbar to add the MSComm control to your form. Now add two option buttons from the tool bar name as "opton" and "optoff", change the caption to ON and OFF for both buttopns. Now add a command button named cmdsend from the tool bar, and chage the caption to "SEND" On To The Code Now that the form is set up and ready to go, we need to start adding our code to the project. The user will select a pin state from option button, and then click cmdSend to send the data to the microcontroller. So first of all we need to set up the MSComm control, and select one of the pin states to start with. So lets add the following code to our form Private Sub Form_Load() On Error Resume Next 'use comm port 1 MSComm1.CommPort = 1 ' 9600 baud, no parity, 8 data bits, 1 stop bit MSComm1.Settings = "9600,N,8,1" ' Disable DTR MSComm1.DTREnable = False 'open the port MSComm1.PortOpen = True End Sub Now we just need to add the code to send the data. When the user presses cmdSend, we need to do three things.  Get the pin state  Send the data Now lets put it all together and send the data when we press the cmdSend button Private Sub cmdsend_Click() Dim LED As Long ' Get LED State If opton.Value = True Then LED = 0 Else LED = 1 End If ' Send Out Data MSComm1.Output = Chr$(255) & Chr$(LED) End Sub So we sent out the synch byte (255),followed by the LED state. Finally we need to close the comm port when the VB project unloads so Private Sub Form_Unload(Cancel As Integer) MSComm1.PortOpen = False 'Close the COMM port End Sub That's all at the PC side Microcontroller Side Program the MIcrocontroller with the following code ORG 00H &am p;am p;nb sp; ; Reset MOV TMOD,#20H &am p;am p;nb sp; ;enable timer1, mode 2 (auto reload) MOV TH1,#0FDH &am p;am p;nb sp; ;9600 Baud rate MOV SCON,#50H &am p;am p;nb sp; ;8 bit, 1 stop bit, REN enabled SETB TR1 HERE:JNB RI,HERE ; ; ; ; ; ; ;wait for character to come in MOV A,SBUF ;get data in A CJNE A,#0FFH,DOWN ;chk if the char is synch byte ie.offh or 255 ;if not jump to clear RI CLR RI & ; ;nbs p; & ; ;nbs p; ;get ready to get next byte WAIT:JNB RI,WAIT ; ; ; ; ; ; ;wait for character to come in MOV A,SBUF ;get data in A CJNE A,#00H,NXT &a mp;a mp;n bsp; ;chk if the char is 0 CLR P2.0 &a mp;a mp;n bs p; & ;a mp;n bsp; ;switch on LED SJMP DOWN &a mp;a mp;n bs p; & ;a mp;n bsp; ;jump to clear RI NXT:CJNE A,#01H,DOWN & amp; amp; nbsp; ;chk if the char is 1 SETB P2.0 &a mp;a mp;n bs p; & ;a mp;n bsp; ;switch off LED DOWN:CLR RI & ; ;nbs p; & ; ;nbs p; ;get ready to get next byte SJMP HERE &a mp;a mp;n bs p; & ;a mp;n bsp; ;keep getting the data Now run the VB project, select either ON or OFF, and press send. You should see the LED turn ON when you send a ON command, and turn OFF when you send a OFF command. Click here to download it Receiving Data From The Microcontroller: In the last article we sent data to a microcontroller and had it respond to the data that we sent In this article we are going to learn how to receive data from a microcontroller and make the PC respond. For simplicity we are going to get the Port 0 and send to the PC for us to receive using VB. Visual Basic at PC side To get started open Visual Basic.  Start a new Standard EXE.  Next go to the Project | Components menu  Check the Microsoft Comm control 6.0.  Click OK.  Next double-click on the yellow phone in the toolbar to add the MSComm control to your form.  Finally add a label to your form and name it lbldata On To The VB Code Now that the form is set up and ready, we need to get a quick understanding of how the MSComm control can receive data from the serial port. There are basically two methods, polling the port and responding to communications events. Polling the port is done by setting up a timer to check the buffer for data, and if data is there, process it. Polling is better when you have variable length data that starts and ends with header and footer bytes respectively. The event driven method is designed more for receiving fixed length data. It is also better because you don't waist time polling the buffer for data if none is there. Instead the MSComm control will tell you when data is there by firing the OnComm() event. This event fires just like a Click() event would fire if you clicked on a Command Button, only it is not the users action that fires this event, something must happen at the serial port. When the OnComm() event is fired you must check the value of the CommEvent property to see what exactly happened. The CommEvent property will contain a different value for each different kind of communication event that occurs. In this project we are only concerned with the comEvReceive constant which has the value of 2 and is fired when data is available in the buffer. Now that we have a feel for how the MSComm control will assist us in receiving data, lets first set up the MSComm control. Copy this commented code to your project Private Sub Form_Load() ' Fire Rx Event Every single Bytes MSComm1.RThreshold = 1 ' When Inputting Data, Input 1 Byte at a time MSComm1.InputLen = 1 ' 9600 Baud, No Parity, 8 Data Bits, 1 Stop Bit MSComm1.Settings = "9600,N,8,1" ' Disable DTR MSComm1.DTREnable = False ' Open COM1 MSComm1.CommPort = 1 MSComm1.PortOpen = True End Sub You may notice that there are two new properties in the above code that have yet to be explained in these articles. The first is RThreshold. In this example, setting the RThreshold property equal to 1 tells the MSComm control to fire the comEvReceive event when there are at least one bytes available in the buffer. The second property, InputLen, tells the MSComm control to only give us the first byte when we request data from the buffer. With that out of the way, lets take a look at the code that is executed when the OnComm() event is fired. The comments should help you along Private Sub MSComm1_OnComm() Dim Data As String ' If comEvReceive Event then get data and display If MSComm1.CommEvent = comEvReceive Then Data = MSComm1.Input ; ; ; 'get data lbldata.caption = Asc(Data1) 'convert to ASCII and display End If End Sub Finally we need to close the comm port when the VB project unloads so Private Sub Form_Unload(Cancel As Integer) MSComm1.PortOpen = False 'Close the COMM port End Sub That's all at the PC side Microcontroller Side Program the Microcontroller with the following code, it reads the port P0 and sent the data to the PC. ORG 00H &am p;am p;nb sp; ; Reset MOV TMOD,#20H &am p;am p;nb sp; ;enable timer1, mode 2 (auto reload) MOV TH1,#0FDH &am p;am p;nb sp; ;9600 Baud rate MOV SCON,#50H &am p;am p;nb sp; ;8 bit, 1 stop bit, REN enabled SETB TR1 MOV P0,#0FFH & ; ;nbs p; ;make P0 as input port AGAIN:MOV A,P0 &a mp;a mp;n bs p; & ;a mp;n bsp; ;Read P0 MOV SBUF,A ;send data HERE:JNB TI, HERE &a mp;a mp;n bs p; & ;a mp;n bsp; ;wait for data to be transferred CLR TI & ; ;nbs p; & ; ;nbs p; ;clear TI for next char SJMP AGAIN & amp; amp; nbs p; & ; amp; nbsp; ;keep doing it After Burning up the above Program to the microcontroller run your VB project, power up the microcontroller, change the values of the switches. and the datas will be displayed on the PC. Click here to download it Connecting GPS to PC using Visual Basic: This tutorial is about Serial Communications using Visual Basic with Trimble's LassenLP GPS reciever. This GPS reciever can be intefaced and controlled via a computer using a serial cable. The GPs system provides nearly accurate information on the position (i.e latitude, longtitute , Altitude) or Velocity of an object on earth. This messsage on the computer can be extracted from the Lassen LP system using Windows Hyperterminal. Using Hyperterminal is not an easy way to understand the message as it has to be extracted and converted for a ordinary person to be able to understand. This tutorial provides an visual basic code to serially extract the data, convert it appropriately and display it on an screen Advantages of Using Lassen LP GPS Module The LassenLP is a miniature, low- powered, high performance GPS receiver module. It uses only 3.3 volts. Because of its miniature size and low power operations, it can be embedded into many portable devices such as the palm, laptop computers, handheld radios, cell phones, automobile navigation systems and space navigation systems. . Because of its micro-sized board, the system integrator can easily fit GPS functionality into portable products. Lassen LP GPS module allows portable device developers to balance operational frequency and power consumption for a particualar application. Motivation and Audience Gps systems are an important aspect of life today. Today they are incorporated in any mobile equipment right from an cell phone to an automobile to a ship or also an Aeroplane. GPS systems aids in Naigation by providing the position (i.e latitude, longtitute , Altitude) or Velocity of an object. This tutorial explains an visual basic code to interface serially with an LAssenLP GPS reciever and extract positional and velocity information from it. IT doesnot discuss about the GPS theory or the protocols used. The rest of the tutorial is presented as follows: Using HyperTerminal with an GPS Reciever HyperTerminal is an program on an windows machine used to display information that is recieved on the serial port of an computer. The Lassen LP is connected to the serial port of a computer with communication setting being 4800 baud 8bit , 1 stop bit and no flow control. The information from the gps system is updated every few seconds and is as displayed in the hyper terminal window. Understand and Simplify the GPS Code A sample positon and velocity information from the GPS receiver is shown below. The ">" informs the beginning of the message and "<" indicates the end of the message. The letter RPV tells us that it is an response from the GPS reciever about position/velocity. >RPV07559+4026178-0748913800000012;*76< This is an Position/ Velocity information from the GPS receiver. IT could be dissected as follows. The DataString similiar to above AAAAABBBCCCCCDDDDEEEEEFFFGGGHI AAAAA This indicates the GPS time of the Day and it is in secs BBB,CCCCC This indicates the Latitude in Degrees DDDD,EEEEE This indicates the Longtitude in Degrees FFF This indicates the velocity of the speed if the reciever is moving GGG This indicates the direction in degrees. HThis indicates the source of data I This indicats the Age of Data whether it is Current or archieved Visual Basic Source Code and a Brief Explaination Here is a code with an easy to understand front end GUI as shown in the pic. The code can be downloaded LassenLP.zip rather then cutting and pasting from here. The GUI is like this [...]... VXL Về giao thức giao tiếp với máy in, có thể tham khảo trong cuốn "Đo lường & Điều khiển bằng máy tính" của Ngô Diên Tập Sửa bởi administrator ngày 16 June 2007 lúc 23:20 Tự động nối bài vi t của thành vi n Bài vi t gửi lúc 22:59 ngày 16 June 2007 GIAO TIẾP SONG SONG THÔNG QUA CỔNG MÁY IN Trên máy tính, cổng máy in là cổng giao tiếp song song thường gọi là cổng LPT Cổng máy in có 5 ngõ vào số... có thể nạp chương trình trực tiếp từ PC (giống 89V51RB/RD của Philips) Thứ hai, giao tiếp với máy in là giao tiếp song song, nghĩa là dữ liệu truyền nhận mỗi lần là 8 bit truyền cùng 1 lúc Như vậy giữa VĐK MCS51 và máy in giao tiếp với nhau là không có vấn đề gì khó khăn Đơn giản là dùng lệnh MOV thôi Sơ đồ kết nối thì cũng như kết nối các thiết bị ngoại vi giao tiếp song song khác, có thể tham khảo... (máu đỏ) và 12 ngõ ra số (màu xanh) Trong đó: + D0 đến D7 là ngõ ra dữ liệu + C0 đến C3 là ngõ ra điều khiển (trong đó C2 tích cực mức cao, còn lại là tích cực mức thấp) + S3 đến S7 là ngõ vào báo trạng thái (trong đó S7 tích cực mức thấp, còn lại là tích cực mức cao) + 8 ngõ còn lại nối đất Phía máy in thì ngược với phía máy tính, nghĩa là ngõ ra của máy tính chính là ngõ vào của máy in và ngược lại... using visual basic to interface a GPS system to a computer using Serial Port With this basics in mind, now we can now implement GPS systems for Navigational purposes Read more: http://www.ant7.com/forum/forum_post.asp?TID=2238#ixzz0dpMvfIh1 Thứ nhất, 89S52 là IC thuộc họ VĐK MCS-51 như 89C51 nên tập lệnh, cách vi t chương trình vẫn như nhau 89S52 dùng chuẩn I2C nên khi có thể nạp chương trình trực tiếp. .. dữ liệu bằng Pascal /Delphi: Const Data = $378; Status = Data + 1; Control = Data + 2; var Bits: Byte; Port[Data] := Bits; { output data } Bits := Port[Status]; { input data } Truy xuất dữ liệu bằng MS Visual C/C++: #include /* required only for function declarations */ #define Data 0x378 #define Status 0x379 #define Control 0x37a int Bits, Dummy; /* 0 . Giao tiếp PC và ngoại vi qua cổng máy in Giao tiếp PC và ngoại vi qua cổng máy in - Mã nguồn (Code) - Sơ đồ mạch Chân Ký hiệu Vào/ra Chức năng 1 STROBE Ra Xung âm xác định máy tính. b i vi ết của th nh vi n à B i vi ết gửi lúc 22:59 ng y 16à June 2007 GIAO TIẾP SONG SONG THÔNG QUA CỔNG MÁY IN Trên máy tính, cổng máy in l cà ổng giao tiếp song song thường gọi l à cổng. liệu D7 10 ACK Vào 0: Tín hiệu xác nhận máy in đã in xong (Acknowledge) 11 BUSY Vào 1: Máy in bận 12 PE Vào 1: Hết giấy (Paper Empty) 13 SLCT Vào 1: Đã có máy in (Select) 14 AF Ra 0: Máy in xuống

Ngày đăng: 08/08/2014, 02:21

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan