Maker Pro
Maker Pro

USB digital IO interface with software event notification when an input changes state ?

S

Steve Parus

Jan 1, 1970
0
Looking for a USB interface device with several digital input/output
lines. Desire something that automatically notifies software (Delphi)
by firing an event whenever an input line changes state. I prefer not
to have to continuously poll the device's input lines to determine
when this occurs.

Ideally the device would not require software drivers to be installed.
Or if it does, then they use ActiveX and not a dll.

Steve
 
R

Rene Tschaggelar

Jan 1, 1970
0
Steve said:
Looking for a USB interface device with several digital input/output
lines. Desire something that automatically notifies software (Delphi)
by firing an event whenever an input line changes state. I prefer not
to have to continuously poll the device's input lines to determine
when this occurs.

Ideally the device would not require software drivers to be installed.
Or if it does, then they use ActiveX and not a dll.

Perhaps an FT232 or an FT245 from FTDI ?
On the delphi side, they work like a serial ports.
Polling the IO can be done with a controller with
sufficient pins. It'd send a serial message to the PC.

Rene
 
R

Robert Marquardt

Jan 1, 1970
0
Steve Parus said:
Looking for a USB interface device with several digital input/output
lines. Desire something that automatically notifies software (Delphi)
by firing an event whenever an input line changes state. I prefer not
to have to continuously poll the device's input lines to determine
when this occurs.

Ideally the device would not require software drivers to be installed.
Or if it does, then they use ActiveX and not a dll.

Steve

Probably the IOWarrior from Code Mercenaries (http://www.codemercs.com)
is the device you seek. My free HID component is part of the SDK.
It reads the device in a thread and fires an event is an input line
changes.
Since the device is a HID device it needs no drivers, DLL or ActiveX.
All done through Win32 API.
 
R

Robert Marquardt

Jan 1, 1970
0
Steve Parus said:
Does your component itself continuously poll in a loop to detect input
line changes ?

The component starts a thread which has a ReadFileEx pending on the
device.
It uses a timeout to periodically have the thread wake up to allow
ending the thread.
The microcontroller of the USB device checks the input lines for
changes and sends a data packet in that case.
For reding input lines this is the best way to implement it in the
microcontroller.
The alternative is to send a packet each time the device is read, but
this would place the detection of changes into the application.
That would be idiotic. The microcontroller has nohing else to do than
watch the input lines.
 
R

Robert Marquardt

Jan 1, 1970
0
Steve Parus said:
If so, is this how all such drivers must function in order to fire an
event upon input line changes ? I'm aware for example of devices with
ActiveX drivers that do event change notification :
http://www.phidgetsusa.com/viewproduct.asp?SKU=1221

This seems to be almost the same as the IOWarrior.
The internal workings of the ActiveX is probably the same as
my HID component.
 
S

Steve Parus

Jan 1, 1970
0
What is the possible time range (minimum, maximum) between the actual
digital input line state change and the event notification being sent
by your component ?

Perhaps there's several additional possible time delays from that to
Delphi's event firing ? Is the event notification sent via a message
placed into Windows message queue, etc ?
 
R

Robert Marquardt

Jan 1, 1970
0
Steve Parus said:
What is the possible time range (minimum, maximum) between the actual
digital input line state change and the event notification being sent
by your component ?

It first depends on the device itself. The IOWarrior is polled each 10
msec (8 msec used by Windows) so you cannot be faster than that.
Windows imposes its own delays. Not really determinable.
Perhaps there's several additional possible time delays from that to
Delphi's event firing ? Is the event notification sent via a message
placed into Windows message queue, etc ?

I use Synchronize which is AFAIK implemented through messages.

Please contact me directly. I check this newsgroup only through
Google.
 
S

Steve Parus

Jan 1, 1970
0
Ok, since Robert has answered my inquiry here before, I'll copy his
comments on my follow up questions :

I was asking about the IOWarrior.
Not sure what you mean by 8 msec is used by Windows ? Is this a time
restriction Windows imposes on USB devices ?

USB is a polled bus. No device can initiate a drata transfer of its
own. The host controller polls the devices in hardware. Each device
tells how often it wants to be polled. The IOWarrior tells it wants
10 msecs. Windows then polls with the nearest power of two = 8 msecs.
So a short pulse change of the inout logic state could be missed ?

Only a second change. The microcontroller detects the change and keeps
the info until the host controller calls for the data. Any changes in
that period get lost (i will ask if that is true).
I thought that devices that fire events into a program would be easier
to work with instead of my having to poll them continuously. I didn't
realize their drivers are actually polling anyway and generating the
event. Or is there some way to not have to poll ?

I think the above explanation tells that there is already enough
polling :)
If that's the case, I could use say a multimedia timer within my own
code to periodically poll the device's IO states. I've found the
multimedia timer to be very immune to other tasks such as minimizing a
window, dragging a scrollbar, etc.

No real reason for that. The delays on USB are mainly hardware
induced. USB is not real-time anyway. it is a serial bus not a serial
line.

Best tell which frequency of input alterations you want to detect.
From there on it is possible to decide if you need a microcontroller
to handle it on its own. Windows is definitely not usable below 1
msec.

Robert Marquardt
 
Top