Page 1 of 1

PhidgetException 0x34 (Device not Attached) with PhidgetInterfaceKit 0/0/4

Posted: Wed Jul 24, 2019 10:38 am
by pavel443
Hello,
I built a simple program in C# for "PhidgetInterfaceKit 0/0/4" (4 relays module).
GUI with 4 buttons, that every button changes the state of its relay number.

Every time the button clicked it use function of Relay.RelaySwitch(x);
When x is the relay number and Relay is a Class that have 4 instances of DigitalOutput (one for every channel)
DigitalOutput ch0 = new DigitalOutput();
DigitalOutput ch1 = new DigitalOutput();
DigitalOutput ch2 = new DigitalOutput();
DigitalOutput ch3 = new DigitalOutput();

and RelaySwitch() method is:

Public void RelaySwitch(DigitalOutput relayNum)
{
try
{
if (relayNum.State)
relayNum.State = false;
else
relayNum.State = true;
}
catch (PhidgetException ex)
{
Console.WriteLine(ex);
}
}


Everything works fine if I switch the same relay.
But when I'm switching fast few relays, the OS(Operational System) freezes until I get "PhidgetException 0x34"(Device not Attached)

Got any advice about what should I do, so the app won't crush?

Thank you.

Re: PhidgetException 0x34 (Device not Attached) with PhidgetInterfaceKit 0/0/4

Posted: Wed Jul 24, 2019 12:21 pm
by fraser
Make sure you set up and open each channel using

Code: Select all

ch0.Channel = 0;
ch1.Channel = 1;
ch2.Channel = 2;
ch3.Channel = 3;
ch0.Open();
ch1.Open();
ch2.Open();
ch3.Open();

Re: PhidgetException 0x34 (Device not Attached) with PhidgetInterfaceKit 0/0/4

Posted: Thu Jul 25, 2019 2:00 am
by pavel443
fraser wrote:Make sure you set up and open each channel using

Code: Select all

ch0.Channel = 0;
ch1.Channel = 1;
ch2.Channel = 2;
ch3.Channel = 3;
ch0.Open();
ch1.Open();
ch2.Open();
ch3.Open();

Yes, I already did that in a constructor:
//Constructor
class PhidgetRelay
{
DigitalOutput ch0 = new DigitalOutput();
DigitalOutput ch1 = new DigitalOutput();
DigitalOutput ch2 = new DigitalOutput();
DigitalOutput ch3 = new DigitalOutput();

/// <summary>
/// Constructor
/// </summary>
public PhidgetRelay()
{

ch0.Channel = 0;
ch1.Channel = 1;
ch2.Channel = 2;
ch3.Channel = 3;

try
{
ch0.Open(Phidget.DefaultTimeout);
ch1.Open(Phidget.DefaultTimeout);
ch2.Open(Phidget.DefaultTimeout);
ch3.Open(Phidget.DefaultTimeout);

ch0.State = false;
ch1.State = false;
ch2.State = false;
ch3.State = false;
}
catch (PhidgetException ex)
{
Console.WriteLine("Failure: " + ex.Message);
}


}

I think it's something to do with Events.
This means if I'm trying to set a state to DigitalOutput, while the previous change state command to other channel have not been complete.
Am I right?

(Solved) Re: PhidgetException 0x34 (Device not Attached) with PhidgetInterfaceKit 0/0/4

Posted: Thu Jul 25, 2019 8:09 am
by pavel443
Well... I solved the problem.
Eventually it was a hardware problem.

I used wrong USB cable, with poor shielding.
And because I work with relay array module, every time the relay close or open, its creates electromagnetic pulse that send noise to USB, and eventually USB driver get too much corruption bits and crashes, causing the module to detach.