LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to interface keyboard or joystick controls?

Im part of a project group that is required to control a RC plane through the use of Labview. With help from users of this forum, I was able to locate a live video streaming software for which to provide a video feed for controlling the RC plane. However that leaves the process of the controls to be transmitted through the use of the serial port transmitter. Hence we are required to control the RC plane through the use of a keyboard or joystick wired through the USB port. Does anyone know where I can refer to for some material on how to interface a keyboard or joystick for controls transmission
0 Kudos
Message 1 of 13
(5,082 Views)
hi there

you can use the VIs under

Advanced\Input Device Control

from the functions palette to access keyboard or a joystick (only windows and linux).

best regards
chris
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 2 of 13
(5,076 Views)
Thanks!
just wondering but would you know where I can get an example or something that explains how to link up the block diagram for it to work?
0 Kudos
Message 3 of 13
(5,063 Views)
There is probably no example because it's very simple - place one of the Init VIs on the diagram, wire Device ID into "Acquire Input Data" and you have your data.
If you're using a keyboard, you can do this by using an event structure to detect the clicks (search the example finder for "events" and this site for tutorials about events).

___________________
Try to take over the world!
0 Kudos
Message 4 of 13
(5,048 Views)
Okay...I'm new to all this so how exactly do you see the data collected from the "Acquire Input Data"? How do I use this acquired data?

Currently, our project approach is to read the data gathered from the joystick then in turn we will match the corresponding joystick control to the RC plane's own RC controller. Hence when the joystick is pushed left, the left command on the joystick will be matched to the left command signal generated on the RC controller which then transmits this as a signal to the RC plane. This will cause the RC plane to turn left.

Can anyone help us out on how to go about doing this? We are truly stuck.

Message Edited by Grad on 06-22-2005 03:48 AM

0 Kudos
Message 5 of 13
(5,030 Views)
The top half of my diagram shows the joystick VI.
The VI calls the joystick 10 times a second (the 100 ms wait) to get its data and outputs the data in clusters (one for axes, one for directions and one for buttons). I created the indicators simply by right clicking the VI's output and selecting Create>>Indicator. The 2 easiest things to do would be to right-click on the VI and select Help (to get more details) and to write a VI similar to the one I wrote, run it and see how playing with the joystick affects the data.
Once you know how moving the joystick affects the data, you can simply unbundle the cluster (using the VIs in the cluster palette) to get the data you need and translate that into "plane data".

The question is how you communicate with the plane. If you have a communication established in another loop, you can simply use a local variable to transfer the value from one loop to the other loop. Alternatively, you can put everything in a single loop. It's hard to say without knowing exactly what your problem is and what you're trying to do. Is your problem in reading the joystick or sending the data to the RC (or both)? We need more details.

It sounds like you don't have much experience with LV. To learn more, try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide.

___________________
Try to take over the world!
Message 6 of 13
(5,023 Views)
Our problem actually lies with both reading the joystick as well as transmitting the data to the RC plane. However our first concern is to get the readings from the joystick. Eventually we will focus on transmitting the data through the serial port.

P.S.
Many thanks for your previous help posting

Regards,
Gerard
0 Kudos
Message 7 of 13
(5,009 Views)
I've managed to get the vi to check on the status of the joystick. How do I make use of the unbundling featureto get the data to a plane?
0 Kudos
Message 8 of 13
(4,974 Views)
A cluster is just a collection of elements (the numerics you are seeing) put into a single structure. Unbundling allows you to read the specific elements. You should really try those tutorials and read the part in the user manual about clusters to see about that.
As for sending the data to your plane, I have no idea. You said you wanted to connect using RS-232, which you can do using the serial VIs, but you will need to know the proper communication protocol to send the proper data to you plane.
You can find examples about serial comm (and probably clusters as well) if you click Help>>Find Example.

___________________
Try to take over the world!
0 Kudos
Message 9 of 13
(4,967 Views)
yup the problem that I'm facing now is how I am to use the data gathered from observing the joystick status demo found in examples and translating it to a serial port device for transmission to the plane. I am told the protocols for the serial port RF module for which is used to communicate with the plane will be given. I have also since read up on the tutorials u forwarded me but to no avail either.
0 Kudos
Message 10 of 13
(4,918 Views)