Windows XP, SP3, USB 2.0, K8055D.dll version 3.0.2.0
Connect (wire) 1 output to 1 input (O1 to I1) on the k8055 board and try the following code.
(timer interval was set to 5 ms)
API is a project namespace that “wraps” unmamage K8055D.dll using DllImport.
But I think, for other languages it should be the same.
If the function UpdateInputs does not call ReadCounter()…, there is a delay 260 ms (instead of cca 45 ms)!
Could you explain this behaviour?
Thanks!
Milos
int stateDI = 0, stateDO = 0;
bool doInput = false;
private void timer_Tick(object sender, EventArgs e)
{
timer.Enabled = false;
UpdateInputs();
UpdateOutputs();
timer.Enabled = true;
}
private void UpdateOutputs()
{
if (doInput == false)
{
if (stateDO ==1)
stateDO = 0;
else
stateDO = 1;
API.WriteAllDigital(stateDO);
writeTime = DateTime.Now;
doInput = true;
}
}
private void UpdateInputs()
{
stateDI = API.ReadAllDigital();
if (doInput && stateDI ==stateDO)
{
doInput = false;
System.Diagnostics.Debug.WriteLine((DateTime.Now - writeTime).TotalMilliseconds.ToString());
}
#if DELAY
// delay cca 260 ms
#else
// delay cca 45 ms
int c1 = API.ReadCounter(1);
int c2 = API.ReadCounter(2);
int ai1 = 0, ai2 = 0;
API.ReadAllAnalog(ref ai1, ref ai2);
#endif
}