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: 

Problem with range of HEX Values

Hello, 

This is my code of randoming 10 hex values in range of 0x0080 (128) to 0x0F80 (3968).

Sometimes i got value over the range i had selected.

Any ideas how to fix that?

 

Attrt_2-1637594743853.png

 

0 Kudos
Message 1 of 6
(850 Views)

Although you hide part of your BD, I can guess that the actual range is 80 to (F80 + 80)=1000.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 6
(835 Views)

We can't see all of your code, but I suspect you are multiplying by the max instead of the difference between the max and min.


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 3 of 6
(834 Views)

Please don't show pictures of code, particularly when we can't clearly see everything and it is difficult to read.  

 

This is a simple Math problem.  LabVIEW provides you with a U(0,1) Random number generator.  You want something that generates integers (an important specification!) in the range of 128 to 3968 (do you want it to include both 128 and 3968, neither, or just one of them?  It matters for the next step).

 

Your Math Problem -- transform a Random Dbl Number in the range [0, 1) (the notation means it can contain 0, but cannot contain 1) into a (uniform) integer distribution in the range [128, 3968] (assuming you want to include both end-points).  Express these values as Hex and you are done.

 

You should be able to do this on your own with pencil and paper, and then transform this to LabVIEW code.  When going from Floats to Integers, think about how you want to round the values.

 

Bob Schor

0 Kudos
Message 4 of 6
(829 Views)

See if you have got this function on your Numeric palette, makes life easy for you.

santo_13_0-1637598637953.png

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 5 of 6
(821 Views)
  1. Show us your code.
  2. Understand the typecast function (No, wiring a string constant with a format %04x is completely pointless! Only the type matters, the value is irrelevant. Any string will do and since a string is the default type, you don't even need to write anything to the top. Similarly, I have my doubts that the partially hidden typecast functions on the left do anything really useful. Why don't you use numeric controls instead and eliminate the middle man??? You can change the display format of the numeric controls to hex with four digits).
0 Kudos
Message 6 of 6
(792 Views)