I am using the VM110N and a digital output (DO) channel to signal a relay to control a motor. In the UI there is a button called “Start”, which when pressed starts the motor. We have found that to trigger the relay, the voltage on the DO must be on for some duration (300ms); too short of a duration and the relay is not triggered. A quick example of the code in C#/.NET is below. What we have found in our testing is that this work… most of the time. Somewhere between 5-10 toggles, the DO fails to clear. We can detect this situation because the light on the board is still on. We have verified that the ClealDigitalChannel is being called and no detectable errors are occurring in the software. So what is causing this? Are we calling the operations on the digital out too quickly?
K8055D.SetDigitalChannel(1); // turn on
Thread.Sleep(300); // wait for 300ms
K8055D.ClearDigitalChannel(1); // turn off
This is definitely an issue with the v5 K8055D.dll. I tested with v4 (4.0.0.1) and it worked great; I never saw the bug. When using either of the v5 DLLs (5.0.0.0 and 5.0.0.1) it would fail within 10 tries.
Its not clear to me what the difference between v4 and v5 is. Is that documented somewhere?
It seems that I can’t reproduce the issue.
I used this timer subroutine to test the operation of the functions: private void timer_Tick(object sender, EventArgs e)
{
timer.Enabled = false;
K8055D.SetDigitalChannel(1); // turn on
Thread.Sleep(300); // wait for 300ms
K8055D.ClearDigitalChannel(1); // turn off
timer.Enabled = true;
}Seems to work with DLL versions 4 and 5 without any problems.
[quote]Its not clear to me what the difference between v4 and v5 is. Is that documented somewhere?[/quote]Please see the last post of this thread: viewtopic.php?f=3&t=8630
There is some info concerning the difference between v4 and v5 DLLs.
I did some more research on this. You are correct, the basic code above does not cause the issue. After peeling out different aspects of my original code I found the issue is with multiple threads calling the K8055D dll. I have a couple threads which at a short interval read the state of the digital inputs and counters; if they detect a change in state they fire a .NET event (very useful). If I comment out that code, then the bug is not reproducible with any version of the DLL. My guess is the K8055D dll doesn’t like to be called multiple times at the same time; this could be a managed-native issue. If the v5 DLL is a bit slower (as reported) then it’s natural that this issue would happen more with the v5 DLL vs the v4 DLL. Classic bug.
FYI, my solution to this is to lock a SyncObject on the K8055D dll each time I make a call to it. This prevents multiple calls at the same time. So far with my testing I am unable to reproduce the bug with this syc lock code.