K8047 / PCS10 recording in Excel

Hi,

I have a PCS10, which I have connected to a Windows XP CPU, and I have tested your VBA for Excel and it works, however I would like to have a record per 1sec. I don’t know VBA, so could you help me with the new codes to make this possible ?

Can the columns LSB and MSB be excluded. And a new column ‘Time in sec’ be inserted ?

Additionally I will prefer that the VBA application runs on a Windows 7, where I have Excel 2013, what do I need to do to make this possible ?, I have already tried to copy Fasttime32.dll, K8047D.dll and K8047E.exe into sysWOW64 folder but when opening your Excel demo for PCS10 I get a error message.

[quote]Can the columns LSB and MSB be excluded. And a new column ‘Time in sec’ be inserted ?[/quote]Yes, by replacing the Sub Read_Data() in this Excel example app.box.com/s/qf2pin2k7sq1yrll4r6s with the following code:

[code]Sub Read_Data()
Dim i As Long
Dim row As Integer
Dim time As Double
time = 0
With ActiveSheet
For row = 2 To 50
ReadData DataBuffer(0)
For i = 0 To 5
.Cells(row, i + 1) = DataBuffer(i)
Next i
If row > 2 Then
If .Cells(row, 1) > .Cells(row - 1, 1) Then
time = time + 0.01
End If
If .Cells(row, 1) < .Cells(row - 1, 1) Then
time = time + 0.01 * (.Cells(row, 1) - .Cells(row - 1, 1) + 256)
End If
End If
.Cells(row, 7) = time

    Next row
End With

End Sub [/code]

[quote]Additionally I will prefer that the VBA application runs on a Windows 7, where I have Excel 2013, what do I need to do to make this possible ?, I have already tried to copy Fasttime32.dll, K8047D.dll and K8047E.exe into sysWOW64 folder but when opening your Excel demo for PCS10 I get a error message.[/quote]I’m sorry, the K8047D.DLL doesn’t work if you have 64bit version of Excel.

Hi

Thank you for the time column, however it is still giving data for every 0.01 sec, I only need every 1 sec, can you help with the code for this ?

[quote]Thank you for the time column, however it is still giving data for every 0.01 sec, I only need every 1 sec, can you help with the code for this ?[/quote]Yes, the following code gives data every 1 sec.Sub Read_Data() Dim i As Integer Dim m As Integer Dim n As Integer Dim old As Integer Dim row As Integer Dim time As Double Dim tmp As Double tmp = 0 time = 0 n = 0 m = 0 With ActiveSheet For row = 2 To 32 Loop1: ReadData DataBuffer(0) If n = 0 Then n = 1 For i = 0 To 5 .Cells(row, i + 1) = DataBuffer(i) Next i .Cells(row, 7) = time old = DataBuffer(0) GoTo EndLoop1 End If If DataBuffer(0) > old Then tmp = tmp + 0.01 * (DataBuffer(0) - old) End If If DataBuffer(0) < old Then tmp = tmp + 0.01 * (DataBuffer(0) - old + 256) End If If tmp >= 1 Or m > 200 Then time = time + tmp tmp = 0 m = 0 For i = 0 To 5 .Cells(row, i + 1) = DataBuffer(i) Next i .Cells(row, 7) = time GoTo EndLoop1 End If old = DataBuffer(0) m = m + 1 GoTo Loop1 EndLoop1: Next row End With End Sub

Hi

Yes, now it works with only 1 record per 1 sec. But I would like to be able to stop the recording during the read data (loop), when I get reach the correct readout on CH2, but while the loop is running it is not possible to use the stop buttom, can you help ?

I am using the system to record the output, where the critical point is where the output changes from increasing to decreasing values on CH2, and this is where I would like the recording to stop. I also would like to be able to set the criteria of the decrease, since I am recording different types of output data, where this criteria could be very different, is is possible to work this into the codes ?

Indeed, it is not possible exit the loop “manually” when the Excel is busy.
Instead by using the software it is possible.

[quote]I am using the system to record the output, where the critical point is where the output changes from increasing to decreasing values on CH2, and this is where I would like the recording to stop. I also would like to be able to set the criteria of the decrease, since I am recording different types of output data, where this criteria could be very different, is is possible to work this into the codes ? [/quote]Yes, by adding the following code snippet you can stop the recording when the required amount of the decrease is reached.
In this example the recording stops if the decrease is 10 or more: If old_CH2 - DataBuffer(3) > 10 Then Exit For End If old_CH2 = DataBuffer(3)

Here is the whole Sub Read_Data() code:Sub Read_Data() Dim i As Integer Dim m As Integer Dim n As Integer Dim old_time As Integer Dim old_CH2 As Integer Dim row As Integer Dim time As Double Dim tmp As Double tmp = 0 time = 0 n = 0 m = 0 old_CH2 = 0 With ActiveSheet For row = 2 To 32 Loop1: ReadData DataBuffer(0) If n = 0 Then n = 1 For i = 0 To 5 .Cells(row, i + 1) = DataBuffer(i) Next i .Cells(row, 7) = time old_time = DataBuffer(0) GoTo EndLoop1 End If If DataBuffer(0) > old_time Then tmp = tmp + 0.01 * (DataBuffer(0) - old_time) End If If DataBuffer(0) < old_time Then tmp = tmp + 0.01 * (DataBuffer(0) - old_time + 256) End If If tmp >= 1 Or m > 200 Then time = time + tmp tmp = 0 m = 0 For i = 0 To 5 .Cells(row, i + 1) = DataBuffer(i) Next i .Cells(row, 7) = time GoTo EndLoop1 End If old_time = DataBuffer(0) m = m + 1 GoTo Loop1 EndLoop1: If old_CH2 - DataBuffer(3) > 10 Then Exit For End If old_CH2 = DataBuffer(3) Next row End With End Sub