Robot can't work with LCD display

When our robot uses LCD,sometimes it will not be controlled。The robot’s motor will keep the last power sport.
I think my program isn’t worry,because if we don’t use LCD,our robot will work well.
Our program is wroten by easyC not only V4 but also V5.

Hello linyoc,

We’re sorry to hear that you’re having this problem. Could you please send a copy of your code so we can better troubleshoot?

Thank you,
Jessi

My OperatorControl function is made from many functions and my english isn’s very good,so i am sorry that you maybe read it difficulty:D。


void OperatorControl ( unsigned long ulTime )
{
      OCInitialize ( ) ;
      while ( 1 )
      {
            InfInput ( ) ;
            OutSpeedOperation ( ) ;
            PowerVariablesSet ( ) ;
            if ( AllStopBnt == 0 )
            {
                  MotorSet ( ) ;
            }
            else
            {
                  Stop_All ( ) ;
            }
            GraphicDisplay (   ) ;
            LCD ( ) ;
      }
}
void OCInitialize ( void )
{
      InitLCD ( 1 ) ;
      SetLCDLight ( 1 , 1 ) ;
      SetLCDText ( 1 , 1 , "     WELCOME    " ) ;
      SetLCDText ( 1 , 2 , "PleaseTouchBut." ) ;
      StartLCDButtonsWatcher ( 1 ) ;
      StartEncoder ( LeftEncoderPort ) ;
      StartEncoder ( RightEncoderPort ) ;
      PresetEncoder ( LeftEncoderPort , 0 ) ;
      PresetEncoder ( RightEncoderPort , 0 ) ;
}
void InfInput ( void )
{
      GetLCDButtonsWatcher ( 1 , &button1_LCD1 , &button2_LCD1 , &button3_LCD1 ) ;
      Potentiometer = GetAnalogInput ( PotentiometerPort ) ;
      BallDirectControllerUpBtn = GetJoystickDigital ( 1 , 6 , 2 ) ;
      BallDirectControllerDownBtn = GetJoystickDigital ( 1 , 6 , 1 ) ;
      Battery = GetMainBattery ( ) ;
      AllStopBnt = GetJoystickDigital ( 1 , 8 , 1 ) ;
      IdlerWheelControl = GetJoystickAnalog( 1 , 3 ) ;
      OutSpeedDownBnt = GetJoystickDigital ( 1 , 7 , 1 ) ;
      OutSpeedUpBnt = GetJoystickDigital ( 1 , 7 , 2 ) ;
      OutSecondSpeedBnt = GetJoystickDigital ( 1 , 7 , 4 ) ;
      OutThirdSpeedBnt = GetJoystickDigital ( 1 , 8 , 3 ) ;
      SpeedRecBtn = GetJoystickDigital ( 1 , 8 , 4 ) ;
      OutHighSpeedBnt = GetJoystickDigital ( 1 , 7 , 3 ) ;
      LiftUpBnt = GetJoystickDigital ( 1 , 5 , 2 ) ;
      LiftDownBnt = GetJoystickDigital ( 1 , 5 , 1 ) ;
      LCD_Bnt = GetJoystickDigital ( 1 , 8 , 2 ) ;
}
void OutSpeedOperation ( void )
{
      if ( OutSpeedOperationTime == 0 )
      {
            StartTimer ( 3 ) ;
            PresetTimer ( 3 , 1 ) ;
            LastLeftEncoder = GetEncoder ( LeftEncoderPort ) ;
            LastRightEncoder = GetEncoder ( RightEncoderPort ) ;
      }
      OutSpeedOperationTime = GetTimer ( 3 ) ;
      if ( OutSpeedOperationTime >= 1000 )
      {
            NowLeftEncoder = GetEncoder ( LeftEncoderPort ) ;
            NowRightEncoder = GetEncoder ( RightEncoderPort ) ;
            LeftOutRPM = (NowLeftEncoder - LastLeftEncoder) *2/3 ;
            RightOutRPM = (NowRightEncoder -LastRightEncoder)*2/3 ;
            StopTimer ( 3 ) ;
            OutSpeedOperationTime = 0 ;
      }
}
void PowerVariablesSet ( void )
{
      if ( Abs(IdlerWheelControl ) > 30 )
      {
            IdlerWheelSpeed = IdlerWheelControl ;
      }
      else
      {
            IdlerWheelSpeed = 0 ;
      }
      if ( SpeedRecBtn == 1&&SpeedRecMode==0 )
      {
            SpeedRecMode = 1 ;
            LastSpeed = OutSpeed ;
            if ( abs(OutSpeed)+30>=127 )
            {
                  OutSpeed = 127 ;
            }
            else
            {
                  OutSpeed +=30 ;
            }
      }
      if ( SpeedRecMode == 1&& SpeedRecBtn == 0 )
      {
            OutSpeed = LastSpeed ;
            SpeedRecMode = 0 ;
      }
      if ( SpeedRecMode == 0 )
      {
            if ( OutHighSpeedBnt == 1 )
            {
                  OutSpeed =69 ;
            }
            else if ( OutSecondSpeedBnt  == 1 )
            {
                  OutSpeed = 57 ;
            }
            else if ( OutThirdSpeedBnt  == 1 )
            {
                  OutSpeed = 40 ; // 愿闹=旸是当?
            }
            else if ( AllStopBnt == 1 )
            {
                  OutSpeed = 0 ;
            }
            if ( OutSpeedUpBnt == 1 )
            {
                  UpIn = 1 ;
            }
            else if ( OutSpeedDownBnt == 1 )
            {
                  DownIn = 1 ;
            }
            if ( UpIn == 1 && OutSpeedUpBnt == 0 )
            {
                  OutSpeed = OutSpeed + 2 ;
                  UpIn = 0 ;
            }
            if ( DownIn == 1 && OutSpeedDownBnt == 0 )
            {
                  OutSpeed = OutSpeed - 2 ;
                  DownIn = 0 ;
            }
      }
      if ( LiftUpBnt == 1 )
      {
            LiftSpeed = -127 ;
            IdlerWheelSpeed  = -50 ;
      }
      else if ( LiftDownBnt == 1 )
      {
            LiftSpeed = 127 ;
      }
      else
      {
            LiftSpeed = 0 ;
      }
      if ( BallDirectControllerUpBtn == 1 )
      {
            BallDirectControllerPower = 127 ;
      }
      else
      {
            if ( BallDirectControllerDownBtn == 1 )
            {
                  BallDirectControllerPower = -127 ;
            }
            else
            {
                  BallDirectControllerPower = 0 ;
            }
      }
}
void MotorSet ( void )
{
      Arcade4_ADVANCED (  15  ) ;
      //Arcade4 ( 1 , 2 , 1 , LeftFrontPort , RightFrontPort , LeftBackPort , RightBackPort , 0 , 0 , 0 , 0 ) ;
      if ( OutSpeed > 127 )
      {
            OutSpeed = 127 ;
      }
      if ( OutSpeed < 0 )
      {
            OutSpeed = 0 ;
      }
      SetMotor ( OutPort1 , OutSpeed ) ;
      SetMotor ( OutPort2 , -OutSpeed ) ;
      SetMotor ( IdlerWheelPort , IdlerWheelSpeed ) ;
      SetMotor ( LiftPort , LiftSpeed ) ;
      SetMotor ( BallDirectControllerRightPort , BallDirectControllerPower ) ;
      SetMotor ( BallDirectControllerLeftPort , -BallDirectControllerPower ) ;
}
void Arcade4_ADVANCED ( int Threshold )
{
      int Axis_X; 
      int Axis_Y; 

      Axis_X = GetJoystickAnalog( 1 , 1 ) ;
      Axis_Y = GetJoystickAnalog( 1 , 2 ) ;
      if ( Abs ( Axis_X ) < Threshold && Abs ( Axis_Y ) <Threshold )
      {
            SetMotor ( LeftFrontPort , 0 ) ;
            SetMotor ( LeftBackPort , 0 ) ;
            SetMotor ( RightBackPort , 0 ) ;
            SetMotor ( RightFrontPort , 0 ) ;
      }
      else if ( Abs ( Axis_X ) < Threshold && Abs ( Axis_Y ) > Threshold )
      {
            SetMotor ( LeftBackPort , Axis_Y ) ;
            SetMotor ( LeftFrontPort , Axis_Y ) ;
            SetMotor ( RightBackPort , -Axis_Y ) ;
            SetMotor ( RightFrontPort , -Axis_Y ) ;
      }
      else if ( Abs ( Axis_X ) > Threshold && Abs ( Axis_Y ) <Threshold )
      {
            SetMotor ( LeftBackPort , Axis_X ) ;
            SetMotor ( LeftFrontPort , Axis_X ) ;
            SetMotor ( RightBackPort , Axis_X ) ;
            SetMotor ( RightFrontPort , Axis_X ) ;
      }
      else if ( Abs ( Axis_X ) >Threshold && Abs ( Axis_Y ) > Threshold )
      {
            Arcade4 ( 1 , 2 , 1 , LeftFrontPort , RightFrontPort , LeftBackPort , RightBackPort , 0 , 0 , 0 , 0 ) ;
      }
}
void Stop_All ( void )
{
      SetMotor ( BallDirectControllerLeftPort , 0 ) ;
      SetMotor ( BallDirectControllerRightPort , 0 ) ;
      SetMotor ( OutPort1 , 0 ) ;
      SetMotor ( OutPort2 , 0 ) ;
      SetMotor ( IdlerWheelPort , 0 ) ;
      SetMotor ( LiftPort , 0 ) ;
      SetMotor ( LeftFrontPort , 0 ) ;
      SetMotor ( LeftBackPort , 0 ) ;
      SetMotor ( RightBackPort , 0 ) ;
      SetMotor ( RightFrontPort , 0 ) ;
}
void LCD ( void )
{
      if ( button1_LCD1 == 1 )
      {
            LCDMode = 1 ;
      }
      else if ( button2_LCD1  == 1 )
      {
            LCDMode = 2 ;
      }
      else if ( button3_LCD1  == 1 )
      {
            LCDMode = 3 ;
      }
      if ( LCDMode == 1 )
      {
            SetLCDText ( 1 , 1 , "Battery" ) ;
            SetLCDText ( 1 , 2 , "%f" , Battery ) ;
      }
      else if ( LCDMode == 2 )
      {
            SetLCDText ( 1 , 1 , "OutSpeed:%d" , OutSpeed ) ;
            SetLCDText ( 1 , 2 , "Pot:%d" , Potentiometer ) ;
      }
      else if ( LCDMode == 3 )
      {
            SetLCDText ( 1 , 1 , "TEAM ID 8432B" ) ;
            SetLCDText ( 1 , 2 , "ProgramVer:0.7.7" ) ;
      }
      if ( LCD_Bnt == 1 )
      {
             LCD_BntIn = 1 ;
      }
      if ( LCD_BntIn == 1 && LCD_Bnt == 0 )
      {
            LCDMode +=1 ;
            if ( LCDMode >3 )
            {
                  LCDMode =1 ;
            }
            LCD_BntIn = 0 ;
      }
}
void GraphicDisplay ( void )
{
      ClearGD ( 6 , 0 , 10 , 79 , 0) ;
      PrintTextToGD ( 1 , 32 , 0 , "Graphic Display\n" ) ;
      PrintTextToGD ( 2 , 29 , 0 , "Program ver. 0.7.7.0\n" ) ;
      PrintTextToGD ( 3 , 0 , 0 , "  Programed by Linyoc for Create Future Robots and Share with all Teams in CFR\n" ) ;
      PrintTextToGD ( 5 , 31 , 0 , "Variables Screen\n" ) ;
      PrintTextToGD ( 6 , 1 , 0 , "OutSpeed:%d\n" , OutSpeed ) ;
      PrintTextToGD ( 7 , 1 , 0 , "Battery:%f\n" , Battery ) ;
      PrintTextToGD ( 8 , 1 , 0 , "LeftOutSpeed(RPM):%f\n" , LeftOutRPM ) ;
      PrintTextToGD ( 9 , 1 , 0 , "RightOutSpeed(RPM):%f\n" , RightOutRPM ) ;
      PrintTextToGD ( 10 , 1 , 0 , "Potentiometer:%d\n" , Potentiometer ) ;
}

