adccommunitymod (AutomationDirect) asked a question.

Math Logic NOT working all the time

Created Date: July 26,2012

Created By: eric14779

**** 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.****

I have a DL250-1 CPU, LookoutDrect, H2-CTRIO based motion control project I am fighting, I do not think my formats or operators are right.... I have attached a PDF file of the stage of code. The first thing it does is read the CTRIO registers. I think I got this right (came from manual chapter 8 page 11) Next it advances the "Pointer " (CTA0) to get the next move count from LKD. I am assuming that there can be a lag until V10000 is updated so I have a delay built in ONDTMR T40 (set to 1 sec) It seems to help with data starvation. Then I start some basic math to determine the next move distance (in counts) I convert my Decimal values from LKD & CTRIO to BCD, Then I load the next position ( V11000) and I subtract the Current Position (V11002) and OUT the result to ( V10004) "Difference " And set C30 (difference calculated) Now I LDD my max carriage travel (d282 hex) convert to BCD, OUTD to V12000 (to use in data view), then SUBD V11020 (current stroke count BCD value from the CTRIO) OUTD V10006 Remaining Travel, then CMPD to V10004 difference. The next Rung is where I use the SP60 (less than) and SP70 (Negative) to decide if I need to JUMP to the "Regrip " Stage (making sure that the CTRIO has been read, Difference calculated and the Delay timer has elapsed. If TRUE the it sets some things and jumps to the REGRIP stage. Also I need to do a regrip when the front end of the part is out far enough so the far end clamp on the carriage can grip it (rung 13 & 14) then Rung 15 assumes that the other 2 conditional checks are false and Jumps to the GOTO Stage witch loads the new V10000 value to the Parameter 3 of the CTRIO and makes the move. Am I doing something wrong? How can I code to be sure I am getting the DATA from LKD without using a delay timer ? Is the delay timer bulletproof ??


  • adccommunitymod (AutomationDirect)

    Created Date: July 26,2012

    Created by: Do-more PE

    Check the last value from LKD against the current value from LKD. If so, then you have new data.

    Load the current value from LKD into the last value from LKD if it is different.

  • adccommunitymod (AutomationDirect)

    Created Date: July 26,2012

    Created by: eric14779

    ADC App Assist,

    thanks for the reply...

    is the rest of the program correct ??

    am I working with the Data types correctly ??

  • adccommunitymod (AutomationDirect)

    Created Date: July 26,2012

    Created by: Do-more PE

    Sorry, I don't have a lot of time today to do a full review. I read the post and made a suggestion based on one of your concerns.

    I wish I had more time to devote to debugging programs, but I have about a dozen things going on including learning about some new products that will be launching soon. ;)

    Hopefully one of the forum regulars will be by and be able to devote some time to it.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: July 26,2012

    Created by: eric14779

    I have a DL250-1 CPU, LookoutDrect, H2-CTRIO based motion control project I am fighting, I do not think my formats or operators are right....

    I have attached a PDF file of the stage of code.

    The first thing it does is read the CTRIO registers. I think I got this right (came from manual chapter 8 page 11)

    Next it advances the "Pointer " (CTA0) to get the next move count from LKD. I am assuming that there can be a lag until V10000 is updated so I have a delay built in ONDTMR T40 (set to 1 sec) It seems to help with data starvation.

    Then I start some basic math to determine the next move distance (in counts) I convert my Decimal values from LKD & CTRIO to BCD, Then I load the next position ( V11000) and I subtract the Current Position (V11002) and OUT the result to ( V10004) "Difference " And set C30 (difference calculated)

    Now I LDD my max carriage travel (d282 hex) convert to BCD, OUTD to V12000 (to use in data view), then SUBD V11020 (current stroke count BCD value from the CTRIO) OUTD V10006 Remaining Travel, then CMPD to V10004 difference.

    The next Rung is where I use the SP60 (less than) and SP70 (Negative) to decide if I need to JUMP to the "Regrip " Stage (making sure that the CTRIO has been read, Difference calculated and the Delay timer has elapsed. If TRUE the it sets some things and jumps to the REGRIP stage.

    Also I need to do a regrip when the front end of the part is out far enough so the far end clamp on the carriage can grip it (rung 13 & 14)

    then Rung 15 assumes that the other 2 conditional checks are false and Jumps to the GOTO Stage witch loads the new V10000 value to the Parameter 3 of the CTRIO and makes the move.

    Am I doing something wrong?

    How can I code to be sure I am getting the DATA from LKD without using a delay timer ?

    Is the delay timer bulletproof ??

    Expand Post