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.
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.
08-31-2016 09:51 AM
i'm communicating with a plc by sending serial data commands as hex bytes. for example
02 30 31 34 32 33 59 30 30 34 31 31 41 03
i've implemented the communication protocol and everything works fine. i send my commands and i get the right response.
the problem: i need to insert in my vi 3x55 = 165 at least of these commands in that format. obviously i could copy-paste them in a string variable and do my job. but i need to find a more practical way as they could change in future. thought of creating a txt with the commads and then create 3 string arrays in my vi but i still need to send HEX data.
i can have my commands in almost any form i want as i generate them in python.
e.g.
02 30 31 34 32 33 59 30 30 30 30 31 35 03 (HEX) or
2 48 49 52 50 51 89 48 48 48 48 49 53 3 (DEC) or
0x02 0x30 0x31 0x34 0x32 0x33 0x59 0x30 0x30 0x30 0x30 0x31 0x35 0x03
this works almost fine but converts me 02 -> 0 to 30 and 2 to 32.
and this is what i get (Display as HEX in array properties). i just need the line string of the txt to be interpreted as a hex and build an array.
any help will be appreciated. thanks in advance.
Solved! Go to Solution.
08-31-2016 09:54 AM - edited 08-31-2016 09:58 AM
Hi afetsis,
replace the ConvertToHexString by a TypeCast function (in the innermost loop)…
General recommendation:
When you want quick help you should attach a "real" VI (or atleast a snippet) instead of pictures. Images are hard to debug with LabVIEW!
08-31-2016 11:01 AM - edited 08-31-2016 11:01 AM
Your code is too complicated. First of all, there is a right-click option for the Read Text File to read the lines. Then you can autoindex on the lines, eliminating one of your loops. Secondly, you can do all of the parsing and conversion of your line of data with just the Spreadsheet String To Array function.
08-31-2016 12:58 PM
eh. thanks for that but been using labview for about a month and im a bit noob.