And this problem always happens when we doesn’t control our robot long time。

linyoc,

We are investigating this problem and will get back with you once we have possible causes.

In the meantime, have you tried removing functions and re-downloading? Have you tried removing all code related to the LCD and the motors and slowly adding it back line by line? By breaking your code apart into smaller pieces, it should help locate where your bugs are.

Hope this helps!
Jessi

Each of our functions was built one by one,and this problem is always exists.Last year we already had this problem.This year we rewrite our code,but this problem still exists.Do you have any feedback about this problem before?

linyoc,

Please send your code directory as a zip file to support@vexrobotics.com. Use “Robot can’t work with LCD display” as the e-mail subject. The directory usually has files with a BDS, ECPX, HEX, dat, txt and h extensions. You say the problem happens when you don’t control the robot for a long time. Is that 10 minutes, 20 minutes? What kind of VEXnet key are you using, the black or the white?

What version of BootLoad and Master code is in the Cortex and Joystick? You can determine the Bootload and Master code versions with easyC by clicking on Tools / Upgrade VEXnet Firmware.

I’ve send a message with my code.
What time robot can’t be controlled is uncertain,may occur at any time.When it happened,we must reboot Cortex(rebooting Joystick is useless),So I don’t know how long it will last, I think maybe it won’t return to normal.
Version of BootLoad and Master code is 4.25.

and we use vex net key2.0