LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

increment the hex number using labview

Solved!
Go to solution

hello everyone

i have one string  like "trans B60A00" in this string last two numbers 00 are the hex numbers and i want to increment only hex number such as 00, 01 till 3A. and i want to increment that number using slider any one can tell me how to do it? 

thank you in advance 

0 Kudos
Message 1 of 12
(1,868 Views)
Solution
Accepted by topic author newmemeber123

What have you tried?  Have you any programming experience in any Computer language that includes working with strings?  How well do you understand the "string structure" of the data you are handling and hope to manipulate?

 

From your (very) brief description, it sounds like you have a string (fixed length?  variable length?) and you want to manipulate the last two characters in the string, treating them as representing Hex numbers and wanting to do an "increment" on the number and use that as a replacement string.

 

Use Tutorials to learn about the LabVIEW String functions (or you can open LabVIEW, open the String Palette, look at the String functions, and read the Detailed Help on the ones whose name suggest they might be appropriate).

 

You basically have the following tasks:

  1. Split the string into two pieces, "Before" and "Last two characters".
  2. Process "Last two characters" as Hex representation of an Integer (what type of integer do you expect for a 2-byte Hex string?  Signed or unsigned?).
  3. Manipulate the integer (sounds like you want to do an increment).
  4. Change the integer result back to a 2-character Hex string (use the String Palette).
  5. Reassemble the two pieces, "Before" and "Transformed two characters".

If you want to learn LabVIEW, you need to do the homework yourself.

 

Bob Schor

Message 2 of 12
(1,856 Views)

 i will try with your suggestions and ask you if i have any questions 

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

Hi, this is working but now im facing problem to  control the with the slider. I mean it should only incrementing value when slider moves. I need to set a range like 00 to 3A in this range slider will move and increment the values. when slider will move then only increment should happen. I have gone through examples on forum but not getting exact idea. can someone help me?

Thank you

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

@newmemeber123 wrote:

Hi, this is working but now im facing problem to  control the with the slider. I mean it should only incrementing value when slider moves. I need to set a range like 00 to 3A in this range slider will move and increment the values. when slider will move then only increment should happen.


I, for one, do not understand what trouble you are having.  Please attach the "code that partly works" (attaching the actual code, meaning a .vi file, is much easier for me to understand and, better, to test than attaching a "picture" of your Block Diagram).  It should (ideally) have the "slider" you mention, and you should explain exactly what you want to do relative to the code you show us.  This makes sure we aren't "answering the wrong question".

 

Here's a question -- have you had enough LabVIEW experience to have encountered using Event Structures to "do things" when you change the value of a Front Panel Control (like this mysterious "slider" you mention)?  Incidentally, this is another "benefit to you" of attaching your code -- it provides us "clues" to your level of LabVIEW expertise so that we can provide the right level of help and explanation ("teaching", as it were).

 

Bob Schor

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

hello, im new here in lab-view and attaching my VI which works fine for increment only once. Now i have to modify it such as the last two hex number of the should increment from 00 to 3A(which is range for slider) using slider at front panel.( Initially number is 00 now. when slider will be move then value should increment from 00 to 3A) now im able to increment only once not in the range and not with the slider.

thank you

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

It works one time because you are searching for 00. You have to split the hex string into an array i.e. [B6,0A,00]. For example, you can use a for loop (for fixed length) or while loop (for variable length) to take off 2 characters from the string each iteration, convert to number and add them to the array. You can then manipulate just the last index of the array.

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

Im bit confused can bit explain in detail or if you any example of it?

Thank you in advance 

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

I explained a general approach to easily manipulate any of the hex numbers.

 

In your case you just want to modify the last 2 characters of you string. So, use 'String Subset' to take the last 2 characters, convert to number and add the value of your slider. Then convert back to string and display the full hex string.

 

But it is good practice to think of a general usage of your programs. Let's say you made the VI to work specifically for modifying the last 2 characters. In the future, for some reason, you want to modify the middle 2 characters. How easily would the be done with your vi? 

 

0 Kudos
Message 9 of 12
(1,728 Views)

Thanks, Yes even i will try that. moreover i have decimal number which i have converted from the last two char already as you can see in the attached Vi. im just not getting how add it to the slider and set the range 0 to 3A(58 decimal). then back to hex string so i can control last two chars using slider.

Thank you 

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