adccommunitymod (AutomationDirect) asked a question.

For/Next and Pointer

Created Date: July 02,2003

Created By: clasentech

**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****

OK I'm doing something wrong. Please advise. I have 3 timers (t0, t1, t2) and 3 counters (ct0, ct1, ct2). Several inputs, but the important one here is X2 which starts my for/next loop. t0, t1, t2 need to transfer to v3000, v3001, v3002 and then the next time v3003, v3004, v3005 then v3006, v3007, v3010 and so on. The counters need to do the same thing but v5000 on. I 've made several attemps. This idea below has not been tried but I think I'm on the right track. sp0 - lda o0 - out v2000 (pointer setup) - lda o1000 - out v4000 x2 - pd c2 c2 - for k3 sp1 - ld p2000 - out p3000 - ld p4000 - out p5000 sp1 - incb v2000 - incb v3000 - incb v4000 - incb v5000 - next Thank you!


  • adccommunitymod (AutomationDirect)

    Created Date: July 02,2003

    Created by: clasentech

    OK I'm doing something wrong. Please advise.

    I have 3 timers (t0, t1, t2) and 3 counters (ct0, ct1, ct2). Several inputs, but the important one here is X2 which starts my for/next loop. t0, t1, t2 need to transfer to v3000, v3001, v3002 and then the next time v3003, v3004, v3005 then v3006, v3007, v3010 and so on. The counters need to do the same thing but v5000 on.

    I 've made several attemps. This idea below has not been tried but I think I'm on the right track.

    sp0 - lda o0

    - out v2000 (pointer setup)

    - lda o1000

    - out v4000

    x2 - pd c2

    c2 - for k3

    sp1 - ld p2000

    - out p3000

    - ld p4000

    - out p5000

    sp1 - incb v2000

    - incb v3000

    - incb v4000

    - incb v5000

    - next

    Thank you!

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: July 02,2003

    Created by: bcarlton

    You didn't set up pointers to V3000 and V5000. You are using their contents as pointer to somewhere (?). You did well with the pointers to the accumulated value of the timers and counters.

  • adccommunitymod (AutomationDirect)

    Created Date: July 02,2003

    Created by: clasentech

    How would you do that? Like this?

    sp0 - lda o0

    - out v2000 (pointer setup)

    - lda o1000

    - out v4000

    - lda o3000

    - out v3000

    - lda 05000

    - out v5000

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: July 02,2003

    Created by: bcarlton

    There's no reason the pointers have to be that far apart in memory. Lets just start them at V2000

    sp0 - lda o0

    - out v2000 (pointer setup)

    - lda o1000

    - out v2001

    - lda o3000

    - out v2002

    - lda 05000

    - out v2003

    Then your processing code becomes

    x2 - pd c2

    c2 - for k3

    sp1 - ld p2000

    - out p2002

    - ld p2001

    - out p2003

    sp1 - incb v2000

    - incb v2001

    - incb v2002

    - incb v2003

    - next

    The above increments the source (the timers and counters) as well as the destination pointers. If thats not what you want, that is keep the imers and counters the same, then delete the incb of V2000 and V2001.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: July 03,2003

    Created by: clasentech

    And the sp0 for the pointer setup is correct right? (first scan only)

  • adccommunitymod (AutomationDirect)

    Created Date: July 03,2003

    Created by: bcarlton

    Yes