VM167 counter value into Excel

I’m using a VM167 to count pulses from a sensor - how do I show the counter value in real time in an Excel cell?

Just replace the timer event handler code in the VM167 Excel example with the following code:

Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, ByVal nIDEvent As Long, ByVal dwTimer As Long) On Error Resume Next ActiveSheet.Cells(1, 1) = ReadCounter(CardAddress) End SubYou’ll get the real time counter value to the cell A1.

Thanks, that seems to be almost there…
I copied the VM167Demo Excel code (including buttons) into my spreadsheet, deleting what I don’t need, but get a Compile error : “Sub or function not defined” at the “SetTimer” of the following code:

If Cards > 0 Then
InOutMode CardAddress, 1, 1
TimerSeconds = 1 ’ the timer interval is now 1 sec.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
End If
n = 2

All assistance is greatly appreciated!

If you go in the Examples folder to the folder \VM167DemoExcel and double click the VM167Demo.xls and then click “Enable macros” is there any error indication?

I sorted the above problem, and had it running displaying the count value in cell A1. When I then tried to read the count value into cell M2 (by changing “ActiveSheet.Cells(1, 1) = ReadCounter(CardAddress)” to Cells(2, 13) something went wrong and I get a “Card open error” message.

Removing the card, restarting Excel and reinserting the card did not help…I’m almost there!

OK - you got it working!
This second problem seems to be quite strange…
Can you try with the original VM167Demo.xls to get the card working again.

It was working in the VM167Demo at the same time; the counter was running as normal (I have a signal generator pulsing it as about 2Hz).

It’s working perfectly! After a cold start it seems to be just fine - I am really pleased!
Thanks for the help!!!