Getting a higher switching speed on the 0/0/4 board

Technical Discussions on any InterfaceKits
Zjaaspoer
Phidgetsian
Posts: 5
Joined: Mon Oct 22, 2012 10:20 am
Contact:

Getting a higher switching speed on the 0/0/4 board

Postby Zjaaspoer » Mon Oct 22, 2012 10:33 am

Hi,

I just discovered Phidgets and they are great, I love them!

Right now I'm using the '1014_2 - PhidgetInterfaceKit 0/0/4' to turn on and of a stroboscope light. This stroboscope needs to simulate a few camera flashes (2 or 3). In order for the effect to work I need to activate power, and deactivate it as quick as possible. Something around 400ms would be great.

I've read a few posts and understand that the recommended rate is 1 switch every 3 seconds, and that switching it quicker is possible but produces more wear and heat. Both these problems are ok, as it will only be activated every few seconds at a maximum.

Now here is my question: How can I boost te speed? Right now I'm using Flash AS3 that interfaces with the board via Webservice. As soon as I switch one of the outputs on, and immediatly off, it still takes between 1 and 2 seconds to switch off again.

Is there anything I'm doing wrong? Is it possible to reach a off-to-on and on-to-off within a few 100ms?

And if not, will the SSR's do a better job in giving me high speed? I will be powering 4 15w stroboscopes with the relay. It's even possible, of needed, to use 2 or 4 different relays if the power consumption will be to high for all on 1

Thanks allready for your help!

User avatar
burley
Human-Cyborg Relations
Posts: 441
Joined: Tue Sep 27, 2011 2:37 pm
Location: Calgary
Contact:

Re: Getting a higher switching speed on the 0/0/4 board

Postby burley » Mon Oct 22, 2012 1:58 pm

Theoretically you can increase the speed, the relays can be switched a maximum of 20 times a second (50ms) though that is per switch, not full on/off cycle so in reality more like 10 times a second. However as you have noted you will experience significantly increased wear at this rate and the relays will fail in a much shorter period of time than normal.

Running over the WebService also presents a problem as it slows things down considerably. To achieve maximum speed you will want to avoid using the WebService (note that this means you cannot use Flash) and instead use a direct connection.
Brian Burley
403-282-7335 ext. 6003
support@phidgets.com

User avatar
Patrick
Lead Developer
Posts: 3119
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Getting a higher switching speed on the 0/0/4 board

Postby Patrick » Mon Oct 22, 2012 2:28 pm

Using the webservice should not slow things down this much - there may be an issues with your Flash code. There should be no issue getting this to work in Flash - especially if you are running on the same PC as the attached Phidgets.

-Patrick

Zjaaspoer
Phidgetsian
Posts: 5
Joined: Mon Oct 22, 2012 10:20 am
Contact:

Re: Getting a higher switching speed on the 0/0/4 board

Postby Zjaaspoer » Mon Oct 22, 2012 2:45 pm

Thank you both Burley and Patrick for your replies!

First of all I would love to try to get this working with Flash, as deriving from this technique will increase the complexity of my project considerably.

My code is really simple. There is some code doing other stuff, but the code for the phidget is basically this:

Code: Select all

var _phidget = new PhidgetInterfaceKit();
_phidget.open("localhost", 5001, "*****", 259236);
_phidget.setOutputState(0,true);
_phidget.setOutputState(0,false);

The above code switches the output on and then off immediately. I've also tried it with a timeout, but still about 2 seconds before it switches off:

Code: Select all

_phidget.setOutputState(0,true);
setTimeout(function(){
   _phidget.setOutputState(0,false); 
},100);

And I tried setting a listener for the output to become active, and then to switch it off. Still 2 seconds before it went off.

What also may be relevant: The initial switching on happens instantly, so no delay. So that gives me the idea that there is no delay between the program and the Phidget.

Zjaaspoer
Phidgetsian
Posts: 5
Joined: Mon Oct 22, 2012 10:20 am
Contact:

Re: Getting a higher switching speed on the 0/0/4 board

Postby Zjaaspoer » Tue Oct 23, 2012 1:46 am

More info: I tried switching the relay directly via the Phidget Controll Panel, and then it reacts instantly.

User avatar
Patrick
Lead Developer
Posts: 3119
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Getting a higher switching speed on the 0/0/4 board

Postby Patrick » Tue Oct 23, 2012 9:20 am

You won't be able to switch the output on then immediately off - you'll need a timeout. Is there a way is Flash to just sleep for ~250ms, rather then setting a function to run on a timeout? I think probably something else is going on with the code.

-Patrick

Zjaaspoer
Phidgetsian
Posts: 5
Joined: Mon Oct 22, 2012 10:20 am
Contact:

Re: Getting a higher switching speed on the 0/0/4 board

Postby Zjaaspoer » Tue Oct 23, 2012 9:27 am

What is the (functional) difference between 'sleep' and a timeout? I would think they do exactly the same?

Isn't this doing the exact same thing as sleep for 250ms and then turn the output off?

_phidget.setOutputState(0,true);
setTimeout(function(){
_phidget.setOutputState(0,false);
},250);

User avatar
Patrick
Lead Developer
Posts: 3119
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Getting a higher switching speed on the 0/0/4 board

Postby Patrick » Tue Oct 23, 2012 11:30 am

Yes it is.

I would try setting the timeout to 5 seconds, then 4, 3, 2, etc. and verify that the timing is accurate or not as you lower the value, when it is something that you can actually time with just a clock. You may also want to print out some log in the timeout function so you know exactly when the setOutput message is being sent from Flash - I just can't see it taking 2 second between the function call and the Relay switching - more likely, something in flash is delaying the call more then your timeout value. It may also depend on what else your program is doing.

It could also be getting delayed by incoming events - make sure that your program doesn't block any events while it's waiting to set the outputs - though I don't really think this is the case.

-Patrick

Zjaaspoer
Phidgetsian
Posts: 5
Joined: Mon Oct 22, 2012 10:20 am
Contact:

Re: Getting a higher switching speed on the 0/0/4 board

Postby Zjaaspoer » Wed Oct 24, 2012 3:47 am

Ok Patrick, thank you for your pointers. I'm going to do a lot of experimenting with the code and I'll get back to you when I've got some results. Thanks!


Return to “InterfaceKits”

Who is online

Users browsing this forum: No registered users and 0 guests