News:

  • June 29, 2026, 07:15:10 AM

Login with username, password and session length

Author Topic: Labeling a bit in a v register  (Read 9265 times)

cyounger

  • Jr. Member
  • **
  • Posts: 16
Labeling a bit in a v register
« on: December 19, 2014, 02:34:37 PM »
Does anyone know how I can assign a nickname to say a v0=1,or a 2 and so on.  I tried in the documentation editor and I can not see it in the ladder.  I am trying to make it easy for someone to look at the program and the v0 would have a nickname for which bit is on.
Thanks,
Chris

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: Labeling a bit in a v register
« Reply #1 on: December 19, 2014, 02:51:44 PM »
Are you wanting to document the bit cast
V0:0 is bit 0 of V0
V0:1 is bit 1 of V0
...
V0:15 is bit 15 of V0

Or are you wanting to enumerate constants for the various possible values for V0 (e.g. state)
value of
0 HomePosition
1 Running
2 Idling
3 WarmingUp
4 ShutDown

Do-more can do both.

Bit casts, go to the Element Browser (F9) and enter the cast (e.g. V0:15) and set its Nickname to whatever you want, and hit Write Details.  Or go to the Documentation Editor (Ctrl+D) and hit the Add records button in the view's toolbar (first button) and enter the cast in the Element field, enter the Nickname, then hit the Add Record button.

Symbolic Constants can be done via the Documentation Editor (Ctrl+D).  Hit the Symb button in the view's toolbar (Symbolic Constant) (2nd button).  Give the symbolic name in the Constant Name field, then enter the value (you can enter it as decimal constant, octal constant, hexadecimal constant, or real constant).

Note that when you use Symbolic Constants, that does NOT mean that the constant of "0" is "HomePosition" EVERYWHERE.  No.  You must use the element "HomePosition" specifically where that means something (say in a relational contact).  That element IS "HomePosition" that is a symbolic constant with a value of 0.  It is NOT the "constant 0", which is just a value.  Basically, use the text "HomePosition" everywhere you want to reference that named constant, but use "0" where you just need the number 0.

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Labeling a bit in a v register
« Reply #2 on: December 19, 2014, 02:57:02 PM »
If I understand you question correctly, then what you are wanting is not possible. You cannot nickname the 'status' of a register.

However you could add a:
Code: [Select]
STRPRINT
Print to: SL1
Automatically insert space after each item: Checked
Print Script: Lookup(V0:0,"","Bit 0 On") Lookup(V0:1,"","Bit 1 On") Lookup(V0:2,"","Bit 2 On") Lookup(V0:3,"","Bit 3 On")
Etc.

Now all you have to do is look at SL1 and you can see the status of each bit.

EDIT: See franji1's post above
« Last Edit: December 19, 2014, 02:58:58 PM by plcnut »
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: Labeling a bit in a v register
« Reply #3 on: December 19, 2014, 02:58:56 PM »
One side note on Symbolic Constants.  Even though the element "HomePosition" is different than the element "0", if you do a FIND Ctrl+F of the element "0", it will find it in both elements, as long as the "Match Exactly" is UNchecked.  If you do check "Match Exactly" in the Find dialog to find element "0", it will ONLY find the element "0", not the symbolic constant "HomePosition".
« Last Edit: December 19, 2014, 03:00:45 PM by franji1 »

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: Labeling a bit in a v register
« Reply #4 on: December 19, 2014, 03:02:52 PM »
If I understand you question correctly, then what you are wanting is not possible. You cannot nickname the 'status' of a register.
Yet another valid meaning.  And I like the solution!  That can work with HMI's and Designer!