excel by example a microsoft excel cookbook for electronics engineers phần 8

WorkbookOpen. Thêm mã này để đóng tất cả các hình thức và sau đó kích hoạt bảng đầu tiên (và như một hệ quả hiển thị sơ đồ đơn ổn). Bảng tính với hình thức thể hiện smack thoa vào giữa của cửa sổ | Example 14 Interface to a Digital Multimeter Using a Serial Port Public bSeekingSync As Boolean used to indicate that the program is looking to synchronise the bytes Public nFrozenTime As Single used to timeout to allow sync Public iDMMMessage 9 As Byte Public bEndFlag As Boolean used to denote stop button input buffer Public bBlocReceived As Boolean indicates a 9 byte block has been recived Public iInputPointer As Integer Add a procedure called PollDMM as follows Sub PollDMM Dim i As Integer bEndFlag False set up port to read one byte With this is just shorthand to save writing nnn every time. .CommPort 1 .PortOpen True .Handshaking comNone no handshaking required .Settings 4800 N 8 1 set for 4800 baud no parity 8 bits 1 stop bit .InputMode comInputModeBinary binary data returned in variant array .InputLen 1 set to one character when read by Input .RThreshold 1 number of characters to receive before generating on comm event .DTREnable True .RTSEnable False End With bSeekingSync True indicate that we are looking for sync nFrozenTime Timer initialize timer bBlocReceived False and that there is no valid block 249 Excel by Example While Timer - nFrozenTime waiting untill there is a dead time DoEvents Wend now to format port to read 9 bytes bSeekingSync False 9 interrupt after 9 bytes 0 transfer all received bytes when read While bEndFlag False DoEvents If bBlocReceived True Then block has been received. write them to sheetl Sheets Sheet1 .Select For i 0 To 8 Cells i 1 1 iDMMMessage i Cells 11 1 iCounter Cells 12 2 TestP Next i bBlocReceived False clear block and start looking again End If Wend End Sub Initially the serial port is opened and configured for single-byte reception using the with construction. At the end of the port setup some values are initialized. bSeekingSync is a flag that indicates to the OnComm interrupt that we are looking for a sync signal. nFrozen

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.