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

Supporting Visual Studio on Windows
Post Reply
pavel443
Fresh meat
Posts: 4
Joined: Wed Jul 24, 2019 10:23 am
Contact:

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

Post 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.
Attachments
The GUI
The GUI
pic1.jpg (15.51 KiB) Viewed 13437 times
fraser
Engineering
Posts: 138
Joined: Thu Nov 19, 2009 4:41 pm
Contact:

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

Post 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();
pavel443
Fresh meat
Posts: 4
Joined: Wed Jul 24, 2019 10:23 am
Contact:

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

Post 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?
pavel443
Fresh meat
Posts: 4
Joined: Wed Jul 24, 2019 10:23 am
Contact:

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

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests