LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending Byte Array to Serial Port

Hi, 

  I find myself running into a slight porblem. I have an array of bytes which are in hexadecimal and i need to be able to write them to the serial port so that a stepper motor can be controlled. I have accumulated the array of bytes and converted them into a string using the 'byte array to string' vi, but for some reason i find myself unable to communicate with the stepper motor. I have successfully communicated with the stepper motor using RealTerm by sending hex commands, but it still won't work in LV. Once the array was converted into a string i then "unconverted" it back to an array of bytes just to make sure that the correct string was getting to the write buffer, and it seems to be just fine. I have included an image and the vi. Any input would be greatly appreciated. 

   David

0 Kudos
Message 1 of 3
(3,659 Views)

Does your stepper motor want actual binary hex commands or ASCII Hex commands?  I'm guessing it wants ASCII Hex commands since you are currently sending it binary hex commands.  So use the Number To Hex String on your data instead of the Byte Array to String.


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 2 of 3
(3,636 Views)

Thanks for the quick reply!

The stepper needs binary hex commands. When I send the ASCII hex commands in a terminal program or if I don't specify that the values are hex (with the 0x prefix) then the motor driver will not respond. I have also tried manually converting the hex values that I am trying to send and sending them in decimal through a terminal program, and this also works, so I'm pretty confident that the motor wants real binary commands and not just ASCII. From what you've seen of my VI, does it look like what is getting to the serial port is the binary hex commands?

0 Kudos
Message 3 of 3
(3,616 Views)