LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

USB Foot Switch

 

Hello,

 

Recently I have written an interface to some laser control. The interface include some boolean buttons such as on \ off switch.

 

I want to control one of these buttons via a mechanical switch rather than a mouse a click - For this I have a cheap Foot Pedal FS1_P.

 

All I want is when pressed - to send  true or false into my exising interface.

 

When I connect it to my computer Windows 7 automatically installed it. I install the software that comes with it and it works - I need to set the keyboard key I want the pedal to be and initilize it - and I can write with the pedal in notepad.

 

I don't have a clue however on how to interface it with LabView.

 

I've tried to follow this tutrial but completly got lost. In my device manage I see USB-composite device, in MAX I don't see any USB device - not even my Logiteh mouse.

 

Can someone help?

0 Kudos
Message 1 of 6
(3,759 Views)

If it appears to Windows as a normal HID device and works like a normal keyboard, you can use an event structure and use the Key Down? event to detect it then look for that key to be pressed, and discard the results.

0 Kudos
Message 2 of 6
(3,755 Views)

I'm not following you... In the switch software I first need to set the key and than initilze it.

 

how can I do this in LabView?

0 Kudos
Message 3 of 6
(3,753 Views)

So you run the software the first time and bind they pedal to a key.  Then it works in notepad.  Do you have to initialize it again?  I'd assume that information is remembered either on the PC side or in the device.  Why do you need to bind the key every time?

 

If you just need to run the software you could add it to the Startup folder so it starts when Windows does, or you can call it from LabVIEW using the System Exec VI.

0 Kudos
Message 4 of 6
(3,750 Views)

@mrish wrote:

I'm not following you... In the switch software I first need to set the key and than initilze it.

 

how can I do this in LabView?


once you set your key combo on your foot pedal, LV will see it as a "Key Down" in an Event Structure...here is an example Smiley Wink

Example_VI_BD.png

Message 5 of 6
(3,718 Views)

Two points.  First, what the earlier replies are saying is that if you set up your Foot Switch to produce a unique identifying message, then you can (in principle) use LabVIEW to see if any key on the keyboard has been pressed, and if so, see if it is part of your message.  One "nice" way to do this is to make the message a single key combination you otherwise never use, such as Ctrl-Shift-A -- if you see this, then it's from the pedal, otherwise ignore it.

 

The other point is that LabVIEW might be able to directly read from the specified "Keyboard/Mouse", i.e. you might actually be able to see a "Mouse Down" event.  I discovered, while trying to ask "Can I attach a Joystick to LabVIEW?", that there are some Input Devices functions that can work with Joysticks, Keyboards, and Mice.  For Joysticks, it actually goes out and obtains the names of all of the Joystick-looking devices it finds, and you can then "attach" to whichever one you want.  It also gives the names of the Keyboard and Mouse devices, and because it returns an array of these, I thought that you could "choose" which Keyboard or Mouse (assuming you have more than one) to use.  However, to my disappointment, the Initialize Keyboard and Initialize Mouse function (unlike Initialize Joystick) do not have a place for you to specify the Device Index and return a specific Keyboard or Mouse reference, so maybe this is not possible.  It is worth an experiment, however, to see if Query Input Devices returns multiple Mouse and/or Keyboard entries on your system when the Foot Pedal is attached.  If so, we can lobby NI to let us use Device Index to choose which one we want to use.

 

Bob Schor

0 Kudos
Message 6 of 6
(3,684 Views)