News:

  • September 25, 2026, 06:33:57 AM

Login with username, password and session length

Author Topic: Subscrib effecting 2nd 'Real' result  (Read 10339 times)

DavidS

  • Full Member
  • ***
  • Posts: 26
Subscrib effecting 2nd 'Real' result
« on: December 16, 2021, 12:10:48 PM »
I am using the Subscrib to convert 2 consecutive Unsigned Words from an MRX into a Real value. The set up is as follows:
Source 'chillerAV13' (user defined memory Unsigned Word), As, DWord Real, Destination 'chillerAR7' (user defined memory Real), Number of Elements 2, Word Swap.
The issue I am having is, this instruction is writing over the next Real Value 'chillerAR8'. It is my understanding that the '# of Elements' applies to the source, and the result should land in only 1 Real register. If this correct? Or, is the Publish reading from 2 Unsigned Words, and Writing to 2 Real registers. Also, when I search for 'chillerAR8', the search lands me on the Subscib that only has the 'chillerAR7'. Does the Number of Elements, apply to both the Input, and Output of the Subscib.
Thanks for comments and insight.
DavidS

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Subscrib effecting 2nd 'Real' result
« Reply #1 on: December 16, 2021, 12:25:57 PM »
No.  # of Elements is the Do-more element, not # of Modbus HRs (remote element).

So, it should be 1, for 1 real.  So for a REAL, # of HR would be 2x number of elements.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Subscrib effecting 2nd 'Real' result
« Reply #2 on: December 16, 2021, 12:33:45 PM »
Also, casts are NOT needed (:R cast would not work with odd word address), so the Source in SUBSCRIB is more about the memory address of the element (e.g. chillerAV13), and then the "As DWORD Real" tells the PLC to interpret that PLC memory address as a DWORD Real (i.e. 32 bit IEEE Float), so chillerAV13 and chillerAV14 are looked at as a 32 bit REAL value.

DavidS

  • Full Member
  • ***
  • Posts: 26
Re: Subscrib effecting 2nd 'Real' result
« Reply #3 on: December 16, 2021, 12:41:11 PM »
I am reading 2 unsigned words in the MRX starting with 'chillerAV13', and having the the Subscrib convert the 2 (# of Words) unsigned words 'chillerAV13' & 'chillerAV14', to a Real 'chillerAR7'. That is working fine. But the Subscrib is clearing 'chillerAR8' which should have nothing to do with the Subscrib if the # of Words only applies to the input of unsigned words, and not to the output which should be a single Real word 'chillerAR7'.
I have tested this by trying to set a value to 'chillerAR8' and it remains 0. As soon as I disable the rung with the Subscrib that converts 'chillerAV13' for 2 words to 'chillerAR7', 'chillerAR8' works fine. I can set any value to chillerAR8, but as soon as I enable the rung with the Subscrib with chillerAR7 as the destination, chillerAR8 stays at 0, and I can not set a value.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Subscrib effecting 2nd 'Real' result
« Reply #4 on: December 16, 2021, 12:50:17 PM »
SUBSCRIB of 2 elements is doing 2 REALS.  Change SUBSCRIB to do 1 REAL.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Subscrib effecting 2nd 'Real' result
« Reply #5 on: December 16, 2021, 12:51:24 PM »
Make sure you are describing the format of chillerAV13 as a DWORD REAL, not WORD.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Subscrib effecting 2nd 'Real' result
« Reply #6 on: December 16, 2021, 12:54:26 PM »
I am making some assumptions here.

chillerAV13 and chillerAV14 are two halves of a 32 bit IEEE float, correct (this is what I am assuming)?

Or are they literally just 2 unsigned words, 0-65535?  I assume not.

DavidS

  • Full Member
  • ***
  • Posts: 26
Re: Subscrib effecting 2nd 'Real' result
« Reply #7 on: December 16, 2021, 02:08:52 PM »
Your assumption is correct, they are 2 halves of a 32 bit IEEE Float.
Changing the Subscrib to 1 Element from 2, fixed the problem.
I would say the documentation is a little misleading, since it refers to the number of source. "#Elements - number of Source locations to convert."
I will then assume, the Do-More is assuming it needs to read 2 unsigned 16 bit words, in order to fill a 32 bit Real.....

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Subscrib effecting 2nd 'Real' result
« Reply #8 on: December 16, 2021, 02:37:20 PM »
Your assumption is correct, they are 2 halves of a 32 bit IEEE Float.
Changing the Subscrib to 1 Element from 2, fixed the problem.
I would say the documentation is a little misleading, since it refers to the number of source. "#Elements - number of Source locations to convert."
I will then assume, the Do-More is assuming it needs to read 2 unsigned 16 bit words, in order to fill a 32 bit Real.....

Yes, the documentation is not straight forward.  Basically, it's the description of your Source Address along with the Format, so a WORD address to be viewed as a DWORD, the "source" element size is a DWORD, not a WORD.  SUBSCRIB cross reference got it right (see attachment)   ::)