ni.com is currently experiencing unexpected issues.

Some services may be unavailable at this time.

取消
显示结果 
搜索替代 
您的意思是: 

decimal as hex without converting

So I have an unusal requirement. Essentially I'm interfacing with a serial board that takes in 4 hex numbers as its commands followed by a line feed (0x0A). If I use string input boxes with the display set to 'Hex', I can interface corrected and the board executes the commands are run correctly.

 

The issue is that it takes in these hex numbers as one would read them in decimal*. That is 0x01 would be 1 but 0x10 would be executed as 10 not as 16. As I said string inputs as 'hex' displays works just fine. 

 

But I would like to use visual (numeric) indicators in the user interface. Say, for instance, the input is a knob with the scale set from 1 to 16 and I want to send this as hex 0x01 to 0x16.

 

I tried using the type cast as seen below. It works just fine from 1 to 9 but 10 gets converted to 0x0A rather than 0x10. 

 

Any suggestions of how I can do this? Thanks for your time. 

 

* Don't ask me why it does this...

0 项奖励
1 条消息(共 15 条)
4,776 次查看

You are typecasting from a number to a string.  That is like using the chr$ function in basic.

 

I don't understand what you are trying to do with this serial board.  x10 is hex 10 or decimal 16.

 

A knob can only be set for decimal values.  So 1 to 16 is 16 different values.  Hex  x01 to x16 is 22 different values.  With a decimal based knob, there is no way you are going to get the some of your hex values such as x0A x0B   ... x0F.

0 项奖励
2 条消息(共 15 条)
4,763 次查看
Why not just use a numeric control that's set to display in Hex? This can be done using the "Format & Precision" tab in the numeric control's Properties sheets.
0 项奖励
3 条消息(共 15 条)
4,753 次查看
Note: You can set a knob to be in Hex, but there's a LabVIEW bug depending on which version you have that does not let you set the format to Hex using the Property sheets. You have to set it programmatically.
0 项奖励
4 条消息(共 15 条)
4,748 次查看

Ravens Fan wrote:

You are typecasting from a number to a string.  That is like using the chr$ function in basic.

 

I don't understand what you are trying to do with this serial board.  x10 is hex 10 or decimal 16.

 

A knob can only be set for decimal values.  So 1 to 16 is 16 different values.  Hex  x01 to x16 is 22 different values.  With a decimal based knob, there is no way you are going to get the some of your hex values such as x0A x0B   ... x0F.


Advanced editing mode will let you specify "%x" to get a hex display.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 项奖励
5 条消息(共 15 条)
4,746 次查看

I was looking at it in LV2009f2.  The property sheet had hex display grayed out.  And the advanced editing mode didn't allow %x either.

 

In LV8.6, the property sheet has a weird flickering when trying to pick hex.  And the advanced editing mode doesn't allow %x either.

 

In LV8.5 and 8.2, grayed out on property sheet.  Advanced editing mode still doesn't allow %x.

 

I noticed something interesting.  In LV8.5 and 8.2, a valid display string is a lit green LED, an invalid display string is an unlit green LED.  In 8.6 and 2009, the an invalide display string is a lit red LED.

 

So there does seem to be a bit of a bug in LV8.6.  But I wasn't able to get any of them to show hex display for a knob.

 

But Smercurio's property node method does work.

Message Edited by Ravens Fan on 11-30-2009 10:53 AM
0 项奖励
6 条消息(共 15 条)
4,734 次查看

Ravens Fan wrote:

I was looking at it in LV2009f2.  The property sheet had hex display grayed out.  And the advanced editing mode didn't allow %x either.

 

In LV8.6, the property sheet has a weird flickering when trying to pick hex.  And the advanced editing mode doesn't allow %x either.

 

In LV8.5 and 8.2, grayed out on property sheet.  Advanced editing mode still doesn't allow %x.

 

I noticed something interesting.  In LV8.5 and 8.2, a valid display string is a lit green LED, an invalid display string is an unlit green LED.  In 8.6 and 2009, the an invalide display string is a lit red LED.

 

So there does seem to be a bit of a bug in LV8.6.  But I wasn't able to get any of them to show hex display for a knob.

 

But Smercurio's property node method does work.

Message Edited by Ravens Fan on 11-30-2009 10:53 AM

You need to set the representation to an integer type in order to display the valua as binary, octal or hex. 


"Should be" isn't "Is" -Jay
0 项奖励
7 条消息(共 15 条)
4,726 次查看

Jeff Bohrer wrote:
You need to set the representation to an integer type in order to display the valua as binary, octal or hex. 

You're right.  That does make a difference, and does make some sense.

 

There are still different random assorted bugs among the different versions.

 

LV2009, grayed out, but advanced editing does work.

LV8.6 and 8.5, seem to be fine on the property sheet.

LV8.2, not greyed out, but neither property sheet nor advanced editing work.

Hmm, you wouldn't think bugs would come and go, and come and go again.

 

 

 

8 条消息(共 15 条)
4,715 次查看

Hi butIdo...,

 

what you need is called BCD (Binary Coded Decimals) format. I'm sure there are already such threads, so search for them!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 项奖励
9 条消息(共 15 条)
4,708 次查看

Ravens Fan wrote:

Jeff Bohrer wrote:
You need to set the representation to an integer type in order to display the valua as binary, octal or hex. 

You're right.  That does make a difference, and does make some sense.

 

There are still different random assorted bugs among the different versions.

 

LV2009, grayed out, but advanced editing does work.

LV8.6 and 8.5, seem to be fine on the property sheet.

LV8.2, not greyed out, but neither property sheet nor advanced editing work.

Hmm, you wouldn't think bugs would come and go, and come and go again.

 

 

 


Agreed.

 

NI Please have an App engineer look inot the behaviour of the properties screen for the Knob.

 

And please add to the attached list that when you show the digitial display, it does not let us set the display format as Hex (even after maining it a U8).

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
10 条消息(共 15 条)
4,704 次查看