Announcement

Collapse

Technology Forum Has Moved!

The FIRST Tech Challenge Technology forum has moved to a new location! Please take a look at our forum blog for links and instructions on how to access the new forum.

The official blog of the FIRST Tech Challenge - a STEM robotics programs for students grades 7-12.


Note that volunteers (except for FTA/WTA/CSA will still access their role specific forum through this site. The blog also outlines how to access the volunteer forums.
See more
See less

Check Robot Battery In Program

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

  • Check Robot Battery In Program

    Hi,

    Our robot moves at different speeds in our autonomous based on the amount of power it gets (high power = faster, and vice-versa with low), despite being set to the same motor power. We were wondering if there is any way to check the robot's battery power via code, so that we can set the robot to different motor powers depending on the battery's voltage. While we will be changing batteries often in competition to keep at high power, it would be very useful since our robot drains power pretty quickly.

    Thank you,
    Maelstrom

  • #2
    Have you tried using the runmode RUN_WITH_ENCODER? It sets the speed of the motor, not the power level.

    More about halfway down this link -
    https://gm0.copperforge.cc/en/stable...g-the-sdk.html

    Comment


    • #3
      We have code for the robot to move a certain distance using encoders, but for one part of our autonomous we are using distance sensors. The problem we are running into is that the robot moves too fast at high power and too slow at low power, so we can't set just one motor power because the robot doesn't always move at that same speed. Therefore, the robot keeps plowing into the blocks we are trying to make it stop in front of at high battery, or crawling towards it (with the same motor power) at low battery.

      Comment


      • #4
        Originally posted by Maelstrom View Post
        We have code for the robot to move a certain distance using encoders, but for one part of our autonomous we are using distance sensors. The problem we are running into is that the robot moves too fast at high power and too slow at low power, so we can't set just one motor power because the robot doesn't always move at that same speed. Therefore, the robot keeps plowing into the blocks we are trying to make it stop in front of at high battery, or crawling towards it (with the same motor power) at low battery.
        Run with Encoder Does Not set a power. The link provided had an explanation. Run without Encoders sets a power level, like 0.5 in setPower will turn the power on and off rapidly with a 50% duty cycle. This makes how fast the motor run dependent on voltage.

        Run with Encoder sends a speed to the motor controller. If you send 0.5 in setPower now the motor controller uses the information in the config file like for a Neverest 40 is speced at about 160 rpm. Half of 160 is 80 (see the link as to why it is actually less). The motor controller will compute the speed of the motor from the encoder and use a PID loop to automatically adjust the voltage to the motor to reach that speed. If it is too slow it keeps increasing the power as needed, and decreases power if too fast.

        For what you have described writing a PID to work with your distance sensor is what you really want.

        Video I show my FLL kids (just for the idea, doesn't show you how to java program it) -


        Comment


        • #5
          I would suggest use run with encoder - then the PID in the expansion hub will keep the motors running at a (relatively) constant speed - automatically increasing the power to the motor if the voltage is low. Note - run with encoder is different than run to position which is what most of us use a lot for moving using encoders.

          However - if you want measure the voltage I would suggest using the Rev Extensions 2 - see the library and how to install, etc at: https://github.com/OpenFTC/RevExtensions2

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