How to slow down the clock of the main execution program?

Vect
2011-07-13
2011-07-18
  • Vect - 2011-07-13

    I have a program that does more or less this:

    Pointer_Row:=11
    flag1:=IndirectColumnWithPointerRow.0
    flag2:=IndirectColumnWithPointerRow.1
    flag3:=IndirectColumnWithPointerRow.2
    flag4:=IndirectColumnWithPointerRow.3
    

    When the Pointer_Row changes its value it triggers an interrupt which should put some values on the IndirectColumnWithPointerRow variable, de problem is that the pogram main execution seems to be too fast no matter what I try, the event run but is not enough faster for giving the value to the main program, hence an error.

    I've tried to stop the program with SysLibIECTask, also changing the priorities, also creating another task... but nothing of that solves the problem, and this is because I cannot change the instruction above since it's fundamental for something else to work...

    Thanks in advance

     
  • shooter - 2011-07-15

    So you generate an interrupt on line 1 oke
    then the interupt should do its job and update the database

    after that you check the flags
    correct?

    So this checking should only be done when interupt is finished?
    so just wait until interuptroutine is finished (put a flag as last line in your interupt.)
    routinedone := set

    in main write if routinedone is true then
    stop interupt
    check flags
    routinedone :=reset;
    start interupt

    an interupt on this level is only checked after a pou ends.
    even with very slow processor this will happen.
    basic interupt knowledge.
    i did it on the Z80 years ago.

     
  • Vect - 2011-07-18

    shooter hat geschrieben:
    So you generate an interrupt on line 1 oke
    then the interupt should do its job and update the database
    after that you check the flags
    correct?
    So this checking should only be done when interupt is finished?
    so just wait until interuptroutine is finished (put a flag as last line in your interupt.)
    routinedone := set
    in main write if routinedone is true then
    stop interupt
    check flags
    routinedone :=reset;
    start interupt
    an interupt on this level is only checked after a pou ends.
    even with very slow processor this will happen.
    basic interupt knowledge.
    i did it on the Z80 years ago.

    The problem seems to be rather that codesys doesn't like to interrupt the main program, even when directly using flags the interrupt was too slow and gave incorrect values. I'm doing this with the PLCwinNT software PLC and it seems that it doesn't have a proper way to stop the main program, just like you say... you did that on z80s, I did dad too (and in later microcontrollers with complete success) but it doesn't work on PLCwinNT.

     

Log in to post a comment.