PC Lab 2000se or Logger Recorder Visual Basic Source Code

Hallo,

I have a PCS10 4-Chanel Signal Recorder. I need a Visual Basic Source Code (VB-Project) from an oszilloscope like PC_Lab 2000se. I downloaded the Demo Project from the download side. I get only 5 steps channel values. I will record the values of 1 until 5 minutes.

I need help to find a real vb-source

regards Peter

In this download package there is Visual Basic 6 source code:
velleman.eu/downloads/files/ … 10_dll.zip
You have to edit it to record longer time.

It’s not this what I mean. I know to change the record time. Important is for me to creating the graph in run-time (not from the recorded file). There is no example to find.

OK - I see, you like to represent the data as a graph at run-time.

This is possible in Visual Basic.
Other (maybe easier) solution is to use Excel VBA macro to read the data from the PSC10 to a table and plot it into a graph…

Here an example screenshot:

Here is a link to download this PCS10 VBA example Excel workbook: box.net/shared/bznzex1dgd

I have a PCS-500, which I use successfully with the Capture Data Direct to Excel function.

I have just purchased a PCS-10, which I want to use in the same way, but there is no indication of how to do this in the Help function. The macro for the PCS-500 does not work with it.

Does this macro do the same thing?

Thank you.

[quote]Does this macro do the same thing?[/quote] Yes, this macro works with the PCS10 about similar way as the macro for the PCS500.
For more info and Excel example please see:
viewtopic.php?f=10&t=4562
viewtopic.php?f=10&t=3913

Thanks, very helpful.

One more question: I need the time scales for the two recordings (PCS10 and PCS500) to match (i.e., I am using them together as a 6-channel recorder).

Can you suggest settings (whether in the software, or the VBA script) for each that will result in the same time step? I need to record for about 4-5 seconds; the time-step per row should be somewhere between 1 and 10 ms.

Thanks!

Phil

Put your PCS500 code together with the existing PCS10 code in this timer event handler:Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, _ ByVal nIDEvent As Long, ByVal dwTimer As Long) On Error Resume Next ' ' The procedure is called by Windows. Put your ' timer-related code here. ' Read_Data ' End Sub

Sorry, but I am not a very sophisticated user of VBA, and need more explicit guidance.

For the PCS500, I am using this script, which came from the Help file:

Sub ReadAll()
Dim i As Long
ReadCh1 DataBuffer1(0)
ReadCh2 DataBuffer2(0)
With ActiveSheet
For i = 5 To 4100
.Cells(i + 1, 6) = DataBuffer1(i)
.Cells(i + 1, 7) = DataBuffer2(i)
Next i
End With
End Sub

The time-step comes from the timing setting in PC Lab 2000se (slowest button is 100ms/division, which accordingly to the output file produces readings at 1250 Hz, or 0.8 ms per step.

I inserted a call to this sub within the Start sub:

Sub Start()
Dim i As Long
Range(“B7:E4000”).Select
Selection.ClearContents
Range(“B6”).Select
For i = 1 To 4
ActiveSheet.Cells(10, i) = “CH” + CStr(i)
Next i

StartDevice
StartTimer
Row = 7
ReadAll

End Sub

And I modified the Read_Data (for the PCS10) to read exactly 4100 times (instead of waiting for Stop), like this:

Sub Read_Data()
Dim i As Long
ReadData DataBuffer(0)
With ActiveSheet
For Row = 7 To 4107
For i = 2 To 5
.Cells(Row, i - 1) = DataBuffer(i)
Next i
Next Row
End With
End Sub

But it still seems to keep looping until I hit Stop.

If that is too confusing, the whole module looks like this. Any help would be greatly appreciated:

Option Explicit
Private Declare Function SetTimer Lib “user32” ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib “user32” ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long

'GENERAL PROCEDURES
Private Declare Sub StartDevice Lib “k8047d.dll” ()
Private Declare Sub StopDevice Lib “k8047d.dll” ()

'INPUT PROCEDURE
Private Declare Sub ReadData Lib “k8047d.dll” (Array_Pointer As Long)

'OUTPUT PROCEDURE
Private Declare Sub SetGain Lib “k8047d.dll” (ByVal Channel_no As Long, ByVal Gain As Long)
Private Declare Sub LEDon Lib “k8047d.dll” ()
Private Declare Sub LEDoff Lib “k8047d.dll” ()

'Declare variables
Dim DataBuffer(0 To 7) As Long
Dim Row As Long
Dim TimerID As Long
Dim TimerSeconds As Single
Sub StartTimer()
TimerSeconds = 0.01 ’ .01 sec interval.
TimerID = SetTimer(0&, 0&, TimerSeconds!, AddressOf TimerProc)
End Sub
Sub EndTimer()
On Error Resume Next
KillTimer 0&, TimerID
End Sub
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
On Error Resume Next

’ The procedure is called by Windows. Put your
’ timer-related code here.

Read_Data

End Sub
Sub Start()
Dim i As Long
Range(“B7:E4000”).Select
Selection.ClearContents
Range(“B6”).Select
For i = 1 To 4
ActiveSheet.Cells(10, i) = “CH” + CStr(i)
Next i

StartDevice
StartTimer
Row = 7
ReadAll

End Sub
Sub Quit()
EndTimer
StopDevice
End Sub
Sub Settings()
SetGain 1, 1
SetGain 2, 2
SetGain 3, 5
SetGain 4, 10
End Sub
Sub Read_Data()
Dim i As Long
ReadData DataBuffer(0)
With ActiveSheet
For Row = 7 To 4107
For i = 2 To 5
.Cells(Row, i - 1) = DataBuffer(i)
Next i
Next Row
End With
End Sub

I realize that responding to my previous question might be quite onerous. Here is a simpler question that will help me move forward:

I understand from the PCS10 documentation that it samples every 10 ms, but my VBA script only enters readings in Excel a few times a second.
I thought the way to address this was in the StartTimer sub, which I adjusted from your example as follows:

Sub StartTimer()
TimerSeconds = 0.01 ’ .01 sec interval.
TimerID = SetTimer(0&, 0&, TimerSeconds!, AddressOf TimerProc)
End Sub

But it doesn’t seem to work.

Can you tell me how to increase the frequency with which measurements are recorded?

Thanks,

Phil

Your Sub Read_Data() is very time consuming.
Every time the timer is calling it, the routine will fill 4100 rows on the Excel sheet.

To read 4100 rows of data you need no timer.
This script will do the job:

[code]Option Explicit
'GENERAL PROCEDURES
Private Declare Sub StartDevice Lib “k8047d.dll” ()
Private Declare Sub StopDevice Lib “k8047d.dll” ()

'INPUT PROCEDURE
Private Declare Sub ReadData Lib “k8047d.dll” (Array_Pointer As Long)

'OUTPUT PROCEDURE
Private Declare Sub SetGain Lib “k8047d.dll” (ByVal Channel_no As Long, ByVal Gain As Long)
Private Declare Sub LEDon Lib “k8047d.dll” ()
Private Declare Sub LEDoff Lib “k8047d.dll” ()

'Declare variables
Dim DataBuffer(0 To 7) As Long
Dim n As Long

Sub Start()
StartDevice
n = 1
End Sub
Sub Quit()
StopDevice
End Sub
Sub Settings()
SetGain 1, ActiveSheet.Cells(3, 14)
SetGain 2, ActiveSheet.Cells(3, 15)
SetGain 3, ActiveSheet.Cells(3, 16)
SetGain 4, ActiveSheet.Cells(3, 17)
End Sub
Sub Read_Data()
Dim i As Long
Dim row As Integer
With ActiveSheet
For row = 7 To 4107
ReadData DataBuffer(0)
For i = 0 To 5
.Cells(row, i + 1) = DataBuffer(i)
Next i
Next row
End With
End Sub[/code]

If you anyhow like to use timer for some other purpose, please remember the time is set in milliseconds. Here an example how to set 2 seconds timer:

Sub StartTimer() TimerSeconds = 2 ' 2 sec interval. TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc) End Sub

Thanks, that does seem much simpler.

A few followup questions:

Are you saying that this will write 4100 rows of data, one every 10 ms?

Is there any potential conflict between ReadData for the PCS10 and by Sub ReadAll for the PCS500 (which calls ReadCh1 and ReadCh2)?

Is there any way to keep the two devices reporting in sync – that is, to override the Pc-Lab 2000se time/div instruction to make the PCS500 report every 10ms?

Thank you!

Phil

[quote]Are you saying that this will write 4100 rows of data, one every 10 ms?[/quote]In principle, yes.
You should use the K8047e.exe and K8047D.dll in the package “DLL for K8047 (PCS10) for faster communication”, available on this web site: velleman.eu/support/download … CS10&type=

[quote]Is there any way to keep the two devices reporting in sync – that is, to override the Pc-Lab 2000se time/div instruction to make the PCS500 report every 10ms?[/quote]I’m sorry, this is not possible.
The PCS500 is sending every time 4096 samples of data to the application software when the ReadCh1 or ReadCh2 is called.
This is a big chunk of data and you can’t synchronize it with the 10ms sampling of the PCS10.

Ok, thanks very much.

The code you suggested works fine, but appears not to be recording fast enough.

The first column (LSB) increments by five per row of output. I gather that these are in units of 10 ms? That would be consistent with the data that I am obtaining – I appear to be getting about 20 readings per second, which is not fast enough for my purposes.

Could the problem be with K8047e.exe and K8047D.dll? I followed the installation instructions. Is there any way to know if they are working properly?

Thank you!

Phil

It seems you are using the old (slow speed) version of the K8047e.exe and K8047D.dll.

You should use the K8047e.exe and K8047D.dll in the package “DLL for K8047 (PCS10) for faster communication”, available on this web site: velleman.eu/support/download … CS10&type=

You should replace the K8047e.exe and K8047D.dll in all possible places with the new ones:
Windows subfolders SysWOW64, System32 and in your application folder and in the My Documents folder if they are there too.

Still having trouble, I’m afraid …

First, it appears that the file dates of the files you referred to (K8047 dll and exe, fasttime) are several years EARLIER in the K8047_DLL_FAST zipfile than the files of the same names in the main PCS10 installation zipfiles. Can you confirm that I am supposed to overwrite the newer files with the older ones?

Second, the timestep in the LSB column varies between 5 and 10 units. Can you confirm whether these units are ms or 10ms? Based on the results, I would presume them to by 10ms (i.e. a timestep of 50 to 100 ms – I need the 10ms as advertised).

Third, I tried installing PCLab2000SE on a faster computer (a Toshiba Windows 7 i7 laptop). (I have been running it on an old XP Thinkpad, in order to have a parallel port for the PCS500.) However, I am only getting zeros - no data, even in the time columns. The signal is visible on the recorder/logger window. On the older machine, the same thing occurs if I don’t hit the Start function (which calls StartDevice), but that does not solve the problem on the Toshiba. Any idea why the data is not getting into the DataBuffer?

Sorry to keep bothering you, but this has turned into a bit of a nightmare project …

Thanks,

Phil

[quote]First, it appears that the file dates of the files you referred to (K8047 dll and exe, fasttime) are several years EARLIER in the K8047_DLL_FAST zipfile than the files of the same names in the main PCS10 installation zipfiles. Can you confirm that I am supposed to overwrite the newer files with the older ones?[/quote]The file K8047E.exe in the package “DLL for K8047 (PCS10) for faster communication” should be newer than the file in the package “K8047/PCS10 DLL and example to write your own software”.

Dates of the files in the package “K8047/PCS10 DLL and example to write your own software”:
K8047E.exe 3/12/2002
K8047D.dll 18/11/2002
FASTTime32.dll 22/8/1998

Dates of the files in the package “DLL for K8047 (PCS10) for faster communication”:
K8047E.exe 9/5/2005
K8047D.dll 18/11/2002
FASTTime32.dll 22/8/1998

[quote]Second, the timestep in the LSB column varies between 5 and 10 units. Can you confirm whether these units are ms or 10ms?[/quote] One step is 10ms.

[quote]Third, I tried installing PCLab2000SE on a faster computer (a Toshiba Windows 7 i7 laptop). (I have been running it on an old XP Thinkpad, in order to have a parallel port for the PCS500.) However, I am only getting zeros - no data, even in the time columns. The signal is visible on the recorder/logger window. On the older machine, the same thing occurs if I don’t hit the Start function (which calls StartDevice), but that does not solve the problem on the Toshiba. Any idea why the data is not getting into the DataBuffer?[/quote]Most probably your Excel VBA application does not find the files K8047E.exe, K8047D.dll and FASTTime32.dll.
The files FASTTIME32.DLL, K8047D.DLL and K8047E.EXE must be put to the Windows’ subfolder SYSTEM32 (if you use 32 bit operating system).
In 64 bit operating systems put the files to the Windows’ subfolder SysWOW64.
It’s good to copy them to your application folder too.

Here is an example of the result on the Excel sheet.
The signal fed to CH3 was 10Hz sine wave.


Click image to zoom.

Here you can download the files used for this Excel VBA (PCS10_test.xls) example:
app.box.com/s/qf2pin2k7sq1yrll4r6s

In Excel select Tools -> Options
Select General tab.
Clear the “Default file location” to use files (K8047E.exe, K8047D.dll and FASTTime32.dll) in the application folder.

Thanks for the quick reply.

Judging by the file dates, it appears that it is only the k8047e.exe that changed. k8047.dll and FASTTIME32.dll files have the same date stamps in the two zips, meaning that they are unchanged, no?

You indicate that k8047e.exe should be dated 9/5/2005, but I also have a version dated 16/06/2008 (more recent). This is from a folder called “K8047_PCS10_VBA_demo”. I’m not entirely sure where this came from … perhaps from a download link you sent me earlier? Should I use this 2008 version of k8047e.exe, or the 2005 version?

I am encouraged by your excel sheet showing LSB increasing by increments of 1 … I shall persevere.

Thanks,

Phil

[quote]You indicate that k8047e.exe should be dated 9/5/2005, but I also have a version dated 16/06/2008 (more recent). This is from a folder called “K8047_PCS10_VBA_demo”. I’m not entirely sure where this came from … perhaps from a download link you sent me earlier? Should I use this 2008 version of k8047e.exe, or the 2005 version?[/quote]I think there is no problem to use this newer version too.