这个是针对逻辑分析仪采集的数据后倒入CSV文件后的数据进行处理
记录一下VBA提取位数据的方式
下面的程序提取了BIT0-BIT15中的bit11,bit6 和 bit5
Sub subtohex()
Dim i As Long
'转化hex数据
For i = 2 To 50000
If Sheet1.Cells(i, 2) <> "" Then
Sheet1.Cells(i, 5) = "=dec2hex(b" & i & ")"
'提取bit11
Dim tmp As Integer
Dim wei As Integer
tmp = Sheet1.Cells(i, 2) Mod &H1000
wei = tmp - tmp Mod &H800
wei = wei / &H800
If wei <> 0 Then
Sheet1.Cells(i, 6) = wei ' Sheet1.Cells(i, 2) Mod &H1000
Else
Sheet1.Cells(i, 6) = ""
End If
'提取bit6
tmp = Sheet1.Cells(i, 2) Mod &H80
wei = tmp - tmp Mod &H40
wei = wei / &H40
If wei <> 0 Then
Sheet1.Cells(i, 7) = wei ' Sheet1.Cells(i, 2) Mod &H1000
Else
Sheet1.Cells(i, 7) = ""
End If
'提取bit5
tmp = Sheet1.Cells(i, 2) Mod &H40
wei = tmp - tmp Mod &H20
wei = wei / &H20
If wei <> 0 Then
Sheet1.Cells(i, 8) = wei ' Sheet1.Cells(i, 2) Mod &H1000
Else
Sheet1.Cells(i, 8) = ""
End If
Else
'GoTo forbreak:
Exit For '退出for循环
End If
Sheet1.Cells(1, 10) = i
Next i
'forbreak:
End Sub
原始数据
可以拷贝到excel中
Time | MyBus0 | MyBus1 |
0s | 50719 | 1 |
3.4018s | 52799 | 1 |
3.4019s | 50719 | 1 |
9.0782s | 52831 | 1 |
9.0783s | 50719 | 1 |
12.3026s | 52831 | 1 |
12.3027s | 50719 | 1 |
14.4868s | 52831 | 1 |
14.4869s | 50719 | 1 |
15.8865s | 52799 | 1 |
15.8866s | 50719 | 1 |
20.4514s | 52831 | 1 |
20.4515s | 50719 | 1 |
21.0319s | 52799 | 1 |
21.032s | 50719 | 1 |
22.4869s | 52831 | 1 |
22.487s | 50719 | 1 |
22.59s | 52799 | 1 |
22.5901s | 50719 | 1 |
22.9439s | 52831 | 1 |
22.944s | 50719 | 1 |
24.9277s | 52799 | 1 |
24.9278s | 50719 | 1 |
27.9203s | 52799 | 1 |
27.9204s | 50719 | 1 |
35.3557s | 52831 | 1 |
35.3558s | 50719 | 1 |