01-05-2021 03:31 PM
-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.
Solved! Go to Solution.
01-05-2021 06:54 PM
I don't understand what you are trying to do -- aspects of it don't make sense.
Bob Schor
01-06-2021 01:04 AM
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.
01-06-2021 11:55 AM
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.
01-06-2021 01:13 PM
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?
01-06-2021 10:01 PM
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
01-07-2021 01:03 AM
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.
01-07-2021 09:44 AM
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
01-08-2021 08:06 AM
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?
01-08-2021 09:47 AM
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.