From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to send a different types of data using serial port

i need to send an array of angles with some litters as a group to the serial port which function that can do this ? as considerd that the visa wrrite accepts only string input  .

0 Kudos
Message 1 of 7
(3,906 Views)

@MuhammadAshry wrote:

i need to send an array of angles with some litters as a group to the serial port which function that can do this ? as considerd that the visa wrrite accepts only string input  .


I hope you want to send letters and not litters 🙂 Anyway, as you have noted, you can only send string using VISA Write. Same for VISA Read, you get string. The solution is very simple: use the string-number conversion functions (Number/String conversion subpalette). For example you have an "angle" numerical value, you need to convert this into a string, and send it. On the receiver side, you can convert the string back to number if needed:

 

convert1.png

0 Kudos
Message 2 of 7
(3,901 Views)

it works only with an "number" not an array of numbers aslo i need to send something like that "WO " Before the array and then the array . is "Build Text" function works ?

0 Kudos
Message 3 of 7
(3,885 Views)
  1. Attach your VI, and NOT a png file.
  2. Do not use that Build Text Express VI, but proper string functions
  3. Please write an example what exactly you need to send at each iteration of the While loop. In the screenshot you have a number not an array.
  4. That two "Error/No Error" case structures are not needed inside the other Case structures you can just delete them...What do you do in the Error cases there? Attach your VI...
0 Kudos
Message 4 of 7
(3,874 Views)

Is there a specific format for your string?  If you know the format and the types of inputs (for example, a string, a float, and an integer), you can use "Format into String" which has a specified format (for example, %2s %4.1f %4d means "two character string, space, 4 character number format xx.x, space, 4 digit integer").  The function will help you build the Format String (right-click the function, type ^H and read the Help text).

Format into String.png

Bob Schor

0 Kudos
Message 5 of 7
(3,859 Views)

Thanks for ur effort 
actually i have 6 servo motors that i need to send their angles to arduino serial port with that format "WO Xangle1 YAngle2 Zangle3" and so on for the 6 motors .

0 Kudos
Message 6 of 7
(3,824 Views)

A FOR loop might help you to build up all of the strings and then send them all at once after the loop is complete.  Of course, this assumes you have an array for the data of the servos.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 7
(3,799 Views)