LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I read a photogate on a gameport using joystick VIs?

I have a photogate, a common device used in first-year physics labs, attached to the gameport on my PC soundcard. The photogate signal goes from 5V to 0 when the photogate is blocked. The signal goes to the gameport pin that ordinarily records the button status on a joystick. I can read the status by a call to port 0201H using cviVXDWrapper.dll

I believe I should be able to do the same thing using the joystick VIs but I always get an error message:

" -2000000008

ERR_INVALIDDEVICEINDEX
Please check to see if the device is attached correctly. Please make sure the
deviceIndex you passed in to initDevice.vi is correct. "

I believe this means that I need to convince Windows that my photogate is some sort of joystick so that there is an appropriate device ID for LV to use.

I have tried Control Panel|Gaming Options but Windows always says that any joystick I choose is not connected. How does it know? What steps am I missing.

Thanks
0 Kudos
Message 1 of 8
(3,421 Views)
Good Morning,
I'm not sure what either windows or LabVIEW constitute as a joystick these days, as WindowsXP will detect and use a USB joystick (I don't have an analog/sound card one handy) but if you want an older version to try:
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3D89756A4E034080020E74861&p_node=DZ52048&p_source=External

I just opened it in LabVIEW 7.1.1 and it didn't seem to cause any problems, but without the actual joystick ...


Putnam Monroe

Certified LabVIEW Developer
LabVIEW curmdgeon since 1992

"boy, my teachers used to always give me gold stars"
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 8
(3,412 Views)
Thanks for the suggestion but I tried that before.

The problem is that Windows must assign a devive ID to a joystick before LV can interact with it. My trouble is convincing Windows that the photogate is just an odd joystick. Various configurations of Add Hardware and Game Options in Control Panel leads to Windows telling me I don't have a joystick connected which in turn means LV will deliver an error message that a joystick is not present.
0 Kudos
Message 3 of 8
(3,404 Views)
Have you tried connecting an actual joystick to the port and seen if you can see it in LabVIEW? Just to eliminate the possibility that it is some more basic configuration issue in LabVIEW/Windows, that you might not see making CVI calls. Another, really annoying possibility is doing the CVI call and reading that in LabVIEW. I'll try taking a look at it when I get back to my home office this evening, have joysticks, etc.


Putnam Monroe
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 4 of 8
(3,397 Views)
Hello Mike,

This sounds more like a Windows issue than a LabVIEW issue, but it might help to know which versions of both LabVIEW and Windows you are working with. It seems this issue has come up before with Windows 98 systems...

You might want to consider looking into purchasing one of our USB Digital I/O devices: http://sine.ni.com/nips/cds/view/p/lang/en/nid/201737 .


Travis M
Applications Engineer
National Instruments
Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 5 of 8
(3,394 Views)
I am using Win98 and WinMe and LV7.0

Unfortunately I don't have a gameport joystick to play with. Do they still make them? I thought they were all USB now.

Gameports are interesting from a physics eduction point-of-view because gameports are common (if you have a PC) and relatively cheap. Photogates relatively cheap but easy to make. I wrote a set of applications that use a photogates for standard uses in physics labs - timing measurements for velocity and acceleration. A poor man's DAQ system. I hope to make these freely available to HS teachers. Schools can seldom afford even an E-Series board. Also it would make for good student projects. Others on the web have used the gameport for thermistor readings - again quite useful in high school/first year labs.

I was hoping to make more use of the gameport x & y-axes pins perhaps as a resistance or voltage measuring device. Again I probably can do it through port calls but accessing them through LV would be cleaner and easier for me.

What bugs me most is how Windows can know that a joystick is connected or not. Must be some pin connection that alerts Windows to the presence of a joystick. I haven't read anything about that though.

So this isn't really a LV problem so much as a Windows problem.

Thanks for taking the time to help.
0 Kudos
Message 6 of 8
(3,389 Views)
Hello again Mike,

You might want to try the setup on a WindowsXP machine, I have seen documentation where a user was attempting something similar (Win 98 on LabVIEW 7.0) and a switch to WinXP fixed the problem. Just a suggestion,

Travis M
Applications Engineer
National Instruments
Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 7 of 8
(3,383 Views)
I have solved my own question.

I didn't ground the X and Y Axes pins on the gameport (since I wasn't using them) so Windows didn't think anything was connected. Obvious in retrospect.

Thanks to everyone for their input.

Mike
0 Kudos
Message 8 of 8
(3,372 Views)