🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    GO Plus motor stop

    Modules
    2
    2
    4.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      percramer
      last edited by

      Hi all,

      is the code in

      https://github.com/m5stack/GoPlus/blob/master/src/src.ino

      The actual code that it is shipped with? Apart from the fact that it is a bit of a mess, if i read it right then the dc motors should stop if you send a speed of 0

      //duty_motor_num = motor_num;
      if(motor_speed == 0){
      if(motor_num == 0){

        digitalWrite(IN_0, 0);
        digitalWrite(IN_1, 0);
        duty_trun0 = trun;
        duty_speed0 =  motor_speed;
        //MsTimer2::stop(); 
        //time_flag = 0;
        duty0 = 0;
        duty_motor_0_flag = 0;
      
        //analogWrite(IN_0, 0);
        //analogWrite(IN_1, 0);
      }else if(motor_num == 2)
      {
       // digitalWrite(IN_2, 0);
        //digitalWrite(IN_3, 0);
      
        digitalWrite(IN_2, 0);
        digitalWrite(IN_3, 0);
        duty_trun1 = trun;
        duty_speed1 =  motor_speed;
        //MsTimer2::stop(); 
        //time_flag = 0;
        duty1 = 0;
        duty_motor_1_flag = 0;
      
        // analogWrite(IN_2, 0);
        // analogWrite(IN_3, 0);
      } 
      

      }

      it seems like it shoudl first check if the motor speed is 0 and if that is true then check which motor is send. And if the motorspeed <> 0 then it should look at the direction etc.

      But the motor never seems to stop... Can anybody confirm that this is a true?

      ajb2k3A 1 Reply Last reply Reply Quote 0
      • ajb2k3A
        ajb2k3 @percramer
        last edited by

        @percramer you have to use a value just below the motors stall value.
        To make a motor hard stop you perposely stall the motor however, you have to stall and release the motor as soon as it stops or current will ramp up and possibly damage components.

        UIFlow, so easy an adult can learn it!
        If I don't know it, be patient!
        I've ether not learned it or am too drunk to remember it!
        Author of the WIP UIFlow Handbook!
        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

        1 Reply Last reply Reply Quote 0
        • First post
          Last post