oklahomahaa.blogg.se

Excel vba serial port programming
Excel vba serial port programming





excel vba serial port programming

Use "Select case" command to write data separated into destination cells. If you use only one button, you need use an integer type global variable. The instrument is a slave, and your PC is a master? (Request-Answer mode?) You connect only one instrument to your PC? in spreadshhet, or number of serial ports (number of instruments)? Write_and_Read = f.read(30) '10 character will be readed (Not works if I try read 15 chars! Works if I read less than 10 chars, but the answer will be truncated)ĬellC.string = Mid(Write_and_Read, 15, 7) Wait(3500) 'NEEDED a timing! (Maybe it is instrument specific value.) įunction Write_and_Read(OutputStr as string) as Stringį = oFSO.OpenTextFile("COM4:9600", 1) 'for Reading until I used a button to stop the information sent and received in serial port.

excel vba serial port programming

Sorry.I forgot one thing.my code is based on writing the data readed by the serial port every time you press a button and this button sends the information to the serial port, but the the macro always write data in the same line at same cells and I wanted it to write the information on line 1, when I press the button again it writes on line 2 etc. Serial_port.ods (12.33 KiB) Downloaded 1398 times The Answer: '0 ,288.25 ' it means: 0 (no error 288.25 is the temperature value in Kelvin)

excel vba serial port programming

The MEASURE command (input parameter of function) is 'ME+Chr(13)+Chr(10)'

excel vba serial port programming

Write_and_Read = f.read(10) '10 character will be readed (Not works if I try read 15 chars! Works if I read less than 10 chars, but the answer will be truncated) Wait(5000) 'NEEDED a timing! (Maybe it is instrument specific value.) OFSO = createUnoService(".OleObjectFactory").createInstance("Scripting.FileSystemObject")į = oFSO.OpenTextFile("COM1:9600,N,8,1", 2) 'for Writingį.write(OutputChar) 'Sending by each characterį = oFSO.OpenTextFile("COM1:9600,N,8,1", 1) 'for Reading Code: Select all Function Write_and_Read(OutputStr as string) as String







Excel vba serial port programming