Announcement

Collapse
No announcement yet.

Timer Event doesn't work

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Timer Event doesn't work

    Hi,

    In my code, I would use a Timer to send request with a Modbus protocole.

    And my Timer0 never goes ON.

    Here is the code of MagicEvent12 :
    Code:
    func MagicEvent12(var newval)
    if (Modu8state == COM_IDLE)
    telegram[u8id]:= SLAVE_ADDRESS; // slave address telegram[u8fct] := MB_FC_WRITE_REGISTER; // function code telegram[u16RegAdd] := BASE_RHOLD + 0x4B; // start address in slave telegram[u16CoilsNo] := 2; //number of elements (coils or registers) to read telegram[au16reg]:= au16data; // pointer to a memory array au16data[0]:=255; au16data[1]:=255; u8state:=1; //jump to state 4 //ReadyHard := 255; // pour dire on applique les parametres gActionMB := MAJ_FORM0; OldForm := MAJ_FORM0; WriteObject(tStrings,16,0); sys_SetTimer(TIMER0,GetADC_Ready); sys_SetTimer(TIMER0,1000); print("\nStart");
    endif
    endfunc
    And here is the code of GetADC_Ready :
    Code:
    func GetADC_Ready()
    print("\nTimer"); if(au16data[0] == 0xFF)
    print("\nTermine");
    else
    if (Modu8state == COM_IDLE)
    telegram[u8id]:= SLAVE_ADDRESS; // slave address telegram[u8fct] := MB_FC_READ_REGISTERS; // function code telegram[u16RegAdd] := BASE_RHOLD + 0x0820; // start address in slave telegram[u16CoilsNo] := 1; //number of elements (coils or registers) to read telegram[au16reg]:= au16data; // pointer to a memory array au16data[0] := 0; u8state:=1; //jump to state 4
    endif
    endif
    endfunc
    "Start" is printed on the screen, but never "Timer".

    In attachment my complet code.

    Regards.
    Attached Files

  • #2
    Hello SylvainLAURENT,

    Since you are calling a function, you could try to use this function instead:
    Code:
    sys_SetTimerEvent(TIMER0, GetADC_Ready);
    sys_SetTimer(TIMER0,1000); //Start Timer0 (1 second)
    For more information on this, please refer to Diablo16 Internal Functions Manual (page 286).

    Kind regards,
    Sherwin
    Last edited by sherwin4D; 4 weeks ago.

    Comment


    • SylvainLAURENT
      SylvainLAURENT commented
      Editing a comment
      Hi Sherwin,

      With your code, that works fine.

      Thanks you very much for your help.

      Regards.
      Sylvain.

    • sherwin4D
      sherwin4D commented
      Editing a comment
      You're very much welcome.

      BR,
      Sherwin
Working...
X