Bool turning on in case stament in wrong state?

nz-dave
2023-12-15
2023-12-16
  • nz-dave - 2023-12-15

    I have a case statement running a process.

    during one of the steps it has started calling a bool var that is 2 steps further on in the case?

    i have even tried //commenting it out but it still turns on at the same point in the case.

    i have also run a trace but cant see anything that would trigger it.

    Any Ideas?

    Cheers

     
  • lostcontrol - 2023-12-16

    are you sure it is not used anywhere else.?
    does it have an address that could be duplicated perhaps?
    nothing external writing to it?

     
    • nz-dave - 2023-12-16

      pretty sure its not. ive done a cross reference and only have one write that sets it to true.

      Only way i can stop it is to remove the function block call from the main pou that is running said case.

      its got me stumped:/

       
  • lostcontrol - 2023-12-16

    i would be looking at what the case variable is doing then..
    sounds like there might be a logic race going on

     
    • nz-dave - 2023-12-16

      I had the FB called via a for loop to call a few instances of my FB

      I have removed it the for loop and just called them 1 by 1. Seems to have sorted the problem.

      tho, i have other FB's and for loops doing the same thing but they are all fine.

      below is basically what was happening.

      var:
      mVibrator : ARRAY[1..GVL_Settings.Number_Of_Products] OF Main_Vibrator;
      end_var

      Controller(PRG) call:

      FOR v := 1 TO GVL_Settings.Number_Of_Products BY 1 DO;
      mVibrator[v] ();
      END_FOR

      So at state 30: the mVibrator[1].start was turning on

      30:
      Main_Mixer.Start := TRUE;
      Process_State := 2;
      IF Main_mixer.Done THEN
      Main_Mixer.Start := FALSE;
      Control_State := 40;
      END_IF

      but its not till state 50: that it is actual in the code.

      50:
      Main_Suction_valve.Open_Input := TRUE;
      mVibrator[1].Start := TRUE;
      Process_State := 4;
      IF GVL_Weigh_hopper.LoadCell_Weight = 0 THEN
      Main_Suction_valve.Open_Input := FALSE;
      mVibrator1.Start := FALSE;
      Control_State := 60;
      END_IF

      Thanks for your input.

       

      Related

      Talk.ru: 1


Log in to post a comment.