News:

  • September 30, 2026, 06:33:31 PM

Login with username, password and session length

Author Topic: Delta Contact for a Range  (Read 27350 times)

Bolt

  • Hero Member
  • *****
  • Posts: 598
Delta Contact for a Range
« on: August 15, 2019, 09:48:11 AM »
Is there an easy way to have a range of Delta Contacts to trigger a rung?  For example, ORDLT C600:C631?  ORDLT N600:N631? I think bits could be written to a (double)word and compared, but how would I do integers?  I don't think a sum would work, as 2 values could swap in the same scan and not trigger.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Delta Contact for a Range
« Reply #1 on: August 15, 2019, 10:04:04 AM »
Is there an easy way to have a range of Delta Contacts to trigger a rung?  For example, ORDLT C600:C631?  ORDLT N600:N631? I think bits could be written to a (double)word and compared, but how would I do integers?  I don't think a sum would work, as 2 values could swap in the same scan and not trigger.

Cast. C0:D = C0-C31.

That has limited benefit for words like N, but you can get 2 N locations with N0:D.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Delta Contact for a Range
« Reply #2 on: August 15, 2019, 07:10:46 PM »
You could probably write a subroutine that would work efficiently. Pass the starting point in N memory and number of registers. Do a for loop comparing the current data with old data which is an offset in High N memory. For instance use an offset of 10,0000.  Previous data stored for N0 to N100 would be stored at N10000 to N10100. After the compare you store the new data into the previous data register inside the same loop.
« Last Edit: August 15, 2019, 08:41:27 PM by ATU »

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: Delta Contact for a Range
« Reply #3 on: August 16, 2019, 12:00:39 PM »
I think bits could be written to a (double)word and compared, but how would I do integers?  I don't think a sum would work, as 2 values could swap in the same scan and not trigger.

What if you checksummed the range and looked at STRDLT MyCheckSum?
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Delta Contact for a Range
« Reply #4 on: August 16, 2019, 01:05:49 PM »
I think bits could be written to a (double)word and compared, but how would I do integers?  I don't think a sum would work, as 2 values could swap in the same scan and not trigger.

What if you checksummed the range and looked at STRDLT MyCheckSum?

With a CRC, this would work well.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: Delta Contact for a Range
« Reply #5 on: August 16, 2019, 03:37:51 PM »
Thanks.  The C0:D is exactly what I was looking for, and then N0:D will work in a pinch.  Checksum seems like too much work for this spot in my project  ???

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Delta Contact for a Range
« Reply #6 on: August 16, 2019, 03:39:28 PM »
Thanks.  The C0:D is exactly what I was looking for, and then N0:D will work in a pinch.  Checksum seems like too much work for this spot in my project  ???

CHECKSUM is an instruction.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: Delta Contact for a Range
« Reply #7 on: August 16, 2019, 03:51:35 PM »
Yes, but how do I enter N600:N632 as the criteria?

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Delta Contact for a Range
« Reply #8 on: August 16, 2019, 04:18:39 PM »
Yes, but how do I enter N600:N632 as the criteria?

CHECKSUM
Buffer N600:UB0
Function CRC16
0 initial
0 offset
ending offset 64
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Delta Contact for a Range
« Reply #9 on: August 16, 2019, 08:25:25 PM »
What if you checksummed the range and looked at STRDLT MyCheckSum?

Great Idea!   I could use that one.

PLCwannabe

  • Hero Member
  • *****
  • Posts: 208
Re: Delta Contact for a Range
« Reply #10 on: August 17, 2019, 11:36:22 AM »
Trying to read between the lines here. I have 50 different C's triggering the same alarm. For me this is 50 rungs of code. Is there a more efficient way to do this with less rungs?

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: Delta Contact for a Range
« Reply #11 on: August 17, 2019, 12:04:02 PM »
Great Idea!   I could use that one.

Yes it is (but not mine)!  I was working on something similar several years ago and another poster suggested that idea, I think it was actually in this forum.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Delta Contact for a Range
« Reply #12 on: August 17, 2019, 12:09:08 PM »
Trying to read between the lines here. I have 50 different C's triggering the same alarm. For me this is 50 rungs of code. Is there a more efficient way to do this with less rungs?

Probably. What is your current logic doing? I'd like to see a couple of your rungs.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

PLCwannabe

  • Hero Member
  • *****
  • Posts: 208
Re: Delta Contact for a Range
« Reply #13 on: August 17, 2019, 12:37:30 PM »
Here is a screenshot of all the c,s triggering a program. It keeps going right down to C1050.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Delta Contact for a Range
« Reply #14 on: August 17, 2019, 12:38:02 PM »
I assumed that you want a one shot any time a C bit goes from 0 to 1. This single rung triggers on 64 C bits.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO