LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Send joystick axis and button information to Myrio via NI-Visa

Solved!
Go to solution

-I am using Myrio-1900.
- I want to send the joystick axis and button information to Myrio serially using NI-Visa.
- I want to send information from the computer to myrio using a TTL cable from the usb port on Myrio.

I created a program to read serial communication and Joystick information. I can read the joystick information. There is no problem with that.when I send the joystick axis and button information to myrio
Myrio reads the information, but when I try to read and write at the same time, I am unable to send it back successfully. I don't know how to fix this, I would really appreciate anyone who helped.

Download All
0 Kudos
Message 1 of 12
(1,546 Views)

I don't understand what you are trying to do -- aspects of it don't make sense.

  • Why are you using a Joystick with a myRIO?  As far as I know, the myRIO has no API designed for game controllers or Joysticks. 
  • Are you using the PC as a say of getting 2-4 Analog signals and 8-10 digital signals to the myRIO?  Wouldn't it make more sense to get a 2-axis potentiometer (packaged as a Joystick), power it to give you a voltage from, say, ±5 v, and feed this to two of the myRIO's A/D converters?  There are also numerous DIO lines that could handle lots of "buttons".  And this lets you free up the PC as more than a "Joystick Interpreter".
  • VISA can be used for bidirectional signaling, but you need to design a protocol to handle this.  Better (or at least "easier to understand") is to use existing protocols, such as TCP/IP, that can support multiple information streams.

Bob Schor

0 Kudos
Message 2 of 12
(1,515 Views)

Sir.I am using a Logitech Extreme 3d joystick. It is not affiliated with the joystick myrio. The joystick is connected to the computer, as shown in "Serial monitor test.vi". I'm just sending the joystick axis information to myriyo via Serial.

0 Kudos
Message 3 of 12
(1,504 Views)

I have added this connection scheme to be a little more descriptive. I am currently exchanging information. I am sending data with byte count and time adjustment at a speed close to real time, but at the same time I receive the information a little late, how can I solve this.

0 Kudos
Message 4 of 12
(1,480 Views)

How late is "a little late"?  How fast do you want or need it to be?

 

If a computer reads something, then has to form it into a message that it sends to another device, it is going to take some non-zero amount of time.  It will never be instantaneous.

 

So the question is how fast do you need it to be?

Perhaps even more important, what is the big picture?  What is it you are really trying to do?

0 Kudos
Message 5 of 12
(1,469 Views)

I don't know the proper term for it, but the VISA connection between your PC and your myRIO can transfer data either from Host (PC) to Target (myRIO), or from Target to Host, but not both at the same time.  One side (say, the Host) sends information (say a string) to the other side -- the Host "writes", and the Target "reads", and if either one fails to act, the whole process grinds to a halt.  If you use VISA to send Joystick information to myRIO, the myRIO can act on those signals, but it can't "talk back" to the Host until the Host stops sending Joystick data and "knows" to start "listening".

 

Bob Schor

0 Kudos
Message 6 of 12
(1,454 Views)

Thank you for your answers.
True, it will take more than 0 milliseconds, but the 400-500 millisecond turnaround time seems a bit too long. I have no speed issues sending information. It sends information Almost Instantly, but the return is an estimated 400-500 milliseconds delayed response. Since the information I send and receive is not too much, I want to reduce the turnaround time a bit.

- I think Myrio should be able to send back what it read from the computer just before it finishes listening because the TTL cable contains Rx Tx cables. It uses Rx to listen and Tx to transmit. I think this slowdown is not a hardware lag but a programming error.

Of course, I cannot solve the programming error completely :)Some help is needed in this regard.

0 Kudos
Message 7 of 12
(1,444 Views)

Ahh, you don't want to use NI-VISA, you want to directly control the pins of the DB-25 (or DB-9) serial connector that your PC undoubtedly does not have (since they stopped putting those on PCs about two decades ago, replacing them with a funny connector called a Universal Serial Bus, often abbreviated USB).  Hmm, maybe you plan to write your own USB driver and figure out how to do bi-directional serial communication yourself.  Quite ambitious, and probably doomed to failure ...

 

I just looked (again) at your code.  You really need to learn more about VISA, and @crossrulz has written extensively on this topic (and presented excellent talks on this).  Indeed, when I did a Web search for "crossrulz VISA", I was led to this LabVIEW Community Post which mentions both @crossrulz and some yo-yo named @Bob_Schor.

 

Try writing a simple demo that sends a message, "Hello, myRIO" and gets a response "Hi, PC" from the myRIO once the message is sent.  If you follow the (correct) way to use VISA that @crossrulz shows you (listen to the VIWeek 2020 talk he references about Proper Serial Communication), you should be able to send "Hello" and receive a speedy acknowledgement.

 

Bob Schor

0 Kudos
Message 8 of 12
(1,429 Views)

Hello,Bob_Schor I tried something considering your suggestions. I think I'm currently resolving my low speed in communication. I am reading data from the joystick. I send myrioya and myrio send back the information I sent me and instantly receive all the information Myrion sends. The code is in the attachment below. In addition, I have a question as follows. If I press the stop button in the code loaded on Myrio, that is, if I stop the application, it can close a few seconds after I press the Stop running application button on the computer. Is there a solution to turn it off so late?

Download All
0 Kudos
Message 9 of 12
(1,417 Views)

I went and cleaned up some Rube Goldberg stuff in your real-time code.  (The biggest hack was your array to cluster.)

 

Why would it take several seconds for your RealTime code to close?  Your control for milliseconds to wait is set for 35 milliseconds.  That means if you press the stop button it will take anywhere from 35-70 milliseconds for your loop to end.  I don't know how long the close-out code after the loop would take, so perhaps there is a long delay in that reset MyRIO subVI.

 

 

0 Kudos
Message 10 of 12
(1,412 Views)