Author Topic: Largest number in DM  (Read 13865 times)

Bill

  • Newbie
  • Posts: 21
    • View Profile
Largest number in DM
« on: September 16, 2006, 05:29:11 AM »
I am using a DM register as a total products produced counter using each on/off transition of a photocell to increment DM[n] +1.

This works fine until count 32768 when the numbers display negative and decrements.  I am certain it relates to the max value a DM register can hold, but I am uncertain how to overcome this issue.

My HMI reads this register and displays it's value to the machine operator.  Any suggestions?

Bill

  • Newbie
  • Posts: 21
    • View Profile
Re:Largest number in DM
« Reply #1 on: September 16, 2006, 06:41:37 AM »
I just noticed in the manual that these are 16 bit registers. Any tecniques to work around this obstacle would be welcome.

plc_user

  • Newbie
  • Posts: 21
  • I'm a llama!
    • View Profile
Re:Largest number in DM
« Reply #2 on: September 16, 2006, 07:36:26 AM »
Use a 32bit variable like A-Z then store the upper and lower part of the variable in two DM locations.   Look at the SETHIGH16 and GETHIGH16 statements.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Largest number in DM
« Reply #3 on: September 16, 2006, 08:44:06 AM »
How many 32-bit variables do you need? There are another sixteen 32-bit variables EMLINT[1] to EMLINT[16] that you can use for this purpose.

If it is not sufficient, then you need to combine two DM into one by adding a bit more codes:

Say DM[1] and DM[2] are used together:

DM[1] = DM[1]+1
IF DM[1] > 10000
    DM[1] = 0
    DM[2] = DM[2]+1
ENDIF

This way, the total value = DM[2] x 10000 + DM[1]

The maximum count value is 327,670,000  (327 million).
Letting DM[1] rolls over at 10000 make it easier to read but you can increase maximum count by letting it roll over at 32767 which allows up to >1 billion count.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Bill

  • Newbie
  • Posts: 21
    • View Profile
Re:Largest number in DM
« Reply #4 on: September 16, 2006, 09:03:25 AM »
How do I reference these additional 32 bit variables in my touch screen?

I am using modbus.  I only need on 32 bit register.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Largest number in DM
« Reply #5 on: September 16, 2006, 09:21:24 AM »
Unfortunately 32-bit variables in the PLC are not mapped into MODBUS holding register space.

MODBUS only takes in 16-bit number. Your system may refer to a 32-bit number using two consecutive 16-bit modbus register. In that case, then yes, you need to use a 32-bit variable as counter and then use the GETHIGH16 to get the upper 16 bit of the 32-bit variable and store into the adjacent DM so that it become visisble to MODBUS.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Bill

  • Newbie
  • Posts: 21
    • View Profile
Re:Largest number in DM
« Reply #6 on: September 16, 2006, 09:53:39 AM »
Thanks to PLC_USER and Tech support for your help.


plc_user

  • Newbie
  • Posts: 21
  • I'm a llama!
    • View Profile
Re:Largest number in DM
« Reply #7 on: September 16, 2006, 10:07:47 AM »
No problem