News:

  • October 12, 2025, 06:37:06 PM

Login with username, password and session length

Author Topic: double word help  (Read 4083 times)

blglaw

  • Newbie
  • *
  • Posts: 7
double word help
« on: August 25, 2008, 10:11:41 AM »
I am trying to use BCD_INT32 with my C-more micro graphic display to enter in a value for inches for a length measuring system.  I can enter the value into the display, 1234.56" but when the PLC looks at the same location, it sees 34.56".  I believe it needs to look at 2 Vmem locations.  How do i set the PLC to look at double word location?  I am using greater than/less than functions to compare  my lengths and slow down my motor and then stop.  Is this done in the Memory editor and with it then  look at both words? ???

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: double word help
« Reply #1 on: August 25, 2008, 10:25:30 AM »
Relationals only work with single word values.  There is a CMPD (Compare Double) box that will perform the operation, but as a function, not as inline contacts.  You will need to look at the SP60/61/62 to see the result of the comparison.  I recommend looking at Chapter 5 in the User Manual at the CMPD instruction description.

MikeS

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 254
    • Host Engineering, Inc.
Re: double word help
« Reply #2 on: August 25, 2008, 10:52:23 AM »
you can use a pair of relational contacts - one comparing the upper v-memory location with the upper word of your value, the other comparing the lower v-mem with the low half of the value -  but that's very ugly and hard to maintain.

the best answer is to use the cmpd instruction with it's sp60, 61 & 62 bits to do the comparison. using math functions with sp bits isn't much better, but it's much more maintainable over the long haul.
Good design costs a lot. Bad design costs even more.

blglaw

  • Newbie
  • *
  • Posts: 7
Re: double word help
« Reply #3 on: August 26, 2008, 09:03:23 AM »
OK....thanks.  That is what i figured out.  I just have to get it to work now. 
Thanks again,
Bill