IOW40 and Knobs/Data-Entry

This is the English forum for all topics related to IO-Warrior. Please post in English only

Moderator: Guido Körber

Post Reply
williamk
Posts: 20
Joined: Thu Feb 19, 2004 8:06 am
Contact:

IOW40 and Knobs/Data-Entry

Post by williamk »

Hy, I would like to know how the IOW40 works for using knobs and also data-entry pots.

When you click on a knob, or un-click it, does it generate a "report" like windows does for mouses/keyboards? Or it just writes the new flag on the chip, and I should keep checking this to read the data?

The problem is, I want to use a data-entry pot, that outputs: 0, 1 and 2. But if I have to keep checking the status of it, CPU usage may be increased, and I could also "lost" some positions resulting into complete failure of the data-entry system...

Let me know how this will work.

Best Regards, WilliamK
Guido Körber
Site Admin
Posts: 2856
Joined: Tue Nov 25, 2003 10:25 pm
Location: Germany/Berlin
Contact:

Re: IOW40 and Knobs/Data-Entry

Post by Guido Körber »

What is a "data-entry-pot"?

The way IO-Warrior works is that it sends a report when there is a change of status on one or more pins. You can either do a blocking read (iowkitRead) where the thread waits until data is returned from IO-Warrior, or you can do constant non-blocking reads with iowkitReadImmediate.

In case of a blocking read you should consider programming with threads so your application does not block completely while you wait for data.
williamk
Posts: 20
Joined: Thu Feb 19, 2004 8:06 am
Contact:

Post by williamk »

Thanks and sorry for the lack of information, as I don't know how to call this thingie, I called "data-entry pot". Is an endless potentiometer, like those used on the new Aiwa Radios for Volume. It has 3 pins, and the software will figure-out if you are rotating left or right. ;-)

Yes, the report is what I need, I just have to learn how to handle it on my application. I will check the examples and read more about this, if I get stuck, I post here.

Wk
Guido Körber
Site Admin
Posts: 2856
Joined: Tue Nov 25, 2003 10:25 pm
Location: Germany/Berlin
Contact:

Post by Guido Körber »

Still no idea what kind of device you are talking about.

A pot is a variable resistor, it has two end taps and a center tap that you move by rotating the axis. But it makes no sense to allow it to rotate 360 degrees since you have no reference then. And it is analog, so no connecting it to IO-Warrior without an A/D converter.

The other thing is a rotary encoder. But that has usually four connectors. It supplies two phase shifted signals, mechanical mice work with this method. You can read such an encoder with IO-Warrior as long as the pulse frequency is not too high.
williamk
Posts: 20
Joined: Thu Feb 19, 2004 8:06 am
Contact:

Post by williamk »

Guido Körber wrote:The other thing is a rotary encoder. But that has usually four connectors. It supplies two phase shifted signals, mechanical mice work with this method. You can read such an encoder with IO-Warrior as long as the pulse frequency is not too high.
Yes, that's the one, sorry about that. But I have 2 types here, 3 and 4 pins, they both work.

You mean, if you rotate too fast, it will go crazy? :wink: But I guess I can't controll that... I have to check how this will work...

Wk
Guido Körber
Site Admin
Posts: 2856
Joined: Tue Nov 25, 2003 10:25 pm
Location: Germany/Berlin
Contact:

Post by Guido Körber »

williamk wrote:You mean, if you rotate too fast, it will go crazy? :wink: But I guess I can't controll that... I have to check how this will work...
The IO-Warrior can send only one report every 8msec. If you generate more level changes on the port pins you will lose some.
williamk
Posts: 20
Joined: Thu Feb 19, 2004 8:06 am
Contact:

Post by williamk »

Guido Körber wrote:
williamk wrote:You mean, if you rotate too fast, it will go crazy? :wink: But I guess I can't controll that... I have to check how this will work...
The IO-Warrior can send only one report every 8msec. If you generate more level changes on the port pins you will lose some.
Thanks, on those cases I will just ignore the readings or put values to MAX.

Wk
Guido Körber
Site Admin
Posts: 2856
Joined: Tue Nov 25, 2003 10:25 pm
Location: Germany/Berlin
Contact:

Post by Guido Körber »

williamk wrote:Thanks, on those cases I will just ignore the readings or put values to MAX.
For a rotary encoder you can get only certain sequences of states, if one is skipped you know you missed data:

00 <-> 01 <-> 11 <-> 10 <-> 00

The sequence goes left or right depending on the rotation direction.
williamk
Posts: 20
Joined: Thu Feb 19, 2004 8:06 am
Contact:

Post by williamk »

Thanks Guido, you are right indeed. So is easy to see when there were "skips". On those cases I can do 2 things. Wait until a "valid" sequence is sent, or assume that the user wants the MAX value possible. (most used on hardware I see around)

Wk
williamk
Posts: 20
Joined: Thu Feb 19, 2004 8:06 am
Contact:

Post by williamk »

Just one last question. When a port changes its status, it reports. But what happens if the report wasn't read yet and there is a NEW report. Does it get added to a "list" of reports. That would help me a lot ...

Wk
Guido Körber
Site Admin
Posts: 2856
Joined: Tue Nov 25, 2003 10:25 pm
Location: Germany/Berlin
Contact:

Post by Guido Körber »

Windows keeps a buffer of some reports, though I don't know right away how many it keeps. Robert?
williamk
Posts: 20
Joined: Thu Feb 19, 2004 8:06 am
Contact:

Post by williamk »

I just did a quick C++ program to test the rotatory-encoder. And yes, it won't read right if you move too fast. Altough, there is a way to fix that. I created a variable that checks if you are moving up or down, and if you move too fast, it assumes the last movement. Not optimal, but works. ;-)

I used the Read() command, it halts until something changes. Not sure if that one is buffered.

Wk
williamk
Posts: 20
Joined: Thu Feb 19, 2004 8:06 am
Contact:

Post by williamk »

Eeeekkkkk, I was testing more, and no, it doesn't work. :cry: Since it assumes the last position, sometimes it goes the opositive way...

So, what I need to do, is built a simple circuit that will read the rotatory-encoder and output only +/- instead. And maybe even +10/-10. But I have no clue on how to proceed. I will think on something ...

Edit: Maybe I should seek an all-in-one rotatory-encoder solution... I will check the local electronics stores... maybe I find something that I can use with IOW40... I could use the current one, but it would be very strange.

Wk
Robert Marquardt
Posts: 543
Joined: Mon Dec 01, 2003 6:09 pm

Post by Robert Marquardt »

Guido Körber wrote:Windows keeps a buffer of some reports, though I don't know right away how many it keeps. Robert?
AFAIK 8 for Win2000/XP. Can be increased with a call to HidD_SetNumInputBuffers (512 max).
Post Reply