my stb controller crad

sahu

Member
here the function detels of my stabilizer controller card .

its CCS C code as ...
Code:
/********************************************************************************************
        // Main Stabilizing is done here
********************************************************************************************/
void rl_function_controller(void)
   
  {div_t step_mode;
int1 a=0;
step_mode=div(a,3);
    { ch = CalculateMV(1);  
 switch (step_mode.rem)
          { 
           case 0:
      if ((ch >= 10) && (ch <= 130)) //>95 volt
          {G=1;
          power_level_1();
            break;
           }
          if ((ch >= 137) && (ch <= 167))  //>115 v
          {B=1;
          power_level_2();//RL3=ON
           a=a+1;     //step_mode = step_mode+1;  // goto step 2
            break;
          }
          /* if (ch >= 170) 
           {// state=1;
a=a+1;     //step_mode = step_mode+1;  // goto step 2
                                 break;
           }*/

     case 1:
     
     if (ch < 115) //now  case 2 < 115v 
          {B=1;G=1;
          a=a-1;  // step_mode = step_mode - 1;  // Callback to step 1
        // state=0;;
                break;
          }
         // if (ch < 132)  // //now  case 2 < 137v 
        if ((ch >= 119) && (ch <= 140)) //RL1=ON &  //RL3=OFF
          {C=1;
          power_level_3();
                break;
           }
         // if (ch >= 157)    // //now  case 2 > 137v to 170 v
        if ((ch >= 144) && (ch <= 177)) //RL1=ON &  RL3=ON
          {D=1;
          power_level_4();
              a=a+1;
               break;
          }
        /*if (ch > 180) 
         {  //state=2;    //
   a=a+1;// step_mode = step_mode+1;  // goto step 3
                        break;
         }*/
     case 2:
     
     if (ch < 119) //now  case 2 
          {
        //state=1;// 
 a=a-1;     // step_mode = step_mode - 1;  // Callback to step 1
                break;
          }
        if ((ch >= 122) && (ch <= 141)) //RL1=ON &  RL2=ON &RL3=OFF
          {E=1;
          power_level_5();
              break;
           }
       if ((ch >= 143) && (ch <= 175)) //RL1=ON &  RL2=ON &RL3=OFF
          {F=1;
          power_level_6();
            break;
          }
          }}}

 /***************************************************************************
  Function power_level on selected step
 ****************************************************************************/
void power_level_1(void)  
//{ if (G=1)
{
B=0;
C=0;
D=0;
E=0;
F=0;
            output_low(RL1);
            output_low(RL2);
            output_low(RL3);
            delay_ms(60);
break;
            } //}
void power_level_2(void)  
//{  if (B=1)
{
G=0;
C=0;
D=0;
E=0;
F=0;
           output_high(RL3);
            output_low(RL2);
            output_low(RL1);
             delay_ms(60);
break;
} //}
void power_level_3(void)  
//{  if (C=1)
{
G=0;
B=0;
D=0;
E=0;
F=0;
              output_low(RL3);
              output_high(RL1);
              output_low(RL2);
               delay_ms(60);
break;
} //}
void power_level_4(void)  
//{  if (D=1)
{
G=0;
B=0;
C=0;
E=0;
F=0;
            output_high(RL3);
            output_low(RL2);
            output_high(RL1);
               delay_ms(60);
break;
} //}
void power_level_5(void)  
//{  if (E=1)
{
G=0;
B=0;
C=0;
D=0;
F=0;
              output_low(RL3);
              output_high(RL1);
              output_high(RL2);
                 delay_ms(60);
break;
} //}
void power_level_6(void)  
//{  if (F=1)
{
G=0;
B=0;
C=0;
D=0;
E=0;
            output_high(RL3);
            output_high(RL2);
            output_high(RL1);
               delay_ms(60);
break;
}// }
but it is not work as i want .pl guide me where i wrong ??
 
Hi Sahu.... I'm not entirely happy with your switch statement... The 'break;' statements are in 'if' loops... So if none of the if statemets are true... the next 'case' will be executed.

Code:
switch (x)
   {
   case 1:
      if(a)
         {
          arguments;
         }
       if(b)
         {
          arguments;
         }
       if(c)
         {
          arguments;
         }
      break; ----------> break goes here.
   case 1:
        .................rest...
  }

In your powerlevel functions.. There is no need for the break statements
 
thank u Mr .Ian Rogers
now i remove break statements in my powerlevel functions..
so now code are as ....
Code:
 switch (step_mode.rem)
          { 
           case 0:
      if ((ch >= 10) && (ch <= 130)) 
          {G=1;
          power_level_1();
            //break;
           }
          if ((ch >= 137) && (ch <= 167))  
          {B=1;
          power_level_2();//RL3=ON
           a=a+1;     //step_mode = step_mode+1;  // goto step 2
           // break;
          }
                       break;
     case 1:
     if (ch < 115) 
          {B=1;G=1;
          a=a-1;  // step_mode = step_mode - 1;  // Callback to step 1 (last step)
              //  break;
          }
        if ((ch >= 119) && (ch <= 140)) //RL1=ON &  //RL3=OFF  now  case 2
          {C=1;
          power_level_3();
               // break;
           }
        if ((ch >= 144) && (ch <= 177)) //RL1=ON &  RL3=ON
          {D=1;
          power_level_4();
              a=a+1;  // move to next step
              // break;
          }
                 break;
case 0 work very well . but problem is here
 
May I see the div_t structure?

Also... I have tried and tried, but I cant work out the logic... How do you change the step_mode? The input voltage is monitored! but how the outputs are worked out.

For instance... Relay 1, when activated, applies the input voltage onto the 290v rail ??? OR relay 2 redirects the input voltage to the 200v or 137v rail

I take it that the 22v output should be stable with the voltage at any of the four inputs 6/9/11 & 13 : 1 ratio? What is the point of the output?
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…